@public-ui/components 1.6.0-rc.10 → 1.6.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/custom-elements.json +1 -1
  2. package/dist/cjs/{controller-c3dbd7c8.js → controller-20c47dac.js} +1 -1
  3. package/dist/cjs/{controller-c3dbd7c8.js.map → controller-20c47dac.js.map} +1 -1
  4. package/dist/cjs/{controller-318123f0.js → controller-6aabbf41.js} +1 -1
  5. package/dist/cjs/{controller-318123f0.js.map → controller-6aabbf41.js.map} +1 -1
  6. package/dist/cjs/{controller-aff1063a.js → controller-9a10b30b.js} +1 -1
  7. package/dist/cjs/{controller-aff1063a.js.map → controller-9a10b30b.js.map} +1 -1
  8. package/dist/cjs/{controller-6d3e3486.js → controller-d513b916.js} +1 -1
  9. package/dist/cjs/{controller-6d3e3486.js.map → controller-d513b916.js.map} +1 -1
  10. package/dist/cjs/{controller-icon-d20f7f1b.js → controller-icon-d2ec9da9.js} +1 -1
  11. package/dist/cjs/{controller-icon-d20f7f1b.js.map → controller-icon-d2ec9da9.js.map} +1 -1
  12. package/dist/cjs/kol-badge.cjs.entry.js +1 -1
  13. package/dist/cjs/kol-breadcrumb.cjs.entry.js +1 -1
  14. package/dist/cjs/kol-button-wc_2.cjs.entry.js +1 -1
  15. package/dist/cjs/kol-button-wc_2.cjs.entry.js.map +1 -1
  16. package/dist/cjs/kol-icon.cjs.entry.js +1 -1
  17. package/dist/cjs/kol-input-checkbox.cjs.entry.js +1 -1
  18. package/dist/cjs/kol-input-color.cjs.entry.js +1 -1
  19. package/dist/cjs/kol-input-date.cjs.entry.js +1 -1
  20. package/dist/cjs/kol-input-email.cjs.entry.js +1 -1
  21. package/dist/cjs/kol-input-file.cjs.entry.js +1 -1
  22. package/dist/cjs/kol-input-number.cjs.entry.js +1 -1
  23. package/dist/cjs/kol-input-password.cjs.entry.js +1 -1
  24. package/dist/cjs/kol-input-radio.cjs.entry.js +1 -1
  25. package/dist/cjs/kol-input-range.cjs.entry.js +1 -1
  26. package/dist/cjs/kol-input-text.cjs.entry.js +1 -1
  27. package/dist/cjs/kol-link-group.cjs.entry.js +1 -1
  28. package/dist/cjs/kol-link-wc.cjs.entry.js +1 -1
  29. package/dist/cjs/kol-link-wc.cjs.entry.js.map +1 -1
  30. package/dist/cjs/kol-modal.cjs.entry.js +1 -1
  31. package/dist/cjs/kol-nav.cjs.entry.js +1 -1
  32. package/dist/cjs/kol-progress.cjs.entry.js +1 -1
  33. package/dist/cjs/kol-select.cjs.entry.js +1 -1
  34. package/dist/cjs/kol-skip-nav.cjs.entry.js +1 -1
  35. package/dist/cjs/kol-span-wc.cjs.entry.js +1 -1
  36. package/dist/cjs/kol-split-button.cjs.entry.js +1 -1
  37. package/dist/cjs/kol-symbol.cjs.entry.js +1 -1
  38. package/dist/cjs/kol-tabs.cjs.entry.js +1 -1
  39. package/dist/cjs/kol-textarea.cjs.entry.js +1 -1
  40. package/dist/cjs/kol-tooltip.cjs.entry.js +1 -1
  41. package/dist/cjs/kol-version.cjs.entry.js +1 -1
  42. package/dist/cjs/{label-62d191b9.js → label-5738ac71.js} +1 -1
  43. package/dist/cjs/label-5738ac71.js.map +1 -0
  44. package/dist/components/component5.js +1 -1
  45. package/dist/components/component5.js.map +1 -1
  46. package/dist/components/component8.js +1 -1
  47. package/dist/components/component8.js.map +1 -1
  48. package/dist/components/label.js +1 -1
  49. package/dist/components/label.js.map +1 -1
  50. package/dist/esm/{controller-1ef374de.js → controller-0a60db6b.js} +1 -1
  51. package/dist/esm/{controller-1ef374de.js.map → controller-0a60db6b.js.map} +1 -1
  52. package/dist/esm/{controller-7726af85.js → controller-3b1a37ac.js} +1 -1
  53. package/dist/esm/{controller-7726af85.js.map → controller-3b1a37ac.js.map} +1 -1
  54. package/dist/esm/{controller-01bbe05c.js → controller-d9fb3dc1.js} +1 -1
  55. package/dist/esm/{controller-01bbe05c.js.map → controller-d9fb3dc1.js.map} +1 -1
  56. package/dist/esm/{controller-3950f463.js → controller-ff99125c.js} +1 -1
  57. package/dist/esm/{controller-3950f463.js.map → controller-ff99125c.js.map} +1 -1
  58. package/dist/esm/{controller-icon-d403e7d6.js → controller-icon-ba3c5351.js} +1 -1
  59. package/dist/esm/{controller-icon-d403e7d6.js.map → controller-icon-ba3c5351.js.map} +1 -1
  60. package/dist/esm/kol-badge.entry.js +1 -1
  61. package/dist/esm/kol-breadcrumb.entry.js +1 -1
  62. package/dist/esm/kol-button-wc_2.entry.js +1 -1
  63. package/dist/esm/kol-button-wc_2.entry.js.map +1 -1
  64. package/dist/esm/kol-icon.entry.js +1 -1
  65. package/dist/esm/kol-input-checkbox.entry.js +1 -1
  66. package/dist/esm/kol-input-color.entry.js +1 -1
  67. package/dist/esm/kol-input-date.entry.js +1 -1
  68. package/dist/esm/kol-input-email.entry.js +1 -1
  69. package/dist/esm/kol-input-file.entry.js +1 -1
  70. package/dist/esm/kol-input-number.entry.js +1 -1
  71. package/dist/esm/kol-input-password.entry.js +1 -1
  72. package/dist/esm/kol-input-radio.entry.js +1 -1
  73. package/dist/esm/kol-input-range.entry.js +1 -1
  74. package/dist/esm/kol-input-text.entry.js +1 -1
  75. package/dist/esm/kol-link-group.entry.js +1 -1
  76. package/dist/esm/kol-link-wc.entry.js +1 -1
  77. package/dist/esm/kol-link-wc.entry.js.map +1 -1
  78. package/dist/esm/kol-modal.entry.js +1 -1
  79. package/dist/esm/kol-nav.entry.js +1 -1
  80. package/dist/esm/kol-progress.entry.js +1 -1
  81. package/dist/esm/kol-select.entry.js +1 -1
  82. package/dist/esm/kol-skip-nav.entry.js +1 -1
  83. package/dist/esm/kol-span-wc.entry.js +1 -1
  84. package/dist/esm/kol-split-button.entry.js +1 -1
  85. package/dist/esm/kol-symbol.entry.js +1 -1
  86. package/dist/esm/kol-tabs.entry.js +1 -1
  87. package/dist/esm/kol-textarea.entry.js +1 -1
  88. package/dist/esm/kol-tooltip.entry.js +1 -1
  89. package/dist/esm/kol-version.entry.js +1 -1
  90. package/dist/esm/{label-2a601017.js → label-bd9566f6.js} +1 -1
  91. package/dist/esm/label-bd9566f6.js.map +1 -0
  92. package/dist/kolibri/{controller-1ef374de.js → controller-0a60db6b.js} +1 -1
  93. package/dist/kolibri/{controller-7726af85.js → controller-3b1a37ac.js} +1 -1
  94. package/dist/kolibri/{controller-01bbe05c.js → controller-d9fb3dc1.js} +1 -1
  95. package/dist/kolibri/{controller-3950f463.js → controller-ff99125c.js} +1 -1
  96. package/dist/kolibri/{controller-icon-d403e7d6.js → controller-icon-ba3c5351.js} +1 -1
  97. package/dist/kolibri/kol-badge.entry.js +1 -1
  98. package/dist/kolibri/kol-breadcrumb.entry.js +1 -1
  99. package/dist/kolibri/kol-button-wc_2.entry.js +1 -1
  100. package/dist/kolibri/kol-button-wc_2.entry.js.map +1 -1
  101. package/dist/kolibri/kol-icon.entry.js +1 -1
  102. package/dist/kolibri/kol-input-checkbox.entry.js +1 -1
  103. package/dist/kolibri/kol-input-color.entry.js +1 -1
  104. package/dist/kolibri/kol-input-color.entry.js.map +1 -1
  105. package/dist/kolibri/kol-input-date.entry.js +1 -1
  106. package/dist/kolibri/kol-input-email.entry.js +1 -1
  107. package/dist/kolibri/kol-input-file.entry.js +1 -1
  108. package/dist/kolibri/kol-input-number.entry.js +1 -1
  109. package/dist/kolibri/kol-input-password.entry.js +1 -1
  110. package/dist/kolibri/kol-input-radio.entry.js +1 -1
  111. package/dist/kolibri/kol-input-range.entry.js +1 -1
  112. package/dist/kolibri/kol-input-text.entry.js +1 -1
  113. package/dist/kolibri/kol-link-group.entry.js +1 -1
  114. package/dist/kolibri/kol-link-wc.entry.js +1 -1
  115. package/dist/kolibri/kol-link-wc.entry.js.map +1 -1
  116. package/dist/kolibri/kol-modal.entry.js +1 -1
  117. package/dist/kolibri/kol-nav.entry.js +1 -1
  118. package/dist/kolibri/kol-progress.entry.js +1 -1
  119. package/dist/kolibri/kol-select.entry.js +1 -1
  120. package/dist/kolibri/kol-skip-nav.entry.js +1 -1
  121. package/dist/kolibri/kol-span-wc.entry.js +1 -1
  122. package/dist/kolibri/kol-split-button.entry.js +1 -1
  123. package/dist/kolibri/kol-symbol.entry.js +1 -1
  124. package/dist/kolibri/kol-tabs.entry.js +1 -1
  125. package/dist/kolibri/kol-textarea.entry.js +1 -1
  126. package/dist/kolibri/kol-tooltip.entry.js +1 -1
  127. package/dist/kolibri/kol-version.entry.js +1 -1
  128. package/dist/kolibri/label-bd9566f6.js +4 -0
  129. package/dist/kolibri/{label-2a601017.js.map → label-bd9566f6.js.map} +1 -1
  130. package/doc/modal.md +1 -1
  131. package/jest-test-results.json +1 -1
  132. package/package.json +1 -1
  133. package/dist/cjs/label-62d191b9.js.map +0 -1
  134. package/dist/esm/label-2a601017.js.map +0 -1
  135. package/dist/kolibri/label-2a601017.js +0 -4
  136. /package/dist/kolibri/{controller-1ef374de.js.map → controller-0a60db6b.js.map} +0 -0
  137. /package/dist/kolibri/{controller-7726af85.js.map → controller-3b1a37ac.js.map} +0 -0
  138. /package/dist/kolibri/{controller-01bbe05c.js.map → controller-d9fb3dc1.js.map} +0 -0
  139. /package/dist/kolibri/{controller-3950f463.js.map → controller-ff99125c.js.map} +0 -0
  140. /package/dist/kolibri/{controller-icon-d403e7d6.js.map → controller-icon-ba3c5351.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/components",
3
- "version": "1.6.0-rc.10",
3
+ "version": "1.6.0-rc.11",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "bugs": { "url": "https://github.com/public-ui/kolibri/issues", "email": "kolibri@itzbund.de" },
@@ -1 +0,0 @@
1
- {"file":"label-62d191b9.js","mappings":";;;;;;;;AAYA,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAK7C,MAAM,YAAY,GAAG,OAAO,CAAC;AAO7B,SAAS,kBAAkB,CAAC,GAAW;;EACtC,OAAO,OAAO,GAAG,KAAK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,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/H,EAAE;AAEF,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;MACtD,2BAA2B,GAAG,CAC1C,SAAoC,EACpC,KAAmC,EACnC,UAA8B,EAAE;EAEhC,IAAI,KAAK,KAAK,EAAE,EAAE;IACjB,KAAK,GAAG,KAAK,CAAC;GACd;EACDA,8BAAc,CACb,SAAS,EACT,QAAQ,EACR,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EACvD,6BAA6B,EAC7B,KAAK,EACL,oBAAoB,CAAC,OAAO,CAAC,CAC7B,CAAC;AACH;;;;;;;","names":["a11yHint","uiUxHint","watchValidator"],"sources":["src/types/props/label.ts"],"sourcesContent":["import { Generic } from '@a11y-ui/core';\n\nimport { a11yHint, uiUxHint } from '../../utils/a11y.tipps';\nimport { WatchStringOptions, watchValidator } from '../../utils/prop.validators';\n\n/* types */\n\n/**\n * This is a regular expression that matches all readable characters.\n *\n * Interesting: https://stackoverflow.com/questions/150033/regular-expression-to-match-non-english-characters\n */\nconst READABLE_CHARS = /[a-zA-Z0-9äöüÄÖÜß]/g;\n\n/**\n * This is a regular expression that matches only numbers.\n */\nconst ONLY_NUMBERS = /^\\d+$/;\n\n/**\n * This function counts the number of readable characters in a string.\n * @param str The string to count.\n * @returns The number of readable characters in the string.\n */\nfunction countReadableChars(str: string): number {\n\treturn typeof str === 'string' ? str.match(READABLE_CHARS)?.length || 0 : 0;\n}\n\n/**\n * This function checks if a string has at least a certain number of readable characters.\n * @param str The string to check.\n * @param min The minimum number of readable characters.\n * @returns True if the string has at least the minimum number of readable characters, false otherwise.\n */\nexport function hasEnoughReadableChars(str: string, min = 1): boolean {\n\treturn countReadableChars(str) >= min;\n}\n\n/**\n * This function checks if a string contains only numbers.\n * @param str The string to check.\n * @returns True if the string contains only numbers, false otherwise.\n */\nexport function containsOnlyNumbers(str: string): boolean {\n\treturn ONLY_NUMBERS.test(str);\n}\n\n/**\n * Defines the type of the label property.\n */\nexport type LabelPropType = string;\n\n/**\n * Defines the type of the label with expert-slot toggle property.\n */\nexport type LabelWithExpertSlotPropType = LabelPropType | false;\n\n/**\n * The label property is used to label different elements:\n * - abbr -> title text\n * - button -> label text\n * - heading -> headline text\n * - input, select and textarea -> label text\n * - summary -> summary text\n * - quote, table -> caption text\n * - version -> version text\n * - etc.\n *\n * The label is often a mandatory attribute. If the value of the label is false,\n * the expert-slot will be used. Otherwise, the value of the label must be a string\n * and the expert-slot will be ignored.\n */\nexport type PropLabel = {\n\tlabel: LabelPropType;\n};\nexport type PropLabelWithExpertSlot = {\n\tlabel: LabelWithExpertSlotPropType;\n};\n\nexport type LabelProp = Generic.Element.Members<PropLabel, unknown>;\n// type LabelWithExpertSlotProp = Generic.Element.Members<PropLabelWithExpertSlot, unknown>;\n\nfunction getValidationOptions(options: WatchStringOptions): WatchStringOptions {\n\treturn {\n\t\thooks: {\n\t\t\tafterPatch: (value, state, component, key) => {\n\t\t\t\tif (typeof options.hooks?.afterPatch === 'function') {\n\t\t\t\t\toptions.hooks?.afterPatch(value, state, component, key);\n\t\t\t\t}\n\t\t\t\tif (typeof value === 'string' && hasEnoughReadableChars(value, 3) === false && containsOnlyNumbers(value) === false) {\n\t\t\t\t\ta11yHint(`The heading or label (\"${value}\") is not accessible. A label should consist of at least three readable characters.`);\n\t\t\t\t}\n\t\t\t\tif (typeof value === 'string' && value.length > 80) {\n\t\t\t\t\tuiUxHint(`A heading or label should not be longer than 80 characters.`);\n\t\t\t\t}\n\t\t\t},\n\t\t\tbeforePatch: options.hooks?.beforePatch,\n\t\t},\n\t};\n}\n\nconst LABEL_VALUES = new Set(['string']);\nexport const validateLabel = (component: Generic.Element.Component, value?: LabelPropType, options: WatchStringOptions = {}): void => {\n\twatchValidator(component, '_label', (value) => typeof value === 'string', LABEL_VALUES, value, getValidationOptions(options));\n};\n\nconst LABEL_WITH_EXPERT_SLOT_VALUES = new Set(['string', 'false']);\nexport const validateLabelWithExpertSlot = (\n\tcomponent: Generic.Element.Component,\n\tvalue?: LabelWithExpertSlotPropType,\n\toptions: WatchStringOptions = {}\n): void => {\n\tif (value === '') {\n\t\tvalue = false; // TODO: remove this workaround in v2\n\t}\n\twatchValidator(\n\t\tcomponent,\n\t\t'_label',\n\t\t(value) => value === false || typeof value === 'string',\n\t\tLABEL_WITH_EXPERT_SLOT_VALUES,\n\t\tvalue,\n\t\tgetValidationOptions(options)\n\t);\n};\n\n// TODO: Validation for labelWithExpertSlot\n"],"version":3}
@@ -1 +0,0 @@
1
- {"file":"label-2a601017.js","mappings":";;;;;;AAYA,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAK7C,MAAM,YAAY,GAAG,OAAO,CAAC;AAO7B,SAAS,kBAAkB,CAAC,GAAW;;EACtC,OAAO,OAAO,GAAG,KAAK,QAAQ,GAAG,CAAA,MAAA,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,0CAAE,MAAM,KAAI,CAAC,GAAG,CAAC,CAAC;AAC7E,CAAC;SAQe,sBAAsB,CAAC,GAAW,EAAE,GAAG,GAAG,CAAC;EAC1D,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AACvC,CAAC;SAOe,mBAAmB,CAAC,GAAW;EAC9C,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAqCD,SAAS,oBAAoB,CAAC,OAA2B;;EACxD,OAAO;IACN,KAAK,EAAE;MACN,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG;;QACxC,IAAI,QAAO,MAAA,OAAO,CAAC,KAAK,0CAAE,UAAU,CAAA,KAAK,UAAU,EAAE;UACpD,MAAA,O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","names":[],"sources":["src/types/props/label.ts"],"sourcesContent":["import { Generic } from '@a11y-ui/core';\n\nimport { a11yHint, uiUxHint } from '../../utils/a11y.tipps';\nimport { WatchStringOptions, watchValidator } from '../../utils/prop.validators';\n\n/* types */\n\n/**\n * This is a regular expression that matches all readable characters.\n *\n * Interesting: https://stackoverflow.com/questions/150033/regular-expression-to-match-non-english-characters\n */\nconst READABLE_CHARS = /[a-zA-Z0-9äöüÄÖÜß]/g;\n\n/**\n * This is a regular expression that matches only numbers.\n */\nconst ONLY_NUMBERS = /^\\d+$/;\n\n/**\n * This function counts the number of readable characters in a string.\n * @param str The string to count.\n * @returns The number of readable characters in the string.\n */\nfunction countReadableChars(str: string): number {\n\treturn typeof str === 'string' ? str.match(READABLE_CHARS)?.length || 0 : 0;\n}\n\n/**\n * This function checks if a string has at least a certain number of readable characters.\n * @param str The string to check.\n * @param min The minimum number of readable characters.\n * @returns True if the string has at least the minimum number of readable characters, false otherwise.\n */\nexport function hasEnoughReadableChars(str: string, min = 1): boolean {\n\treturn countReadableChars(str) >= min;\n}\n\n/**\n * This function checks if a string contains only numbers.\n * @param str The string to check.\n * @returns True if the string contains only numbers, false otherwise.\n */\nexport function containsOnlyNumbers(str: string): boolean {\n\treturn ONLY_NUMBERS.test(str);\n}\n\n/**\n * Defines the type of the label property.\n */\nexport type LabelPropType = string;\n\n/**\n * Defines the type of the label with expert-slot toggle property.\n */\nexport type LabelWithExpertSlotPropType = LabelPropType | false;\n\n/**\n * The label property is used to label different elements:\n * - abbr -> title text\n * - button -> label text\n * - heading -> headline text\n * - input, select and textarea -> label text\n * - summary -> summary text\n * - quote, table -> caption text\n * - version -> version text\n * - etc.\n *\n * The label is often a mandatory attribute. If the value of the label is false,\n * the expert-slot will be used. Otherwise, the value of the label must be a string\n * and the expert-slot will be ignored.\n */\nexport type PropLabel = {\n\tlabel: LabelPropType;\n};\nexport type PropLabelWithExpertSlot = {\n\tlabel: LabelWithExpertSlotPropType;\n};\n\nexport type LabelProp = Generic.Element.Members<PropLabel, unknown>;\n// type LabelWithExpertSlotProp = Generic.Element.Members<PropLabelWithExpertSlot, unknown>;\n\nfunction getValidationOptions(options: WatchStringOptions): WatchStringOptions {\n\treturn {\n\t\thooks: {\n\t\t\tafterPatch: (value, state, component, key) => {\n\t\t\t\tif (typeof options.hooks?.afterPatch === 'function') {\n\t\t\t\t\toptions.hooks?.afterPatch(value, state, component, key);\n\t\t\t\t}\n\t\t\t\tif (typeof value === 'string' && hasEnoughReadableChars(value, 3) === false && containsOnlyNumbers(value) === false) {\n\t\t\t\t\ta11yHint(`The heading or label (\"${value}\") is not accessible. A label should consist of at least three readable characters.`);\n\t\t\t\t}\n\t\t\t\tif (typeof value === 'string' && value.length > 80) {\n\t\t\t\t\tuiUxHint(`A heading or label should not be longer than 80 characters.`);\n\t\t\t\t}\n\t\t\t},\n\t\t\tbeforePatch: options.hooks?.beforePatch,\n\t\t},\n\t};\n}\n\nconst LABEL_VALUES = new Set(['string']);\nexport const validateLabel = (component: Generic.Element.Component, value?: LabelPropType, options: WatchStringOptions = {}): void => {\n\twatchValidator(component, '_label', (value) => typeof value === 'string', LABEL_VALUES, value, getValidationOptions(options));\n};\n\nconst LABEL_WITH_EXPERT_SLOT_VALUES = new Set(['string', 'false']);\nexport const validateLabelWithExpertSlot = (\n\tcomponent: Generic.Element.Component,\n\tvalue?: LabelWithExpertSlotPropType,\n\toptions: WatchStringOptions = {}\n): void => {\n\tif (value === '') {\n\t\tvalue = false; // TODO: remove this workaround in v2\n\t}\n\twatchValidator(\n\t\tcomponent,\n\t\t'_label',\n\t\t(value) => value === false || typeof value === 'string',\n\t\tLABEL_WITH_EXPERT_SLOT_VALUES,\n\t\tvalue,\n\t\tgetValidationOptions(options)\n\t);\n};\n\n// TODO: Validation for labelWithExpertSlot\n"],"version":3}
@@ -1,4 +0,0 @@
1
- /*!
2
- * KoliBri - The accessible HTML-Standard
3
- */
4
- import{a as t,u as o}from"./a11y.tipps-e607b8b3.js";import{a as e}from"./prop.validators-683bb1d0.js";const a=/[a-zA-Z0-9äöüÄÖÜß]/g,n=/^\d+$/;function s(t){var e;return"string"==typeof t&&(null===(e=t.match(a))||void 0===e?void 0:e.length)||0}function r(t,e=1){return s(t)>=e}function i(t){return n.test(t)}function l(e){var a;return{hooks:{afterPatch:(a,n,s,l)=>{var c,f;"function"==typeof(null===(c=e.hooks)||void 0===c?void 0:c.afterPatch)&&(null===(f=e.hooks)||void 0===f||f.afterPatch(a,n,s,l)),"string"==typeof a&&!1===r(a,3)&&!1===i(a)&&t(`The heading or label ("${a}") is not accessible. A label should consist of at least three readable characters.`),"string"==typeof a&&a.length>80&&o("A heading or label should not be longer than 80 characters.")},beforePatch:null===(a=e.hooks)||void 0===a?void 0:a.beforePatch}}}const f=new Set(["string"]),c=(t,o,a={})=>{e(t,"_label",(t=>"string"==typeof t),f,o,l(a))},d=new Set(["string","false"]),u=(t,o,a={})=>{""===o&&(o=!1),e(t,"_label",(t=>!1===t||"string"==typeof t),d,o,l(a))};export{u as a,i as c,r as h,c as v};