@nl-design-system-community/clippy-components 1.2.0 → 2.0.0
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.
- package/dist/clippy-button/index.js +4 -4
- package/dist/clippy-code/index.js +18 -15
- package/dist/clippy-color-combobox/index.d.ts +9 -13
- package/dist/clippy-color-combobox/index.d.ts.map +1 -1
- package/dist/clippy-color-combobox/index.js +6 -5
- package/dist/clippy-color-combobox/lib.d.ts +16 -12
- package/dist/clippy-color-combobox/lib.d.ts.map +1 -1
- package/dist/clippy-color-combobox/messages/en.d.ts +14 -6
- package/dist/clippy-color-combobox/messages/en.d.ts.map +1 -1
- package/dist/clippy-color-combobox/messages/nl.d.ts +14 -6
- package/dist/clippy-color-combobox/messages/nl.d.ts.map +1 -1
- package/dist/clippy-combobox/index.d.ts +22 -8
- package/dist/clippy-combobox/index.d.ts.map +1 -1
- package/dist/clippy-combobox/index.js +703 -8
- package/dist/clippy-font-combobox/index.d.ts +4 -3
- package/dist/clippy-font-combobox/index.d.ts.map +1 -1
- package/dist/clippy-font-combobox/index.js +94 -59
- package/dist/clippy-heading/index.js +180 -174
- package/dist/clippy-html-image/index.js +51 -31
- package/dist/clippy-icon/index.js +22 -16
- package/dist/clippy-lang-combobox/index.d.ts +2 -4
- package/dist/clippy-lang-combobox/index.d.ts.map +1 -1
- package/dist/clippy-lang-combobox/index.js +104 -78
- package/dist/clippy-modal/index.d.ts +3 -3
- package/dist/clippy-modal/index.d.ts.map +1 -1
- package/dist/clippy-modal/index.js +98 -89
- package/dist/clippy-toggletip/index.d.ts +16 -0
- package/dist/clippy-toggletip/index.d.ts.map +1 -0
- package/dist/clippy-toggletip/index.js +180 -0
- package/dist/decorators-Cq82_-g_.js +11 -0
- package/dist/en-D1kE0w6o.js +4 -0
- package/dist/external-BCrp-PaG.js +4 -0
- package/dist/index-7tZ2Ykfm.js +135 -0
- package/dist/index-C9pF3BXT.js +10683 -0
- package/dist/lib/FormElement/index.d.ts +2 -1
- package/dist/lib/FormElement/index.d.ts.map +1 -1
- package/dist/lib/FormElement/index.js +95 -0
- package/dist/lib/LocalizationMixin/index.d.ts.map +1 -1
- package/dist/lib/LocalizationMixin/index.js +64 -0
- package/dist/lib/converters/index.d.ts +4 -0
- package/dist/lib/converters/index.d.ts.map +1 -1
- package/dist/lib/converters/index.js +35 -0
- package/dist/lib/sr-only/index.d.ts +3 -0
- package/dist/lib/sr-only/index.d.ts.map +1 -0
- package/dist/lib/sr-only/index.js +18 -0
- package/dist/nl-99gBQbne.js +19 -0
- package/package.json +19 -16
- package/dist/decorators-BGpMqJ7V.js +0 -7
- package/dist/en-B-D8DBsf.js +0 -4
- package/dist/external-Dtf6f6DP.js +0 -4
- package/dist/index-CT1z3SFL.js +0 -106
- package/dist/index-CaVpiaBC.js +0 -52
- package/dist/index-CmKtM5nD.js +0 -379
- package/dist/index-CtreqNZ6.js +0 -3602
- package/dist/index-D3FiqptQ.js +0 -65
- package/dist/nl-CJG2-yS5.js +0 -11
|
@@ -1,10 +1,705 @@
|
|
|
1
|
-
import "../decorators-
|
|
2
|
-
import {
|
|
3
|
-
import "lit";
|
|
4
|
-
import "lit/
|
|
5
|
-
import "lit/directives/
|
|
6
|
-
import "
|
|
7
|
-
import "../index
|
|
1
|
+
import { s as safeCustomElement } from "../decorators-Cq82_-g_.js";
|
|
2
|
+
import { css, unsafeCSS, nothing, html } from "lit";
|
|
3
|
+
import { property, state } from "lit/decorators.js";
|
|
4
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
5
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
6
|
+
import { allowedValuesConverter, arrayFromTokenList } from "../lib/converters/index.js";
|
|
7
|
+
import { FormElement } from "../lib/FormElement/index.js";
|
|
8
|
+
import srOnly from "../lib/sr-only/index.js";
|
|
9
|
+
const comboboxStyles = "/**\n * @license EUPL-1.2\n * Copyright (c) 2023 Frameless B.V.\n */\n.utrecht-combobox {\n inline-size: 100%;\n max-inline-size: var(--utrecht-textbox-max-inline-size, var(--utrecht-form-control-max-inline-size));\n position: relative;\n}\n\n.utrecht-combobox__popover {\n border-width: 0;\n padding-block-end: 0;\n padding-block-start: 0;\n padding-inline-end: 0;\n padding-inline-start: 0;\n background-color: canvas;\n block-size: fit-content;\n color: canvastext;\n inline-size: fit-content;\n inset: 0;\n overflow: auto;\n position: absolute;\n z-index: var(--utrecht-combobox-popover-z-index, 1);\n}\n\n.utrecht-combobox__popover--block-end {\n inset-block-start: 100%;\n}\n\n.utrecht-combobox__popover--hidden {\n display: none !important;\n}";
|
|
10
|
+
const listboxStyles = "/**\n * @license EUPL-1.2\n * Copyright (c) 2020-2024 Frameless B.V.\n * Copyright (c) 2021-2024 Gemeente Utrecht\n */\n/**\n * @license EUPL-1.2\n * Copyright (c) 2023 Frameless B.V.\n */\n.utrecht-listbox {\n --utrecht-listbox-max-block-size: 300px;\n background-color: var(--_utrecht-listbox-disabled-background-color, var(--_utrecht-listbox-interactive-background-color, var(--utrecht-listbox-background-color)));\n border-color: var(--_utrecht-listbox-disabled-border-color, var(--_utrecht-listbox-interactive-border-color, var(--utrecht-listbox-border-color)));\n border-radius: var(--utrecht-listbox-border-radius);\n border-style: solid;\n border-width: var(--utrecht-listbox-border-width);\n box-sizing: border-box;\n color: var(--_utrecht-listbox-disabled-color, var(--_utrecht-listbox-interactive-color, var(--utrecht-listbox-color)));\n cursor: default;\n display: flex;\n flex-direction: column;\n font-weight: var(--utrecht-listbox-font-weight, var(--utrecht-form-control-font-weight, initial));\n inline-size: var(--utrecht-listbox-inline-size, var(--utrecht-form-control-max-inline-size));\n max-block-size: var(--utrecht-listbox-max-block-size);\n max-inline-size: 100%;\n min-block-size: 1em;\n overflow-block: auto;\n overflow-y: auto;\n padding-block-end: var(--utrecht-listbox-padding-block-end);\n padding-block-start: var(--utrecht-listbox-padding-block-start);\n padding-inline-end: var(--utrecht-listbox-padding-inline-end);\n padding-inline-start: var(--utrecht-listbox-padding-inline-start);\n -webkit-user-select: none;\n user-select: none;\n}\n@media (forced-colors: active) {\n .utrecht-listbox {\n --utrecht-listbox-background-color: field;\n --utrecht-listbox-border-color: fieldtext;\n --utrecht-listbox-hover-background-color: field;\n --utrecht-listbox-hover-border-color: fieldtext;\n --utrecht-listbox-hover-color: fieldtext;\n --utrecht-listbox-focus-border-color: Highlight;\n --utrecht-listbox-disabled-border-color: GrayText;\n --utrecht-listbox-option-background-color: field;\n --utrecht-listbox-option-color: fieldtext;\n --utrecht-listbox-option-hover-background-color: Highlight;\n --utrecht-listbox-option-hover-color: HighlightText;\n --utrecht-listbox-option-active-background-color: Highlight;\n --utrecht-listbox-option-active-color: HighlightText;\n --utrecht-listbox-option-disabled-background-color: field;\n --utrecht-listbox-option-disabled-color: GrayText;\n --utrecht-listbox-option-selected-background-color: Highlight;\n --utrecht-listbox-option-selected-color: HighlightText;\n --utrecht-listbox-option-selected-hover-background-color: Highlight;\n --utrecht-listbox-option-selected-hover-color: HighlightText;\n --utrecht-listbox-option-selected-disabled-background-color: GrayText;\n --utrecht-listbox-option-selected-disabled-color: field;\n }\n}\n\n.utrecht-listbox--focus {\n --_utrecht-listbox-interactive-border-color: var(--utrecht-listbox-focus-border-color);\n}\n\n.utrecht-listbox--focus-visible {\n --_utrecht-focus-ring-box-shadow: 0 0 0 var(--utrecht-focus-outline-width, 0)\n var(--utrecht-focus-inverse-outline-color, transparent);\n box-shadow: var(--_utrecht-focus-ring-box-shadow);\n outline-color: var(--utrecht-focus-outline-color, revert);\n outline-offset: var(--utrecht-focus-outline-offset, revert);\n outline-style: var(--utrecht-focus-outline-style, revert);\n outline-width: var(--utrecht-focus-outline-width, revert);\n z-index: 1;\n}\n\n.utrecht-listbox--invalid {\n}\n\n.utrecht-listbox__list {\n margin-block-end: 0;\n margin-block-start: 0;\n margin-inline-end: 0;\n margin-inline-start: 0;\n padding-inline-start: 0;\n}\n\n.utrecht-listbox__group {\n margin-block-end: 0;\n margin-block-start: 0;\n margin-inline-end: 0;\n margin-inline-start: 0;\n padding-inline-start: 0;\n margin-block-end: var(--utrecht-listbox-option-group-margin-block-end);\n}\n\n.utrecht-listbox__group-label {\n color: var(--utrecht-listbox-option-group-label-color);\n font-size: var(--utrecht-listbox-option-group-label-font-size);\n font-weight: var(--utrecht-listbox-option-group-label-font-weight);\n line-height: var(--utrecht-listbox-option-group-label-line-height);\n margin-inline-start: var(--utrecht-listbox-option-group-label-margin-inline-start);\n}\n@media (forced-colors: active) {\n .utrecht-listbox__group-label {\n background-color: field;\n color: fieldtext;\n }\n}\n\n.utrecht-listbox__option {\n list-style: none;\n --_utrecht-listbox-option-background-color: var(\n --_utrecht-listbox-option-disabled-background-color,\n var(\n --_utrecht-listbox-option-interactive-background-color,\n var(--_utrecht-listbox-option-state-background-color, var(--utrecht-listbox-option-background-color))\n )\n );\n --_utrecht-listbox-option-color: var(\n --_utrecht-listbox-option-disabled-color,\n var(\n --_utrecht-listbox-option-interactive-color,\n var(--_utrecht-listbox-option-state-color, var(--utrecht-listbox-option-color))\n )\n );\n align-items: center;\n background-color: var(--_utrecht-listbox-option-background-color);\n box-sizing: border-box;\n color: var(--_utrecht-listbox-option-color);\n display: flex;\n min-block-size: var(--utrecht-listbox-option-min-block-size, var(--utrecht-pointer-target-min-size, 24px));\n padding-block-end: var(--utrecht-listbox-option-padding-block-end);\n padding-block-start: var(--utrecht-listbox-option-padding-block-start);\n padding-inline-end: var(--utrecht-listbox-option-padding-inline-end);\n padding-inline-start: var(--utrecht-listbox-option-padding-inline-start);\n}\n@media (forced-colors: active) {\n .utrecht-listbox__option {\n forced-color-adjust: none;\n }\n}\n\n.utrecht-listbox__option--hover {\n --_utrecht-listbox-option-interactive-background-color: var(--utrecht-listbox-option-hover-background-color);\n --_utrecht-listbox-option-interactive-color: var(--utrecht-listbox-option-hover-color);\n}\n\n.utrecht-listbox__option--focus {\n --_utrecht-listbox-option-state-background-color: var(--utrecht-listbox-option-focus-background-color);\n --_utrecht-listbox-option-state-color: var(--utrecht-listbox-option-focus-color);\n}\n\n.utrecht-listbox__option--focus-visible {\n --_utrecht-focus-ring-box-shadow: 0 0 0 var(--utrecht-focus-outline-width, 0)\n var(--utrecht-focus-inverse-outline-color, transparent);\n box-shadow: var(--_utrecht-focus-ring-box-shadow);\n outline-color: var(--utrecht-focus-outline-color, revert);\n outline-offset: var(--utrecht-focus-outline-offset, revert);\n outline-style: var(--utrecht-focus-outline-style, revert);\n outline-width: var(--utrecht-focus-outline-width, revert);\n z-index: 1;\n --utrecht-focus-outline-offset: calc(var(--utrecht-focus-outline-width) * -1);\n}\n\n.utrecht-listbox__option--active {\n --_utrecht-listbox-option-state-background-color: var(--utrecht-listbox-option-active-background-color);\n --_utrecht-listbox-option-state-color: var(--utrecht-listbox-option-active-color);\n font-weight: var(--utrecht-listbox-option-is-active-font-weight);\n}\n\n.utrecht-listbox__option--selected {\n --_utrecht-listbox-option-state-background-color: var(--utrecht-listbox-option-selected-background-color);\n --_utrecht-listbox-option-state-color: var(--utrecht-listbox-option-selected-color);\n}\n\n.utrecht-listbox__option--html-li {\n list-style: none;\n}\n.utrecht-listbox__option--html-li:hover {\n --_utrecht-listbox-option-interactive-background-color: var(--utrecht-listbox-option-hover-background-color);\n --_utrecht-listbox-option-interactive-color: var(--utrecht-listbox-option-hover-color);\n}\n.utrecht-listbox__option--html-li:focus {\n --_utrecht-listbox-option-state-background-color: var(--utrecht-listbox-option-focus-background-color);\n --_utrecht-listbox-option-state-color: var(--utrecht-listbox-option-focus-color);\n}\n.utrecht-listbox__option--disabled {\n --utrecht-listbox-option-hover-background-color: var(--utrecht-listbox-option-disabled-background-color);\n --utrecht-listbox-option-hover-color: var(--utrecht-listbox-option-disabled-color);\n --_utrecht-listbox-option-interactive-background-color: var(--utrecht-listbox-option-disabled-background-color);\n --_utrecht-listbox-option-interactive-color: var(--utrecht-listbox-option-disabled-color);\n cursor: var(--utrecht-action-disabled-cursor, not-allowed);\n}\n.utrecht-listbox__option--disabled.utrecht-listbox__option--selected {\n --_utrecht-listbox-option-disabled-background-color: var(--utrecht-listbox-option-selected-disabled-background-color);\n --_utrecht-listbox-option-disabled-color: var(--utrecht-listbox-option-selected-disabled-color);\n}\n\n.utrecht-listbox--disabled {\n --_utrecht-listbox-option-disabled-background-color: var(--utrecht-listbox-option-disabled-background-color);\n --_utrecht-listbox-option-disabled-color: var(--utrecht-listbox-option-disabled-color);\n --_utrecht-listbox-disabled-background-color: var(--utrecht-listbox-disabled-background-color);\n --_utrecht-listbox-disabled-border-color: var(--utrecht-listbox-disabled-border-color);\n --_utrecht-listbox-disabled-color: var(--utrecht-listbox-disabled-color);\n cursor: var(--utrecht-action-disabled-cursor, not-allowed);\n}\n\n.utrecht-listbox--html-div:focus {\n --_utrecht-listbox-interactive-border-color: var(--utrecht-listbox-focus-border-color);\n}\n.utrecht-listbox--html-div:focus-visible {\n --_utrecht-focus-ring-box-shadow: 0 0 0 var(--utrecht-focus-outline-width, 0)\n var(--utrecht-focus-inverse-outline-color, transparent);\n box-shadow: var(--_utrecht-focus-ring-box-shadow);\n outline-color: var(--utrecht-focus-outline-color, revert);\n outline-offset: var(--utrecht-focus-outline-offset, revert);\n outline-style: var(--utrecht-focus-outline-style, revert);\n outline-width: var(--utrecht-focus-outline-width, revert);\n z-index: 1;\n}\n\n.utrecht-listbox--forced-colors {\n --utrecht-listbox-background-color: field;\n --utrecht-listbox-border-color: fieldtext;\n --utrecht-listbox-hover-background-color: field;\n --utrecht-listbox-hover-border-color: fieldtext;\n --utrecht-listbox-hover-color: fieldtext;\n --utrecht-listbox-focus-border-color: Highlight;\n --utrecht-listbox-disabled-border-color: GrayText;\n --utrecht-listbox-option-background-color: field;\n --utrecht-listbox-option-color: fieldtext;\n --utrecht-listbox-option-hover-background-color: Highlight;\n --utrecht-listbox-option-hover-color: HighlightText;\n --utrecht-listbox-option-active-background-color: Highlight;\n --utrecht-listbox-option-active-color: HighlightText;\n --utrecht-listbox-option-disabled-background-color: field;\n --utrecht-listbox-option-disabled-color: GrayText;\n --utrecht-listbox-option-selected-background-color: Highlight;\n --utrecht-listbox-option-selected-color: HighlightText;\n --utrecht-listbox-option-selected-hover-background-color: Highlight;\n --utrecht-listbox-option-selected-hover-color: HighlightText;\n --utrecht-listbox-option-selected-disabled-background-color: GrayText;\n --utrecht-listbox-option-selected-disabled-color: field;\n}";
|
|
11
|
+
const textboxStyles = '/**\n * @license EUPL-1.2\n * Copyright (c) 2020-2024 Frameless B.V.\n * Copyright (c) 2021-2024 Gemeente Utrecht\n */\n.utrecht-textbox {\n --_utrecht-textbox-value-char: 0.667em + 0.334ch;\n --_utrecht-textbox-max-inline-size: calc(\n calc(var(--utrecht-textbox-value-max-length) * var(--_utrecht-textbox-value-char)) +\n var(--utrecht-textbox-padding-inline-end, var(--utrecht-form-control-padding-inline-end, 0)) +\n var(--utrecht-textbox-padding-inline-start, var(--utrecht-form-control-padding-inline-start, 0)) +\n var(--utrecht-textbox-border-width, var(--utrecht-form-control-border-width, 0)) +\n var(--utrecht-textbox-autocomplete-ui-size, 44px)\n );\n background-color: var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color));\n block-size: initial;\n border-width: var(--utrecht-textbox-border-width, var(--utrecht-form-control-border-width));\n border-block-end-width: var(--utrecht-textbox-border-bottom-width, var(--utrecht-textbox-border-width, var(--utrecht-form-control-border-width)));\n border-color: var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color));\n border-radius: var(--utrecht-textbox-border-radius, var(--utrecht-form-control-border-radius, 0));\n border-style: solid;\n box-sizing: border-box;\n color: var(--utrecht-textbox-color, var(--utrecht-form-control-color));\n display: block;\n font-family: var(--utrecht-textbox-font-family, var(--utrecht-form-control-font-family));\n font-size: var(--utrecht-textbox-font-size, var(--utrecht-form-control-font-size, inherit));\n font-weight: var(--utrecht-textbox-font-weight, var(--utrecht-form-control-font-weight, initial));\n inline-size: 100%;\n line-height: var(--utrecht-textbox-line-height, var(--utrecht-form-control-line-height, initial));\n min-block-size: var(--utrecht-pointer-target-min-size, 44px);\n min-inline-size: var(--utrecht-pointer-target-min-size, 44px);\n max-inline-size: min(var(--_utrecht-textbox-max-inline-size, 100%), var(--utrecht-textbox-max-inline-size, var(--utrecht-form-control-max-inline-size)));\n overflow: hidden;\n padding-block-end: var(--utrecht-textbox-padding-block-end, var(--utrecht-form-control-padding-block-end, 0));\n padding-block-start: var(--utrecht-textbox-padding-block-start, var(--utrecht-form-control-padding-block-start, 0));\n padding-inline-end: var(--utrecht-textbox-padding-inline-end, var(--utrecht-form-control-padding-inline-end, initial));\n padding-inline-start: var(--utrecht-textbox-padding-inline-start, var(--utrecht-form-control-padding-inline-start, initial));\n white-space: nowrap;\n}\n\n.utrecht-textbox--invalid {\n --_utrecht-textbox-border-width: var(\n --utrecht-textbox-invalid-border-width,\n var(\n --utrecht-form-control-invalid-border-width,\n var(--utrecht-textbox-border-width, var(--utrecht-form-control-border-width))\n )\n );\n background-color: var(--utrecht-textbox-invalid-background-color, var(--utrecht-form-control-invalid-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-width: var(--_utrecht-textbox-border-width);\n border-block-end-width: var(--utrecht-textbox-invalid-border-bottom-width, var(--utrecht-form-control-invalid-border-bottom-width, var(--utrecht-textbox-border-bottom-width, var(--utrecht-form-control-border-bottom-width, var(--_utrecht-textbox-border-width)))));\n border-color: var(--utrecht-textbox-invalid-border-color, var(--utrecht-form-control-invalid-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-invalid-color, var(--utrecht-form-control-invalid-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n}\n\n.utrecht-textbox--disabled {\n background-color: var(--utrecht-textbox-disabled-background-color, var(--utrecht-form-control-disabled-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-color: var(--utrecht-textbox-disabled-border-color, var(--utrecht-form-control-disabled-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-disabled-color, var(--utrecht-form-control-disabled-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n cursor: var(--utrecht-action-disabled-cursor, not-allowed);\n}\n\n.utrecht-textbox--focus {\n background-color: var(--utrecht-textbox-focus-background-color, var(--utrecht-form-control-focus-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-color: var(--utrecht-textbox-focus-border-color, var(--utrecht-form-control-focus-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-focus-color, var(--utrecht-form-control-focus-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n}\n\n.utrecht-textbox--focus-visible {\n --_utrecht-focus-ring-box-shadow: 0 0 0 var(--utrecht-focus-outline-width, 0)\n var(--utrecht-focus-inverse-outline-color, transparent);\n box-shadow: var(--_utrecht-focus-ring-box-shadow);\n outline-color: var(--utrecht-focus-outline-color, revert);\n outline-offset: var(--utrecht-focus-outline-offset, revert);\n outline-style: var(--utrecht-focus-outline-style, revert);\n outline-width: var(--utrecht-focus-outline-width, revert);\n z-index: 1;\n}\n\n.utrecht-textbox--read-only {\n background-color: var(--utrecht-textbox-read-only-background-color, var(--utrecht-form-control-read-only-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-color: var(--utrecht-textbox-read-only-border-color, var(--utrecht-form-control-read-only-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-read-only-color, var(--utrecht-form-control-read-only-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n}\n\n.utrecht-textbox__placeholder {\n color: var(--utrecht-textbox-placeholder-color, var(--utrecht-form-control-placeholder-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n font-style: var(--utrecht-form-control-placeholder-font-style);\n opacity: 100%;\n}\n\n.utrecht-textbox--numeric {\n -moz-appearance: textfield;\n font-variant-numeric: lining-nums tabular-nums;\n}\n\n.utrecht-textbox--password {\n font-variant-ligatures: none;\n font-variant-numeric: slashed-zero;\n}\n\n.utrecht-textbox--postal-code-nl-size {\n --utrecht-textbox-value-max-length: 7;\n}\n\n.utrecht-textbox--house-number-size {\n --utrecht-textbox-value-max-length: 5;\n}\n\n.utrecht-textbox--house-letter-size {\n --utrecht-textbox-value-max-length: 1;\n}\n\n.utrecht-textbox--house-addition-size {\n --utrecht-textbox-value-max-length: 4;\n}\n\n.utrecht-textbox--voorvoegsel-size {\n --utrecht-textbox-value-max-length: 10;\n}\n\n.utrecht-textbox--tel-size {\n --utrecht-textbox-value-max-length: 19;\n}\n\n.utrecht-textbox--tel-nl-size {\n --utrecht-textbox-value-max-length: 13;\n}\n\n.utrecht-textbox--iban-size {\n --utrecht-textbox-value-max-length: 41;\n}\n\n.utrecht-textbox--iban-nl-size {\n --utrecht-textbox-value-max-length: 22;\n}\n.utrecht-textbox--placeholder-ltr::placeholder, .utrecht-textbox--placeholder-ltr:placeholder-shown {\n direction: ltr;\n}\n.utrecht-textbox--placeholder-rtl::placeholder, .utrecht-textbox--placeholder-rtl:placeholder-shown {\n direction: rtl;\n}\n\n.utrecht-textbox--url {\n font-variant-ligatures: none;\n}\n\n.utrecht-textbox--html-input {\n}\n.utrecht-textbox--html-input:focus {\n background-color: var(--utrecht-textbox-focus-background-color, var(--utrecht-form-control-focus-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-color: var(--utrecht-textbox-focus-border-color, var(--utrecht-form-control-focus-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-focus-color, var(--utrecht-form-control-focus-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n}\n.utrecht-textbox--html-input:focus-visible {\n --_utrecht-focus-ring-box-shadow: 0 0 0 var(--utrecht-focus-outline-width, 0)\n var(--utrecht-focus-inverse-outline-color, transparent);\n box-shadow: var(--_utrecht-focus-ring-box-shadow);\n outline-color: var(--utrecht-focus-outline-color, revert);\n outline-offset: var(--utrecht-focus-outline-offset, revert);\n outline-style: var(--utrecht-focus-outline-style, revert);\n outline-width: var(--utrecht-focus-outline-width, revert);\n z-index: 1;\n}\n.utrecht-textbox--html-input:user-invalid, .utrecht-textbox--html-input[aria-invalid=true] {\n --_utrecht-textbox-border-width: var(\n --utrecht-textbox-invalid-border-width,\n var(\n --utrecht-form-control-invalid-border-width,\n var(--utrecht-textbox-border-width, var(--utrecht-form-control-border-width))\n )\n );\n background-color: var(--utrecht-textbox-invalid-background-color, var(--utrecht-form-control-invalid-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-width: var(--_utrecht-textbox-border-width);\n border-block-end-width: var(--utrecht-textbox-invalid-border-bottom-width, var(--utrecht-form-control-invalid-border-bottom-width, var(--utrecht-textbox-border-bottom-width, var(--utrecht-form-control-border-bottom-width, var(--_utrecht-textbox-border-width)))));\n border-color: var(--utrecht-textbox-invalid-border-color, var(--utrecht-form-control-invalid-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-invalid-color, var(--utrecht-form-control-invalid-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n}\n.utrecht-textbox--html-input:read-only {\n background-color: var(--utrecht-textbox-read-only-background-color, var(--utrecht-form-control-read-only-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-color: var(--utrecht-textbox-read-only-border-color, var(--utrecht-form-control-read-only-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-read-only-color, var(--utrecht-form-control-read-only-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n}\n.utrecht-textbox--html-input:disabled {\n background-color: var(--utrecht-textbox-disabled-background-color, var(--utrecht-form-control-disabled-background-color, var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))));\n border-color: var(--utrecht-textbox-disabled-border-color, var(--utrecht-form-control-disabled-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))));\n color: var(--utrecht-textbox-disabled-color, var(--utrecht-form-control-disabled-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n cursor: var(--utrecht-action-disabled-cursor, not-allowed);\n}\n.utrecht-textbox--html-input::placeholder {\n color: var(--utrecht-textbox-placeholder-color, var(--utrecht-form-control-placeholder-color, var(--utrecht-textbox-color, var(--utrecht-form-control-color))));\n font-style: var(--utrecht-form-control-placeholder-font-style);\n opacity: 100%;\n}\n.utrecht-textbox--html-input[type=password i] {\n font-variant-ligatures: none;\n font-variant-numeric: slashed-zero;\n}\n.utrecht-textbox--html-input[type=url i], .utrecht-textbox--html-input[type=email i], .utrecht-textbox--html-input[inputMode=email i], .utrecht-textbox--html-input[inputMode=url i] {\n font-variant-ligatures: none;\n}\n.utrecht-textbox--html-input[pattern="\\\\d*"], .utrecht-textbox--html-input[pattern="[0-9]*"], .utrecht-textbox--html-input[type=number i], .utrecht-textbox--html-input[type=tel i], .utrecht-textbox--html-input[inputMode=numeric i], .utrecht-textbox--html-input[inputMode=decimal i], .utrecht-textbox--html-input[inputMode=tel i] {\n -moz-appearance: textfield;\n font-variant-numeric: lining-nums tabular-nums;\n}';
|
|
12
|
+
function debounce(function_, wait = 100, options = {}) {
|
|
13
|
+
if (typeof function_ !== "function") {
|
|
14
|
+
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
|
|
15
|
+
}
|
|
16
|
+
if (wait < 0) {
|
|
17
|
+
throw new RangeError("`wait` must not be negative.");
|
|
18
|
+
}
|
|
19
|
+
if (typeof options === "boolean") {
|
|
20
|
+
throw new TypeError("The `options` parameter must be an object, not a boolean. Use `{immediate: true}` instead.");
|
|
21
|
+
}
|
|
22
|
+
const { immediate } = options;
|
|
23
|
+
let storedContext;
|
|
24
|
+
let storedArguments;
|
|
25
|
+
let timeoutId;
|
|
26
|
+
let timestamp;
|
|
27
|
+
let result;
|
|
28
|
+
function run() {
|
|
29
|
+
const callContext = storedContext;
|
|
30
|
+
const callArguments = storedArguments;
|
|
31
|
+
storedContext = void 0;
|
|
32
|
+
storedArguments = void 0;
|
|
33
|
+
result = function_.apply(callContext, callArguments);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
function later() {
|
|
37
|
+
const last = Date.now() - timestamp;
|
|
38
|
+
if (last < wait && last >= 0) {
|
|
39
|
+
timeoutId = setTimeout(later, wait - last);
|
|
40
|
+
} else {
|
|
41
|
+
timeoutId = void 0;
|
|
42
|
+
if (!immediate) {
|
|
43
|
+
result = run();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const debounced = function(...arguments_) {
|
|
48
|
+
if (storedContext && this !== storedContext && Object.getPrototypeOf(this) === Object.getPrototypeOf(storedContext)) {
|
|
49
|
+
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
50
|
+
}
|
|
51
|
+
storedContext = this;
|
|
52
|
+
storedArguments = arguments_;
|
|
53
|
+
timestamp = Date.now();
|
|
54
|
+
const callNow = immediate && !timeoutId;
|
|
55
|
+
if (!timeoutId) {
|
|
56
|
+
timeoutId = setTimeout(later, wait);
|
|
57
|
+
}
|
|
58
|
+
if (callNow) {
|
|
59
|
+
result = run();
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(debounced, "isPending", {
|
|
65
|
+
get() {
|
|
66
|
+
return timeoutId !== void 0;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
debounced.clear = () => {
|
|
70
|
+
if (!timeoutId) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
clearTimeout(timeoutId);
|
|
74
|
+
timeoutId = void 0;
|
|
75
|
+
storedContext = void 0;
|
|
76
|
+
storedArguments = void 0;
|
|
77
|
+
};
|
|
78
|
+
debounced.flush = () => {
|
|
79
|
+
if (!timeoutId) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
debounced.trigger();
|
|
83
|
+
};
|
|
84
|
+
debounced.trigger = () => {
|
|
85
|
+
result = run();
|
|
86
|
+
debounced.clear();
|
|
87
|
+
};
|
|
88
|
+
return debounced;
|
|
89
|
+
}
|
|
90
|
+
var has = Object.prototype.hasOwnProperty;
|
|
91
|
+
function find(iter, tar, key) {
|
|
92
|
+
for (key of iter.keys()) {
|
|
93
|
+
if (dequal(key, tar)) return key;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function dequal(foo, bar) {
|
|
97
|
+
var ctor, len, tmp;
|
|
98
|
+
if (foo === bar) return true;
|
|
99
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
100
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
101
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
102
|
+
if (ctor === Array) {
|
|
103
|
+
if ((len = foo.length) === bar.length) {
|
|
104
|
+
while (len-- && dequal(foo[len], bar[len])) ;
|
|
105
|
+
}
|
|
106
|
+
return len === -1;
|
|
107
|
+
}
|
|
108
|
+
if (ctor === Set) {
|
|
109
|
+
if (foo.size !== bar.size) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
for (len of foo) {
|
|
113
|
+
tmp = len;
|
|
114
|
+
if (tmp && typeof tmp === "object") {
|
|
115
|
+
tmp = find(bar, tmp);
|
|
116
|
+
if (!tmp) return false;
|
|
117
|
+
}
|
|
118
|
+
if (!bar.has(tmp)) return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (ctor === Map) {
|
|
123
|
+
if (foo.size !== bar.size) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
for (len of foo) {
|
|
127
|
+
tmp = len[0];
|
|
128
|
+
if (tmp && typeof tmp === "object") {
|
|
129
|
+
tmp = find(bar, tmp);
|
|
130
|
+
if (!tmp) return false;
|
|
131
|
+
}
|
|
132
|
+
if (!dequal(len[1], bar.get(tmp))) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (ctor === ArrayBuffer) {
|
|
139
|
+
foo = new Uint8Array(foo);
|
|
140
|
+
bar = new Uint8Array(bar);
|
|
141
|
+
} else if (ctor === DataView) {
|
|
142
|
+
if ((len = foo.byteLength) === bar.byteLength) {
|
|
143
|
+
while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
|
|
144
|
+
}
|
|
145
|
+
return len === -1;
|
|
146
|
+
}
|
|
147
|
+
if (ArrayBuffer.isView(foo)) {
|
|
148
|
+
if ((len = foo.byteLength) === bar.byteLength) {
|
|
149
|
+
while (len-- && foo[len] === bar[len]) ;
|
|
150
|
+
}
|
|
151
|
+
return len === -1;
|
|
152
|
+
}
|
|
153
|
+
if (!ctor || typeof foo === "object") {
|
|
154
|
+
len = 0;
|
|
155
|
+
for (ctor in foo) {
|
|
156
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
157
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
158
|
+
}
|
|
159
|
+
return Object.keys(bar).length === len;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return foo !== foo && bar !== bar;
|
|
163
|
+
}
|
|
164
|
+
const copyProperty = (to, from, property2, ignoreNonConfigurable) => {
|
|
165
|
+
if (property2 === "length" || property2 === "prototype") {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (property2 === "arguments" || property2 === "caller") {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const toDescriptor = Object.getOwnPropertyDescriptor(to, property2);
|
|
172
|
+
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property2);
|
|
173
|
+
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
Object.defineProperty(to, property2, fromDescriptor);
|
|
177
|
+
};
|
|
178
|
+
const canCopyProperty = function(toDescriptor, fromDescriptor) {
|
|
179
|
+
return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
|
180
|
+
};
|
|
181
|
+
const changePrototype = (to, from) => {
|
|
182
|
+
const fromPrototype = Object.getPrototypeOf(from);
|
|
183
|
+
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
Object.setPrototypeOf(to, fromPrototype);
|
|
187
|
+
};
|
|
188
|
+
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
|
|
189
|
+
${fromBody}`;
|
|
190
|
+
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
|
|
191
|
+
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
|
|
192
|
+
const changeToString = (to, from, name) => {
|
|
193
|
+
const withName = name === "" ? "" : `with ${name.trim()}() `;
|
|
194
|
+
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
195
|
+
Object.defineProperty(newToString, "name", toStringName);
|
|
196
|
+
const { writable, enumerable, configurable } = toStringDescriptor;
|
|
197
|
+
Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable });
|
|
198
|
+
};
|
|
199
|
+
function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
|
|
200
|
+
const { name } = to;
|
|
201
|
+
for (const property2 of Reflect.ownKeys(from)) {
|
|
202
|
+
copyProperty(to, from, property2, ignoreNonConfigurable);
|
|
203
|
+
}
|
|
204
|
+
changePrototype(to, from);
|
|
205
|
+
changeToString(to, from, name);
|
|
206
|
+
return to;
|
|
207
|
+
}
|
|
208
|
+
const maxTimeoutValue = 2147483647;
|
|
209
|
+
const cacheStore = /* @__PURE__ */ new WeakMap();
|
|
210
|
+
const cacheTimerStore = /* @__PURE__ */ new WeakMap();
|
|
211
|
+
const cacheKeyStore = /* @__PURE__ */ new WeakMap();
|
|
212
|
+
function getValidCacheItem(cache, key) {
|
|
213
|
+
const item = cache.get(key);
|
|
214
|
+
if (!item) {
|
|
215
|
+
return void 0;
|
|
216
|
+
}
|
|
217
|
+
if (item.maxAge <= Date.now()) {
|
|
218
|
+
cache.delete(key);
|
|
219
|
+
return void 0;
|
|
220
|
+
}
|
|
221
|
+
return item;
|
|
222
|
+
}
|
|
223
|
+
function memoize(function_, { cacheKey, cache = /* @__PURE__ */ new Map(), maxAge } = {}) {
|
|
224
|
+
if (maxAge === 0) {
|
|
225
|
+
return function_;
|
|
226
|
+
}
|
|
227
|
+
if (typeof maxAge === "number" && Number.isFinite(maxAge)) {
|
|
228
|
+
if (maxAge > maxTimeoutValue) {
|
|
229
|
+
throw new TypeError(`The \`maxAge\` option cannot exceed ${maxTimeoutValue}.`);
|
|
230
|
+
}
|
|
231
|
+
if (maxAge < 0) {
|
|
232
|
+
throw new TypeError("The `maxAge` option should not be a negative number.");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const memoized = function(...arguments_) {
|
|
236
|
+
const key = cacheKey ? cacheKey(arguments_) : arguments_[0];
|
|
237
|
+
const cacheItem = getValidCacheItem(cache, key);
|
|
238
|
+
if (cacheItem) {
|
|
239
|
+
return cacheItem.data;
|
|
240
|
+
}
|
|
241
|
+
const result = function_.apply(this, arguments_);
|
|
242
|
+
const computedMaxAge = typeof maxAge === "function" ? maxAge(...arguments_) : maxAge;
|
|
243
|
+
if (computedMaxAge !== void 0 && computedMaxAge !== Number.POSITIVE_INFINITY) {
|
|
244
|
+
if (!Number.isFinite(computedMaxAge)) {
|
|
245
|
+
throw new TypeError("The `maxAge` function must return a finite number, `0`, or `Infinity`.");
|
|
246
|
+
}
|
|
247
|
+
if (computedMaxAge <= 0) {
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
if (computedMaxAge > maxTimeoutValue) {
|
|
251
|
+
throw new TypeError(`The \`maxAge\` function result cannot exceed ${maxTimeoutValue}.`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
cache.set(key, {
|
|
255
|
+
data: result,
|
|
256
|
+
maxAge: computedMaxAge === void 0 || computedMaxAge === Number.POSITIVE_INFINITY ? Number.POSITIVE_INFINITY : Date.now() + computedMaxAge
|
|
257
|
+
});
|
|
258
|
+
if (computedMaxAge !== void 0 && computedMaxAge !== Number.POSITIVE_INFINITY) {
|
|
259
|
+
const timer = setTimeout(() => {
|
|
260
|
+
cache.delete(key);
|
|
261
|
+
cacheTimerStore.get(memoized)?.delete(timer);
|
|
262
|
+
}, computedMaxAge);
|
|
263
|
+
timer.unref?.();
|
|
264
|
+
const timers = cacheTimerStore.get(memoized) ?? /* @__PURE__ */ new Set();
|
|
265
|
+
timers.add(timer);
|
|
266
|
+
cacheTimerStore.set(memoized, timers);
|
|
267
|
+
}
|
|
268
|
+
return result;
|
|
269
|
+
};
|
|
270
|
+
mimicFunction(memoized, function_, {
|
|
271
|
+
ignoreNonConfigurable: true
|
|
272
|
+
});
|
|
273
|
+
cacheStore.set(memoized, cache);
|
|
274
|
+
cacheKeyStore.set(memoized, cacheKey ?? ((arguments_) => arguments_[0]));
|
|
275
|
+
return memoized;
|
|
276
|
+
}
|
|
277
|
+
const styles = css`
|
|
278
|
+
.clippy-combobox__input-container {
|
|
279
|
+
display: inline-block;
|
|
280
|
+
inline-size: 100%;
|
|
281
|
+
position: relative;
|
|
282
|
+
}
|
|
283
|
+
.clippy-combobox__current-option {
|
|
284
|
+
pointer-events: none;
|
|
285
|
+
position: absolute;
|
|
286
|
+
display: flex;
|
|
287
|
+
// Clip contents when current option exceeds input size
|
|
288
|
+
inline-size: 100%;
|
|
289
|
+
white-space: nowrap;
|
|
290
|
+
overflow: hidden;
|
|
291
|
+
align-items: center;
|
|
292
|
+
}
|
|
293
|
+
.clippy-combobox__current-option:has(+ input:focus) {
|
|
294
|
+
display: none;
|
|
295
|
+
}
|
|
296
|
+
/* added specificity to override the align-items now that the flex direction changes */
|
|
297
|
+
.clippy-combobox__option.utrecht-listbox__option {
|
|
298
|
+
display: flex;
|
|
299
|
+
flex-direction: column;
|
|
300
|
+
align-items: unset;
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
var __defProp = Object.defineProperty;
|
|
304
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
305
|
+
var __typeError = (msg) => {
|
|
306
|
+
throw TypeError(msg);
|
|
307
|
+
};
|
|
308
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
309
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
310
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
311
|
+
if (decorator = decorators[i])
|
|
312
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
313
|
+
if (kind && result) __defProp(target, key, result);
|
|
314
|
+
return result;
|
|
315
|
+
};
|
|
316
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
317
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
318
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
319
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
320
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
321
|
+
var _ClippyCombobox_instances, id_get, _options, _addAdditionalOptions, _handleBlur, _handleChange, _handleDocumentClick, _handleFocus, _handleInput, _handleOptionsClick, _handleKeydown, setActiveItem_fn, commitActiveItem_fn, commitQuery_fn, listId_get, getOptionId_fn;
|
|
322
|
+
const allowances = ["options", "other"];
|
|
323
|
+
const defaultAllowance = "options";
|
|
324
|
+
const positions = ["block-start", "block-end"];
|
|
325
|
+
const defaultPosition = "block-end";
|
|
326
|
+
const tag = "clippy-combobox";
|
|
327
|
+
let ClippyCombobox = class extends FormElement {
|
|
328
|
+
constructor() {
|
|
329
|
+
super(...arguments);
|
|
330
|
+
__privateAdd(this, _ClippyCombobox_instances);
|
|
331
|
+
this.allow = defaultAllowance;
|
|
332
|
+
this.open = false;
|
|
333
|
+
this.position = defaultPosition;
|
|
334
|
+
this.invalid = false;
|
|
335
|
+
__privateAdd(this, _options, /* @__PURE__ */ new Map());
|
|
336
|
+
this.activeIndex = -1;
|
|
337
|
+
this.query = "";
|
|
338
|
+
this.filter = (query) => {
|
|
339
|
+
const normalizedQuery = query.toLowerCase();
|
|
340
|
+
return ({ description, label }) => {
|
|
341
|
+
return Boolean(
|
|
342
|
+
label.toLowerCase().includes(normalizedQuery) || description?.toLowerCase().includes(normalizedQuery)
|
|
343
|
+
);
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
__privateAdd(this, _addAdditionalOptions, debounce(
|
|
347
|
+
memoize(
|
|
348
|
+
async (query) => {
|
|
349
|
+
const additions = await this.fetchAdditionalOptions(query);
|
|
350
|
+
for (const addition of additions) {
|
|
351
|
+
__privateGet(this, _options).set(addition.label, addition);
|
|
352
|
+
}
|
|
353
|
+
this.requestUpdate();
|
|
354
|
+
},
|
|
355
|
+
{ maxAge: 6e4 }
|
|
356
|
+
),
|
|
357
|
+
100
|
|
358
|
+
));
|
|
359
|
+
__privateAdd(this, _handleBlur, (event) => {
|
|
360
|
+
const focusedRelatedElement = event.relatedTarget && this.shadowRoot?.contains(event.relatedTarget);
|
|
361
|
+
if (!focusedRelatedElement) {
|
|
362
|
+
if (this.allow === "other" && this.query) {
|
|
363
|
+
const value = this.queryToValue(this.query);
|
|
364
|
+
if (value && dequal(value, this.value)) {
|
|
365
|
+
this.value = value;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
this.open = false;
|
|
369
|
+
this.emit("blur");
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
__privateAdd(this, _handleChange, () => {
|
|
373
|
+
this.emit("change");
|
|
374
|
+
});
|
|
375
|
+
__privateAdd(this, _handleDocumentClick, (event) => {
|
|
376
|
+
const path = event.composedPath();
|
|
377
|
+
if (!path.some((element) => element instanceof Node && this.contains(element))) {
|
|
378
|
+
this.open = false;
|
|
379
|
+
this.emit("blur");
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
__privateAdd(this, _handleFocus, () => {
|
|
383
|
+
this.open = true;
|
|
384
|
+
this.invalid = false;
|
|
385
|
+
this.emit("focus");
|
|
386
|
+
});
|
|
387
|
+
__privateAdd(this, _handleInput, (event) => {
|
|
388
|
+
const target = event.target;
|
|
389
|
+
if (!(target instanceof HTMLInputElement)) return;
|
|
390
|
+
this.activeIndex = -1;
|
|
391
|
+
this.open = true;
|
|
392
|
+
this.query = target.value;
|
|
393
|
+
if (this.query.length > 3) {
|
|
394
|
+
__privateGet(this, _addAdditionalOptions).call(this, this.query);
|
|
395
|
+
}
|
|
396
|
+
this.emit("input");
|
|
397
|
+
});
|
|
398
|
+
__privateAdd(this, _handleOptionsClick, (event) => {
|
|
399
|
+
const target = event.currentTarget;
|
|
400
|
+
if (!(target instanceof HTMLElement)) return;
|
|
401
|
+
const index = Number(target.dataset["index"]);
|
|
402
|
+
if (Number.isNaN(index)) return;
|
|
403
|
+
__privateMethod(this, _ClippyCombobox_instances, commitActiveItem_fn).call(this, index);
|
|
404
|
+
});
|
|
405
|
+
__privateAdd(this, _handleKeydown, ({ key }) => {
|
|
406
|
+
const index = this.activeIndex;
|
|
407
|
+
const count = this.filteredOptions.length;
|
|
408
|
+
switch (key) {
|
|
409
|
+
case "ArrowDown":
|
|
410
|
+
return __privateMethod(this, _ClippyCombobox_instances, setActiveItem_fn).call(this, index + 1, true);
|
|
411
|
+
case "ArrowUp":
|
|
412
|
+
return __privateMethod(this, _ClippyCombobox_instances, setActiveItem_fn).call(this, index - 1, true);
|
|
413
|
+
case "Enter":
|
|
414
|
+
if (index > -1) {
|
|
415
|
+
return __privateMethod(this, _ClippyCombobox_instances, commitActiveItem_fn).call(this, index);
|
|
416
|
+
} else if (count === 1 && this.allow === "options") {
|
|
417
|
+
return __privateMethod(this, _ClippyCombobox_instances, commitActiveItem_fn).call(this, 0);
|
|
418
|
+
} else if (this.allow === "other") {
|
|
419
|
+
return __privateMethod(this, _ClippyCombobox_instances, commitQuery_fn).call(this);
|
|
420
|
+
}
|
|
421
|
+
return void 0;
|
|
422
|
+
case "Escape":
|
|
423
|
+
return __privateMethod(this, _ClippyCombobox_instances, setActiveItem_fn).call(this, -1);
|
|
424
|
+
case "Home":
|
|
425
|
+
return __privateMethod(this, _ClippyCombobox_instances, setActiveItem_fn).call(this, 0);
|
|
426
|
+
case "End":
|
|
427
|
+
return __privateMethod(this, _ClippyCombobox_instances, setActiveItem_fn).call(this, count - 1);
|
|
428
|
+
default:
|
|
429
|
+
return void 0;
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
get filteredOptions() {
|
|
434
|
+
if (this.query.length === 0) {
|
|
435
|
+
return this.options;
|
|
436
|
+
}
|
|
437
|
+
const filter = this.filter(this.query);
|
|
438
|
+
return this.options.filter(filter);
|
|
439
|
+
}
|
|
440
|
+
set options(options) {
|
|
441
|
+
__privateSet(this, _options, new Map(
|
|
442
|
+
options.map(
|
|
443
|
+
(option) => typeof option === "string" ? [option, { label: option, value: option }] : [option.label, option]
|
|
444
|
+
)
|
|
445
|
+
));
|
|
446
|
+
}
|
|
447
|
+
get options() {
|
|
448
|
+
return [...__privateGet(this, _options).values()];
|
|
449
|
+
}
|
|
450
|
+
set value(value) {
|
|
451
|
+
super.value = value;
|
|
452
|
+
}
|
|
453
|
+
get value() {
|
|
454
|
+
return super.value;
|
|
455
|
+
}
|
|
456
|
+
emit(type) {
|
|
457
|
+
this.dispatchEvent(new Event(type, { bubbles: true, composed: true }));
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Override this function to customize an external data source
|
|
461
|
+
*/
|
|
462
|
+
fetchAdditionalOptions(_query) {
|
|
463
|
+
const empty = [];
|
|
464
|
+
return Promise.resolve(empty);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Override this function to customize how the value is looked up based on the selected option
|
|
468
|
+
*/
|
|
469
|
+
getOptionForValue(value) {
|
|
470
|
+
const option = this.options.find((option2) => dequal(option2.value, value));
|
|
471
|
+
if (this.allow === "other" && !option && typeof value === "string") {
|
|
472
|
+
return { label: value, value };
|
|
473
|
+
}
|
|
474
|
+
return option;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Override this function to customize how the user input is resolved to a value.
|
|
478
|
+
*/
|
|
479
|
+
queryToValue(query) {
|
|
480
|
+
if (this.allow === "other") {
|
|
481
|
+
return this.getOptionForValue(this.value)?.value || query;
|
|
482
|
+
}
|
|
483
|
+
const filter = this.filter(query);
|
|
484
|
+
return this.options.find(filter)?.value ?? null;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Override this function to customize how a value is converted to a query.
|
|
488
|
+
* This runs on setting the value.
|
|
489
|
+
*/
|
|
490
|
+
valueToQuery(value) {
|
|
491
|
+
const option = this.getOptionForValue(value);
|
|
492
|
+
return option?.label || (this.allow === "other" && typeof value === "string" ? value : "");
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Override this function to customize the rendering of combobox options and selected value.
|
|
496
|
+
* By default, it renders the label and description (if available) in the listbox options,
|
|
497
|
+
* and only the label in the input when an option is selected (by virtue of `index` being `undefined`).
|
|
498
|
+
*/
|
|
499
|
+
renderEntry({ description, label }, index) {
|
|
500
|
+
return html`
|
|
501
|
+
<div>${label}</div>
|
|
502
|
+
${description && index !== void 0 ? html`<div>${description}</div>` : nothing}
|
|
503
|
+
`;
|
|
504
|
+
}
|
|
505
|
+
willUpdate(changed) {
|
|
506
|
+
super.willUpdate(changed);
|
|
507
|
+
if (changed.has("options") || changed.has("value")) {
|
|
508
|
+
this.query = this.valueToQuery(this.value) ?? "";
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
connectedCallback() {
|
|
512
|
+
super.connectedCallback();
|
|
513
|
+
document.addEventListener("click", __privateGet(this, _handleDocumentClick));
|
|
514
|
+
}
|
|
515
|
+
disconnectedCallback() {
|
|
516
|
+
super.disconnectedCallback();
|
|
517
|
+
document.removeEventListener("click", __privateGet(this, _handleDocumentClick));
|
|
518
|
+
}
|
|
519
|
+
render() {
|
|
520
|
+
const labelClasses = {
|
|
521
|
+
"clippy-combobox__label": true,
|
|
522
|
+
"sr-only": !this.children.length
|
|
523
|
+
// If there are no slotted children, the label is only for screen readers, otherwise it's expected that the slotted content provides the label.
|
|
524
|
+
};
|
|
525
|
+
const popoverClasses = {
|
|
526
|
+
[`utrecht-combobox__popover--${this.position}`]: this.position,
|
|
527
|
+
"utrecht-combobox__popover--hidden": !this.open
|
|
528
|
+
};
|
|
529
|
+
const textboxClasses = {
|
|
530
|
+
"utrecht-combobox__input": true,
|
|
531
|
+
"utrecht-textbox": true,
|
|
532
|
+
"utrecht-textbox--invalid": this.invalid
|
|
533
|
+
};
|
|
534
|
+
const currentOption = this.getOptionForValue(this.value);
|
|
535
|
+
const populatedSlots = Array.from(this.children).reduce(
|
|
536
|
+
(acc, child) => ({
|
|
537
|
+
...acc,
|
|
538
|
+
[child.slot]: child
|
|
539
|
+
}),
|
|
540
|
+
{}
|
|
541
|
+
);
|
|
542
|
+
return html`
|
|
543
|
+
<div class="utrecht-combobox">
|
|
544
|
+
<label for="${__privateGet(this, _ClippyCombobox_instances, id_get)}" class=${classMap(labelClasses)}>
|
|
545
|
+
<slot name="label">${this.hiddenLabel || this.name}</slot>
|
|
546
|
+
</label>
|
|
547
|
+
${populatedSlots["description"] ? html` <div id="${__privateGet(this, _ClippyCombobox_instances, id_get)}-description" class="clippy-combobox__description">
|
|
548
|
+
<slot name="description"></slot>
|
|
549
|
+
</div>` : nothing}
|
|
550
|
+
${populatedSlots["error"] ? html` <div id="${__privateGet(this, _ClippyCombobox_instances, id_get)}-error" class="clippy-combobox__error">
|
|
551
|
+
<slot name="error"></slot>
|
|
552
|
+
</div>` : nothing}
|
|
553
|
+
<div class="clippy-combobox__input-container">
|
|
554
|
+
${currentOption ? html`<div
|
|
555
|
+
role="presentation"
|
|
556
|
+
class=${classMap({ "clippy-combobox__current-option": true, ...textboxClasses })}
|
|
557
|
+
>
|
|
558
|
+
${this.renderEntry(currentOption)}
|
|
559
|
+
</div>` : nothing}
|
|
560
|
+
<input
|
|
561
|
+
id=${__privateGet(this, _ClippyCombobox_instances, id_get)}
|
|
562
|
+
name=${this.name}
|
|
563
|
+
autocomplete="off"
|
|
564
|
+
role="combobox"
|
|
565
|
+
aria-autocomplete="list"
|
|
566
|
+
aria-haspopup="listbox"
|
|
567
|
+
aria-controls=${__privateGet(this, _ClippyCombobox_instances, listId_get)}
|
|
568
|
+
aria-expanded=${this.open}
|
|
569
|
+
aria-activedescendant=${ifDefined(__privateMethod(this, _ClippyCombobox_instances, getOptionId_fn).call(this))}
|
|
570
|
+
aria-invalid=${ifDefined(this.invalid ? "true" : void 0)}
|
|
571
|
+
aria-errormessage=${ifDefined(populatedSlots["error"] ? `${__privateGet(this, _ClippyCombobox_instances, id_get)}-error` : void 0)}
|
|
572
|
+
aria-describedby=${ifDefined(populatedSlots["description"] ? `${__privateGet(this, _ClippyCombobox_instances, id_get)}-description` : void 0)}
|
|
573
|
+
type="text"
|
|
574
|
+
class=${classMap(textboxClasses)}
|
|
575
|
+
dir="auto"
|
|
576
|
+
.value=${this.query}
|
|
577
|
+
@input=${__privateGet(this, _handleInput)}
|
|
578
|
+
@focus=${__privateGet(this, _handleFocus)}
|
|
579
|
+
@blur=${__privateGet(this, _handleBlur)}
|
|
580
|
+
@keydown=${__privateGet(this, _handleKeydown)}
|
|
581
|
+
/>
|
|
582
|
+
</div>
|
|
583
|
+
<div
|
|
584
|
+
id=${__privateGet(this, _ClippyCombobox_instances, listId_get)}
|
|
585
|
+
class="utrecht-listbox utrecht-combobox__popover ${classMap(popoverClasses)}"
|
|
586
|
+
role="listbox"
|
|
587
|
+
tabindex="-1"
|
|
588
|
+
>
|
|
589
|
+
<ul class="utrecht-listbox__list" role="none">
|
|
590
|
+
${this.filteredOptions.map((option, index) => {
|
|
591
|
+
const active = index === this.activeIndex;
|
|
592
|
+
const selected = dequal(option, currentOption);
|
|
593
|
+
const interactionClasses = {
|
|
594
|
+
"utrecht-listbox__option--active": active,
|
|
595
|
+
"utrecht-listbox__option--selected": selected
|
|
596
|
+
};
|
|
597
|
+
return html`<li
|
|
598
|
+
class="clippy-combobox__option utrecht-listbox__option utrecht-listbox__option--html-li ${classMap(
|
|
599
|
+
interactionClasses
|
|
600
|
+
)}"
|
|
601
|
+
role="option"
|
|
602
|
+
id=${ifDefined(__privateMethod(this, _ClippyCombobox_instances, getOptionId_fn).call(this, index))}
|
|
603
|
+
aria-selected=${selected}
|
|
604
|
+
data-index=${index}
|
|
605
|
+
@click=${__privateGet(this, _handleOptionsClick)}
|
|
606
|
+
>
|
|
607
|
+
${this.renderEntry(option, index)}
|
|
608
|
+
</li>`;
|
|
609
|
+
})}
|
|
610
|
+
</ul>
|
|
611
|
+
</div>
|
|
612
|
+
</div>
|
|
613
|
+
`;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
_ClippyCombobox_instances = /* @__PURE__ */ new WeakSet();
|
|
617
|
+
id_get = function() {
|
|
618
|
+
return `${tag}-${this.name}`;
|
|
619
|
+
};
|
|
620
|
+
_options = /* @__PURE__ */ new WeakMap();
|
|
621
|
+
_addAdditionalOptions = /* @__PURE__ */ new WeakMap();
|
|
622
|
+
_handleBlur = /* @__PURE__ */ new WeakMap();
|
|
623
|
+
_handleChange = /* @__PURE__ */ new WeakMap();
|
|
624
|
+
_handleDocumentClick = /* @__PURE__ */ new WeakMap();
|
|
625
|
+
_handleFocus = /* @__PURE__ */ new WeakMap();
|
|
626
|
+
_handleInput = /* @__PURE__ */ new WeakMap();
|
|
627
|
+
_handleOptionsClick = /* @__PURE__ */ new WeakMap();
|
|
628
|
+
_handleKeydown = /* @__PURE__ */ new WeakMap();
|
|
629
|
+
setActiveItem_fn = function(index, open = false) {
|
|
630
|
+
this.open = open;
|
|
631
|
+
this.activeIndex = index > -1 ? index % this.filteredOptions.length : -1;
|
|
632
|
+
if (this.activeIndex > -1) {
|
|
633
|
+
const element = this.shadowRoot?.querySelector(`#${String(__privateMethod(this, _ClippyCombobox_instances, getOptionId_fn).call(this))}`);
|
|
634
|
+
element?.scrollIntoView({
|
|
635
|
+
behavior: "smooth",
|
|
636
|
+
block: "nearest",
|
|
637
|
+
inline: "nearest"
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
commitActiveItem_fn = function(index) {
|
|
642
|
+
const { label, value } = this.filteredOptions.at(index) ?? {};
|
|
643
|
+
if (index < 0 || !label || !value) return;
|
|
644
|
+
if (!dequal(this.value, value)) {
|
|
645
|
+
this.value = value;
|
|
646
|
+
__privateGet(this, _handleChange).call(this);
|
|
647
|
+
}
|
|
648
|
+
this.open = false;
|
|
649
|
+
};
|
|
650
|
+
commitQuery_fn = function() {
|
|
651
|
+
const value = this.queryToValue(this.query);
|
|
652
|
+
if (!dequal(this.value, value)) {
|
|
653
|
+
this.value = value;
|
|
654
|
+
__privateGet(this, _handleChange).call(this);
|
|
655
|
+
}
|
|
656
|
+
this.open = false;
|
|
657
|
+
};
|
|
658
|
+
listId_get = function() {
|
|
659
|
+
return `list-${__privateGet(this, _ClippyCombobox_instances, id_get)}`;
|
|
660
|
+
};
|
|
661
|
+
getOptionId_fn = function(index = this.activeIndex) {
|
|
662
|
+
return index === -1 ? void 0 : `option-${index}-${__privateGet(this, _ClippyCombobox_instances, id_get)}`;
|
|
663
|
+
};
|
|
664
|
+
ClippyCombobox.allowances = allowances;
|
|
665
|
+
ClippyCombobox.positions = positions;
|
|
666
|
+
ClippyCombobox.styles = [
|
|
667
|
+
styles,
|
|
668
|
+
srOnly,
|
|
669
|
+
unsafeCSS(comboboxStyles),
|
|
670
|
+
unsafeCSS(listboxStyles),
|
|
671
|
+
unsafeCSS(textboxStyles)
|
|
672
|
+
];
|
|
673
|
+
__decorateClass([
|
|
674
|
+
property({ converter: allowedValuesConverter(ClippyCombobox.allowances, defaultAllowance) })
|
|
675
|
+
], ClippyCombobox.prototype, "allow", 2);
|
|
676
|
+
__decorateClass([
|
|
677
|
+
property({ reflect: true, type: Boolean })
|
|
678
|
+
], ClippyCombobox.prototype, "open", 2);
|
|
679
|
+
__decorateClass([
|
|
680
|
+
property({ converter: allowedValuesConverter(ClippyCombobox.positions, defaultPosition) })
|
|
681
|
+
], ClippyCombobox.prototype, "position", 2);
|
|
682
|
+
__decorateClass([
|
|
683
|
+
property({ reflect: true, type: Boolean })
|
|
684
|
+
], ClippyCombobox.prototype, "invalid", 2);
|
|
685
|
+
__decorateClass([
|
|
686
|
+
state()
|
|
687
|
+
], ClippyCombobox.prototype, "activeIndex", 2);
|
|
688
|
+
__decorateClass([
|
|
689
|
+
state()
|
|
690
|
+
], ClippyCombobox.prototype, "query", 2);
|
|
691
|
+
__decorateClass([
|
|
692
|
+
state()
|
|
693
|
+
], ClippyCombobox.prototype, "filteredOptions", 1);
|
|
694
|
+
__decorateClass([
|
|
695
|
+
property({ converter: arrayFromTokenList })
|
|
696
|
+
], ClippyCombobox.prototype, "options", 1);
|
|
697
|
+
__decorateClass([
|
|
698
|
+
property()
|
|
699
|
+
], ClippyCombobox.prototype, "value", 1);
|
|
700
|
+
ClippyCombobox = __decorateClass([
|
|
701
|
+
safeCustomElement(tag)
|
|
702
|
+
], ClippyCombobox);
|
|
8
703
|
export {
|
|
9
|
-
|
|
704
|
+
ClippyCombobox
|
|
10
705
|
};
|