<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>https://wiki.iccup.org/index.php?action=history&amp;feed=atom&amp;title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%3ADisplayUtil</id>
	<title>Модуль:DisplayUtil - История изменений</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.iccup.org/index.php?action=history&amp;feed=atom&amp;title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%3ADisplayUtil"/>
	<link rel="alternate" type="text/html" href="https://wiki.iccup.org/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:DisplayUtil&amp;action=history"/>
	<updated>2026-05-31T12:04:07Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.iccup.org/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:DisplayUtil&amp;diff=165&amp;oldid=prev</id>
		<title>DarkMuse: Новая страница: «--- -- @iCCup -- wiki=commons -- page=Module:DisplayUtil -- -- Please see https://github.com/iCCup/Lua-Modules to contribute --  local Array = require(&#039;Module:Array&#039;) local FeatureFlag = require(&#039;Module:FeatureFlag&#039;) local FnUtil = require(&#039;Module:FnUtil&#039;) local Logic = require(&#039;Module:Logic&#039;) local TypeUtil = require(&#039;Module:TypeUtil&#039;)  local DisplayUtil = {propTypes = {}, types = {}}  --[[ Checks that the props to be used by a display component satisfy typ...»</title>
		<link rel="alternate" type="text/html" href="https://wiki.iccup.org/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:DisplayUtil&amp;diff=165&amp;oldid=prev"/>
		<updated>2024-08-31T21:51:09Z</updated>

		<summary type="html">&lt;p&gt;Новая страница: «--- -- @iCCup -- wiki=commons -- page=Module:DisplayUtil -- -- Please see https://github.com/iCCup/Lua-Modules to contribute --  local Array = require(&amp;#039;Module:Array&amp;#039;) local FeatureFlag = require(&amp;#039;Module:FeatureFlag&amp;#039;) local FnUtil = require(&amp;#039;Module:FnUtil&amp;#039;) local Logic = require(&amp;#039;Module:Logic&amp;#039;) local TypeUtil = require(&amp;#039;Module:TypeUtil&amp;#039;)  local DisplayUtil = {propTypes = {}, types = {}}  --[[ Checks that the props to be used by a display component satisfy typ...»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;---&lt;br /&gt;
-- @iCCup&lt;br /&gt;
-- wiki=commons&lt;br /&gt;
-- page=Module:DisplayUtil&lt;br /&gt;
--&lt;br /&gt;
-- Please see https://github.com/iCCup/Lua-Modules to contribute&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local Array = require(&amp;#039;Module:Array&amp;#039;)&lt;br /&gt;
local FeatureFlag = require(&amp;#039;Module:FeatureFlag&amp;#039;)&lt;br /&gt;
local FnUtil = require(&amp;#039;Module:FnUtil&amp;#039;)&lt;br /&gt;
local Logic = require(&amp;#039;Module:Logic&amp;#039;)&lt;br /&gt;
local TypeUtil = require(&amp;#039;Module:TypeUtil&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local DisplayUtil = {propTypes = {}, types = {}}&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Checks that the props to be used by a display component satisfy type&lt;br /&gt;
constraints. Throws if it does not.&lt;br /&gt;
&lt;br /&gt;
For performance reasons, type checking is disabled unless the force_type_check&lt;br /&gt;
feature flag is enabled via {{#vardefine:feature_force_type_check|1}}.&lt;br /&gt;
&lt;br /&gt;
By default this only checks the contents of table properties up to 1 deep.&lt;br /&gt;
Specify options.maxDepth to increase the depth.&lt;br /&gt;
]]&lt;br /&gt;
---@param props table&lt;br /&gt;
---@param propTypes table&lt;br /&gt;
---@param options {maxDepth: integer?}?&lt;br /&gt;
DisplayUtil.assertPropTypes = function(props, propTypes, options)&lt;br /&gt;
	local typeCheckFeature = FeatureFlag.get(&amp;#039;force_type_check&amp;#039;)&lt;br /&gt;
	if not typeCheckFeature then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	options = options or {}&lt;br /&gt;
&lt;br /&gt;
	local errors = TypeUtil.checkValue(&lt;br /&gt;
		props,&lt;br /&gt;
		TypeUtil.struct(propTypes),&lt;br /&gt;
		{&lt;br /&gt;
			maxDepth = options.maxDepth or 2,&lt;br /&gt;
			name = &amp;#039;props&amp;#039;,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
	if #errors &amp;gt; 0 then&lt;br /&gt;
		error(table.concat(errors, &amp;#039;\n&amp;#039;), 2)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---Attempts to render a display component in the pure function style.&lt;br /&gt;
---The error is caught and displayed using classic error style.&lt;br /&gt;
---@param Component fun(props: table): Html&lt;br /&gt;
---@param props table&lt;br /&gt;
---@param other fun(error: Error): Html&lt;br /&gt;
---@return Html&lt;br /&gt;
function DisplayUtil.TryPureComponent(Component, props, other)&lt;br /&gt;
	return Logic.tryOrElseLog(&lt;br /&gt;
		function() return Component(props) end,&lt;br /&gt;
		other,&lt;br /&gt;
		function(error)&lt;br /&gt;
			error.header = &amp;#039;Error occurred in display component: (caught by DisplayUtil.TryPureComponent)&amp;#039;&lt;br /&gt;
			return error&lt;br /&gt;
		end&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
DisplayUtil.tryOrLog = DisplayUtil.TryPureComponent&lt;br /&gt;
DisplayUtil.tryOrElseLog = DisplayUtil.TryPureComponent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@alias OverflowModes &amp;#039;ellipsis&amp;#039;|&amp;#039;wrap&amp;#039;|&amp;#039;hidden&amp;#039;&lt;br /&gt;
DisplayUtil.types.OverflowModes = TypeUtil.literalUnion(&amp;#039;ellipsis&amp;#039;, &amp;#039;wrap&amp;#039;, &amp;#039;hidden&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
---Specifies overflow behavior on a block element. mode can be &amp;#039;ellipsis&amp;#039;, &amp;#039;wrap&amp;#039;, or &amp;#039;hidden&amp;#039;.&lt;br /&gt;
---@param node Html&lt;br /&gt;
---@param mode OverflowModes&lt;br /&gt;
---@return Html&lt;br /&gt;
function DisplayUtil.applyOverflowStyles(node, mode)&lt;br /&gt;
	return node&lt;br /&gt;
		:css(&amp;#039;overflow&amp;#039;, (mode == &amp;#039;ellipsis&amp;#039; or mode == &amp;#039;hidden&amp;#039;) and &amp;#039;hidden&amp;#039; or nil)&lt;br /&gt;
		:css(&amp;#039;overflow-wrap&amp;#039;, mode == &amp;#039;wrap&amp;#039; and &amp;#039;break-word&amp;#039; or nil)&lt;br /&gt;
		:css(&amp;#039;text-overflow&amp;#039;, mode == &amp;#039;ellipsis&amp;#039; and &amp;#039;ellipsis&amp;#039; or nil)&lt;br /&gt;
		:css(&amp;#039;white-space&amp;#039;, (mode == &amp;#039;ellipsis&amp;#039; or mode == &amp;#039;hidden&amp;#039;) and &amp;#039;pre&amp;#039; or &amp;#039;normal&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Whether a value is a mediawiki html node.&lt;br /&gt;
local mwHtmlMetatable = FnUtil.memoize(function()&lt;br /&gt;
	return getmetatable(mw.html.create(&amp;#039;div&amp;#039;))&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
---@param x any&lt;br /&gt;
---@return boolean&lt;br /&gt;
function DisplayUtil.isMwHtmlNode(x)&lt;br /&gt;
	return type(x) == &amp;#039;table&amp;#039;&lt;br /&gt;
		and getmetatable(x) == mwHtmlMetatable()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---Like Array.flatten, except that mediawiki html nodes are not considered arrays.&lt;br /&gt;
---@generic T&lt;br /&gt;
---@param elems T[]&lt;br /&gt;
---@return T[]&lt;br /&gt;
function DisplayUtil.flattenArray(elems)&lt;br /&gt;
	local flattened = {}&lt;br /&gt;
	for _, elem in ipairs(elems) do&lt;br /&gt;
		if type(elem) == &amp;#039;table&amp;#039;&lt;br /&gt;
			and not DisplayUtil.isMwHtmlNode(elem) then&lt;br /&gt;
			Array.extendWith(flattened, elem)&lt;br /&gt;
		elseif elem then&lt;br /&gt;
			table.insert(flattened, elem)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return flattened&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[===[&lt;br /&gt;
Clears the link param in a wikicode link.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
DisplayUtil.removeLinkFromWikiLink(&amp;#039;[[File:ZergIcon.png|14px|link=Zerg]]&amp;#039;)&lt;br /&gt;
-- returns &amp;#039;[[File:ZergIcon.png|14px|link=]]&amp;#039;&amp;#039;&lt;br /&gt;
]===]&lt;br /&gt;
---@param text string&lt;br /&gt;
---@return string&lt;br /&gt;
function DisplayUtil.removeLinkFromWikiLink(text)&lt;br /&gt;
	local textNoLink = text:gsub(&amp;#039;link=[^|%]]*&amp;#039;, &amp;#039;link=&amp;#039;)&lt;br /&gt;
	return textNoLink&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return DisplayUtil&lt;/div&gt;</summary>
		<author><name>DarkMuse</name></author>
	</entry>
</feed>