@vielzeug/refine 2.1.3 → 2.2.4
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/accordion.cjs +1 -1
- package/dist/accordion.cjs.map +1 -1
- package/dist/accordion.js +2 -2
- package/dist/accordion.js.map +1 -1
- package/dist/carousel.cjs +25 -24
- package/dist/carousel.cjs.map +1 -1
- package/dist/carousel.js +125 -135
- package/dist/carousel.js.map +1 -1
- package/dist/combobox.cjs +14 -14
- package/dist/combobox.cjs.map +1 -1
- package/dist/combobox.js +88 -98
- package/dist/combobox.js.map +1 -1
- package/dist/content/carousel/carousel.d.ts.map +1 -1
- package/dist/content/list/_list-item-reveal.cjs +1 -1
- package/dist/content/list/_list-item-reveal.cjs.map +1 -1
- package/dist/content/list/_list-item-reveal.d.ts +3 -3
- package/dist/content/list/_list-item-reveal.d.ts.map +1 -1
- package/dist/content/list/_list-item-reveal.js +22 -22
- package/dist/content/list/_list-item-reveal.js.map +1 -1
- package/dist/content/list/list-item.d.ts.map +1 -1
- package/dist/core/focus.cjs +1 -1
- package/dist/core/focus.cjs.map +1 -1
- package/dist/core/focus.d.ts.map +1 -1
- package/dist/core/focus.js +21 -20
- package/dist/core/focus.js.map +1 -1
- package/dist/core/index.d.ts +2 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/nav.cjs +1 -1
- package/dist/core/nav.cjs.map +1 -1
- package/dist/core/nav.d.ts +3 -62
- package/dist/core/nav.d.ts.map +1 -1
- package/dist/core/nav.js +41 -124
- package/dist/core/nav.js.map +1 -1
- package/dist/core/option-list.cjs +1 -1
- package/dist/core/option-list.cjs.map +1 -1
- package/dist/core/option-list.d.ts +5 -5
- package/dist/core/option-list.d.ts.map +1 -1
- package/dist/core/option-list.js +14 -13
- package/dist/core/option-list.js.map +1 -1
- package/dist/core/overlay.cjs +1 -1
- package/dist/core/overlay.cjs.map +1 -1
- package/dist/core/overlay.d.ts +0 -8
- package/dist/core/overlay.d.ts.map +1 -1
- package/dist/core/overlay.js +1 -3
- package/dist/core/overlay.js.map +1 -1
- package/dist/custom-elements.json +5636 -5683
- package/dist/drawer.cjs +6 -6
- package/dist/drawer.cjs.map +1 -1
- package/dist/drawer.js +65 -75
- package/dist/drawer.js.map +1 -1
- package/dist/feedback/skeleton/skeleton.css.cjs +1 -1
- package/dist/feedback/skeleton/skeleton.css.cjs.map +1 -1
- package/dist/feedback/skeleton/skeleton.css.js +1 -1
- package/dist/feedback/skeleton/skeleton.css.js.map +1 -1
- package/dist/feedback/skeleton/skeleton.d.ts.map +1 -1
- package/dist/feedback/toast/toast.d.ts.map +1 -1
- package/dist/grid.cjs +2 -2
- package/dist/grid.cjs.map +1 -1
- package/dist/grid.js +42 -41
- package/dist/grid.js.map +1 -1
- package/dist/input.cjs.map +1 -1
- package/dist/input.js.map +1 -1
- package/dist/inputs/input/input.css.cjs +1 -1
- package/dist/inputs/input/input.css.cjs.map +1 -1
- package/dist/inputs/input/input.css.js +1 -1
- package/dist/inputs/input/input.css.js.map +1 -1
- package/dist/inputs/input/input.d.ts +2 -0
- package/dist/inputs/input/input.d.ts.map +1 -1
- package/dist/inputs/select/select.d.ts +2 -2
- package/dist/inputs/select/select.d.ts.map +1 -1
- package/dist/layout/grid/grid.d.ts.map +1 -1
- package/dist/layout/navbar/navbar.d.ts.map +1 -1
- package/dist/layout/sidebar/sidebar.d.ts.map +1 -1
- package/dist/list-item.cjs +2 -6
- package/dist/list-item.cjs.map +1 -1
- package/dist/list-item.js +40 -39
- package/dist/list-item.js.map +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.cjs.map +1 -1
- package/dist/list.js +2 -2
- package/dist/list.js.map +1 -1
- package/dist/marquee.cjs +1 -1
- package/dist/marquee.cjs.map +1 -1
- package/dist/marquee.js +3 -1
- package/dist/marquee.js.map +1 -1
- package/dist/menu.cjs +5 -5
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.js +59 -59
- package/dist/menu.js.map +1 -1
- package/dist/navbar.cjs +9 -9
- package/dist/navbar.cjs.map +1 -1
- package/dist/navbar.js +124 -116
- package/dist/navbar.js.map +1 -1
- package/dist/otp-input.cjs +1 -1
- package/dist/otp-input.cjs.map +1 -1
- package/dist/otp-input.js +2 -2
- package/dist/otp-input.js.map +1 -1
- package/dist/overlay/drawer/drawer.d.ts.map +1 -1
- package/dist/overlay/menu/menu.d.ts.map +1 -1
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.cjs.map +1 -1
- package/dist/radio-group.js +2 -3
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.cjs +1 -1
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.js +12 -11
- package/dist/radio.js.map +1 -1
- package/dist/rating.cjs +1 -1
- package/dist/rating.cjs.map +1 -1
- package/dist/rating.js +1 -1
- package/dist/rating.js.map +1 -1
- package/dist/refine.cjs +188 -195
- package/dist/refine.cjs.map +1 -1
- package/dist/refine.iife.js +212 -219
- package/dist/refine.iife.js.map +1 -1
- package/dist/refine.js +392 -399
- package/dist/refine.js.map +1 -1
- package/dist/select.cjs +1 -1
- package/dist/select.cjs.map +1 -1
- package/dist/select.js +1 -0
- package/dist/select.js.map +1 -1
- package/dist/sidebar.cjs +16 -16
- package/dist/sidebar.cjs.map +1 -1
- package/dist/sidebar.js +106 -91
- package/dist/sidebar.js.map +1 -1
- package/dist/skeleton.cjs +3 -3
- package/dist/skeleton.cjs.map +1 -1
- package/dist/skeleton.js +8 -7
- package/dist/skeleton.js.map +1 -1
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.cjs.map +1 -1
- package/dist/stepper.js +3 -3
- package/dist/stepper.js.map +1 -1
- package/dist/styles/fouc.css +22 -0
- package/dist/styles/preflight.css +2 -10
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.cjs.map +1 -1
- package/dist/tabs.js +4 -5
- package/dist/tabs.js.map +1 -1
- package/dist/toast.cjs +13 -17
- package/dist/toast.cjs.map +1 -1
- package/dist/toast.js +86 -85
- package/dist/toast.js.map +1 -1
- package/package.json +18 -11
- package/dist/core/swipe.cjs +0 -2
- package/dist/core/swipe.cjs.map +0 -1
- package/dist/core/swipe.d.ts +0 -40
- package/dist/core/swipe.d.ts.map +0 -1
- package/dist/core/swipe.js +0 -63
- package/dist/core/swipe.js.map +0 -1
- package/dist/core/typeahead.cjs +0 -2
- package/dist/core/typeahead.cjs.map +0 -1
- package/dist/core/typeahead.d.ts +0 -53
- package/dist/core/typeahead.d.ts.map +0 -1
- package/dist/core/typeahead.js +0 -23
- package/dist/core/typeahead.js.map +0 -1
package/dist/list.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.cjs","names":[],"sources":["../src/content/list/list.ts"],"sourcesContent":["import { bind, createContext, define, getHost, html, onCleanup, prop, provide, useEmit } from '@vielzeug/ore';\nimport { computed, type Readable, signal, watch } from '@vielzeug/ripple';\nimport { createListControl, lifecycleSignal } from '../../core';\nimport { disablableBundle, LIST_SIZE_PRESET, sizableBundle } from '../../shared';\nimport { sizeVariantMixin } from '../../styles';\nimport type { ComponentSize } from '../../types';\nimport componentStyles from './list.css?inline';\n\n/** Visual variant for `ore-list`. */\nexport type ListVariant = 'bordered' | 'plain' | 'separated';\n\n/** Context provided by `ore-list` to its `ore-list-item` children. */\nexport type ListContext = {\n /**\n * Closes every other item's swipe-revealed action panel. Called directly by an item the moment\n * its own `revealed` attribute transitions to non-null (gesture or direct attribute set) —\n * replaces listening for a bubbled `reveal` event and re-deriving \"is this actually my direct\n * child\" with a plain function call, the same shape as `select` below.\n */\n requestReveal: (item: HTMLElement) => void;\n /**\n * Selects `value` (or clears the selection when `undefined`) and fires `change`. Called\n * directly by an activated item — mirrors `ore-radio-group`'s `RadioGroupContext.select()`.\n * No sibling bookkeeping needed here: every item's `selected` is *derived* from `value`, so\n * changing it here is the only thing that has to happen.\n */\n select: (value: string | undefined) => void;\n selectable: Readable<boolean>;\n /**\n * Single source of truth for the current selection — `ore-list-item` never owns its own\n * \"selected\" state; it's always derived by comparing its own `value` against this one (the\n * same shape as `ore-radio-group`'s `RadioGroupContext.value`).\n */\n value: Readable<string | undefined>;\n};\n/** Injection key for the list context. */\nexport const LIST_CTX = createContext<ListContext>('ListContext');\n\n/** Events emitted by the list component */\nexport type OreListEvents = {\n /** Emitted when the selected value changes (only when `selectable` is set). */\n change: { value: null | string };\n};\n\n/** List component properties */\nexport type OreListProps = {\n /** Disable the entire list — blocks pointer interaction and removes items from tab order */\n disabled?: boolean;\n /**\n * Enables single-selection listbox behavior: clicking (or pressing Enter/Space on) an item\n * selects it and deselects any previously-selected sibling. Arrow keys / Home / End move\n * focus between items. Omit for a plain, non-interactive display list.\n */\n selectable?: boolean;\n /** Size applied to all items (propagated via inherited CSS custom properties) */\n size?: ComponentSize;\n /**\n * Selected item's `value` (only meaningful when `selectable`) — the single source of truth for\n * selection. `ore-list-item` never owns its own selected state; set this directly, bind it for\n * two-way control, or read it back from `change`.\n */\n value?: string;\n /** Visual variant: 'plain' (default, no dividers) | 'bordered' (outer border + row dividers) | 'separated' (each item is its own card) */\n variant?: ListVariant;\n};\n\n/**\n * A vertical list container for `ore-list-item` children — plain display list by default, or a\n * keyboard-navigable single-select listbox via `selectable`. Each item can independently reveal\n * a left/right action panel via touch/pointer swipe (see `ore-list-item`'s `actions-left`/\n * `actions-right` slots) — useful for mobile-style row actions (archive, delete, …).\n *\n * @element ore-list\n * @element ore-list-item - Child element for each row\n *\n * @attr {boolean} disabled - Disable the entire list\n * @attr {boolean} selectable - Enable single-selection listbox behavior with arrow-key navigation\n * @attr {string} size - Size applied to all items: 'sm' | 'md' | 'lg'\n * @attr {string} value - Selected item's value (only meaningful when `selectable`) — the single source of truth for selection\n * @attr {string} variant - Visual variant: 'plain' | 'bordered' | 'separated'\n *\n * @fires change - Emitted when the selected value changes. detail: { value: string | null }\n *\n * @slot - `ore-list-item` elements\n *\n * @cssprop --list-radius - Border radius for the 'bordered'/'separated' variants\n *\n * @example\n * ```html\n * <ore-list variant=\"bordered\">\n * <ore-list-item>Inbox</ore-list-item>\n * <ore-list-item>Drafts</ore-list-item>\n * </ore-list>\n * <ore-list selectable value=\"inbox\">\n * <ore-list-item value=\"inbox\">Inbox</ore-list-item>\n * <ore-list-item value=\"drafts\">Drafts</ore-list-item>\n * </ore-list>\n * ```\n */\nexport const LIST_TAG = 'ore-list' as const;\ndefine<OreListProps>(LIST_TAG, {\n props: {\n ...disablableBundle,\n ...sizableBundle,\n selectable: prop.bool(false),\n value: prop.string(),\n variant: prop.string<ListVariant>(),\n },\n\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreListEvents>();\n\n const getItems = (): HTMLElement[] => [\n ...el.querySelectorAll<HTMLElement>(':scope > ore-list-item:not([disabled])'),\n ];\n\n const getAllItems = (): HTMLElement[] => [...el.querySelectorAll<HTMLElement>(':scope > ore-list-item')];\n\n // Reaches into each item's shadow root for its focusable row — mirrors `ore-accordion`'s\n // `getSummaryElements()` — rather than relying on `item.focus()` + `shadow: { delegatesFocus:\n // true }` to land focus correctly, since that cross-boundary reporting is inconsistent enough\n // between real browsers and jsdom that other multi-item components in this package\n // (`ore-menu`, `ore-tabs`) defensively check both forms too. Queried via `[part=\"row\"]`, not\n // the `.row` class — `part` is list-item's declared public seam for exactly this kind of\n // cross-component reach; the class name is a private styling detail that could change.\n const getRow = (item: Element): HTMLElement | null =>\n item.shadowRoot?.querySelector<HTMLElement>('[part=\"row\"]') ?? null;\n\n const getRows = (): HTMLElement[] =>\n getItems()\n .map(getRow)\n .filter((row): row is HTMLElement => row != null);\n\n const listControl = createListControl<HTMLElement>({\n getItems,\n loop: true,\n onNavigate: (_action, index) => {\n getRow(getItems()[index])?.focus();\n },\n signal: lifecycleSignal(onCleanup),\n });\n\n // Selection — `selectedValue` is the single source of truth (mirrors `ore-radio-group`'s\n // `selectedValue`/`RadioGroupContext.value` pattern): reflected onto the `value` attribute,\n // synced back in when set externally, and read by every item via context to derive its own\n // `selected` state. No sibling-clearing needed anywhere — changing this one signal is enough.\n const selectedValue = signal<string | undefined>(props.value.value);\n\n watch(props.value, (value) => {\n selectedValue.value = value;\n });\n\n const select = (value: string | undefined): void => {\n if (selectedValue.value === value) return;\n\n selectedValue.value = value;\n emit('change', { value: value ?? null });\n };\n\n // Only one item's swipe-revealed action panel is open at a time. The item calls this\n // directly the moment its own `revealed` attribute transitions to non-null — see\n // `ListContext.requestReveal`'s doc comment for why this replaced a bubbled event.\n const requestReveal = (item: HTMLElement): void => {\n for (const sibling of getAllItems()) {\n if (sibling !== item) sibling.removeAttribute('revealed');\n }\n };\n\n // Closes any swipe-revealed item when the user interacts anywhere outside of it — matches\n // the outside-pointerdown-closes pattern used by ore-date-picker/ore-time-picker's popovers.\n const handleOutsidePointerDown = (event: PointerEvent): void => {\n const open = getAllItems().find((item) => item.hasAttribute('revealed'));\n\n if (!open || event.composedPath().includes(open)) return;\n\n open.removeAttribute('revealed');\n };\n\n document.addEventListener('pointerdown', handleOutsidePointerDown, { capture: true });\n onCleanup(() => document.removeEventListener('pointerdown', handleOutsidePointerDown, { capture: true }));\n\n provide(LIST_CTX, {\n requestReveal,\n select,\n selectable: computed(() => Boolean(props.selectable.value)),\n value: selectedValue,\n });\n\n bind({\n attr: {\n 'aria-disabled': () => (props.disabled.value ? 'true' : null),\n role: () => (props.selectable.value ? 'listbox' : 'list'),\n value: () => selectedValue.value ?? null,\n },\n on: {\n keydown: (event: KeyboardEvent) => {\n if (!props.selectable.value || props.disabled.value) return;\n\n const row = event\n .composedPath()\n .find((node): node is HTMLElement => node instanceof HTMLElement && node.getAttribute('part') === 'row');\n\n if (!row) return;\n\n const focused = getRows().indexOf(row);\n\n if (focused === -1) return;\n\n listControl.set(focused);\n listControl.handleKeydown(event);\n },\n },\n });\n\n return html`\n <slot></slot>\n `;\n },\n\n styles: [sizeVariantMixin(LIST_SIZE_PRESET), componentStyles],\n});\n"],"mappings":"gWAoCA,IAAa,GAAA,EAAW,EAAA,cAAA,CAA2B,aAAa,EA+DnD,EAAW,YAC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,CACjC,EAsCA,OApCA,SAAS,iBAAiB,cAAe,EAA0B,CAAE,QAAS,EAAK,CAAC,GACpF,EAAA,EAAA,UAAA,KAAgB,SAAS,oBAAoB,cAAe,EAA0B,CAAE,QAAS,EAAK,CAAC,CAAC,GAExG,EAAA,EAAA,QAAA,CAAQ,EAAU,CAChB,gBACA,SACA,YAAA,EAAY,EAAA,SAAA,KAAe,EAAQ,EAAM,WAAW,KAAM,EAC1D,MAAO,CACT,CAAC,GAED,EAAA,EAAA,KAAA,CAAK,CACH,KAAM,CACJ,oBAAwB,EAAM,SAAS,MAAQ,OAAS,KACxD,SAAa,EAAM,WAAW,MAAQ,UAAY,OAClD,UAAa,EAAc,OAAS,IACtC,EACA,GAAI,CACF,QAAU,GAAyB,CACjC,GAAI,CAAC,EAAM,WAAW,OAAS,EAAM,SAAS,MAAO,OAErD,IAAM,EAAM,EACT,aAAa,CAAC,CACd,KAAM,GAA8B,aAAgB,aAAe,EAAK,aAAa,MAAM,IAAM,KAAK,EAEzG,GAAI,CAAC,EAAK,OAEV,IAAM,EAAU,EAAQ,CAAC,CAAC,QAAQ,CAAG,EAEjC,IAAY,KAEhB,EAAY,IAAI,CAAO,EACvB,EAAY,cAAc,CAAK,EACjC,CACF,CACF,CAAC,EAEM,EAAA,IAAI;;KAGb,EAEA,OAAQ,CAAC,EAAA,iBAAiB,EAAA,gBAAgB,EAAG,EAAA,OAAe,CAC9D,CAAC"}
|
|
1
|
+
{"version":3,"file":"list.cjs","names":[],"sources":["../src/content/list/list.ts"],"sourcesContent":["import { bind, createContext, define, getHost, html, onCleanup, prop, provide, useEmit } from '@vielzeug/ore';\nimport { computed, type Readable, signal, watch } from '@vielzeug/ripple';\nimport { createListControl, lifecycleSignal } from '../../core';\nimport { disablableBundle, LIST_SIZE_PRESET, sizableBundle } from '../../shared';\nimport { sizeVariantMixin } from '../../styles';\nimport type { ComponentSize } from '../../types';\nimport componentStyles from './list.css?inline';\n\n/** Visual variant for `ore-list`. */\nexport type ListVariant = 'bordered' | 'plain' | 'separated';\n\n/** Context provided by `ore-list` to its `ore-list-item` children. */\nexport type ListContext = {\n /**\n * Closes every other item's swipe-revealed action panel. Called directly by an item the moment\n * its own `revealed` attribute transitions to non-null (gesture or direct attribute set) —\n * replaces listening for a bubbled `reveal` event and re-deriving \"is this actually my direct\n * child\" with a plain function call, the same shape as `select` below.\n */\n requestReveal: (item: HTMLElement) => void;\n /**\n * Selects `value` (or clears the selection when `undefined`) and fires `change`. Called\n * directly by an activated item — mirrors `ore-radio-group`'s `RadioGroupContext.select()`.\n * No sibling bookkeeping needed here: every item's `selected` is *derived* from `value`, so\n * changing it here is the only thing that has to happen.\n */\n select: (value: string | undefined) => void;\n selectable: Readable<boolean>;\n /**\n * Single source of truth for the current selection — `ore-list-item` never owns its own\n * \"selected\" state; it's always derived by comparing its own `value` against this one (the\n * same shape as `ore-radio-group`'s `RadioGroupContext.value`).\n */\n value: Readable<string | undefined>;\n};\n/** Injection key for the list context. */\nexport const LIST_CTX = createContext<ListContext>('ListContext');\n\n/** Events emitted by the list component */\nexport type OreListEvents = {\n /** Emitted when the selected value changes (only when `selectable` is set). */\n change: { value: null | string };\n};\n\n/** List component properties */\nexport type OreListProps = {\n /** Disable the entire list — blocks pointer interaction and removes items from tab order */\n disabled?: boolean;\n /**\n * Enables single-selection listbox behavior: clicking (or pressing Enter/Space on) an item\n * selects it and deselects any previously-selected sibling. Arrow keys / Home / End move\n * focus between items. Omit for a plain, non-interactive display list.\n */\n selectable?: boolean;\n /** Size applied to all items (propagated via inherited CSS custom properties) */\n size?: ComponentSize;\n /**\n * Selected item's `value` (only meaningful when `selectable`) — the single source of truth for\n * selection. `ore-list-item` never owns its own selected state; set this directly, bind it for\n * two-way control, or read it back from `change`.\n */\n value?: string;\n /** Visual variant: 'plain' (default, no dividers) | 'bordered' (outer border + row dividers) | 'separated' (each item is its own card) */\n variant?: ListVariant;\n};\n\n/**\n * A vertical list container for `ore-list-item` children — plain display list by default, or a\n * keyboard-navigable single-select listbox via `selectable`. Each item can independently reveal\n * a left/right action panel via touch/pointer swipe (see `ore-list-item`'s `actions-left`/\n * `actions-right` slots) — useful for mobile-style row actions (archive, delete, …).\n *\n * @element ore-list\n * @element ore-list-item - Child element for each row\n *\n * @attr {boolean} disabled - Disable the entire list\n * @attr {boolean} selectable - Enable single-selection listbox behavior with arrow-key navigation\n * @attr {string} size - Size applied to all items: 'sm' | 'md' | 'lg'\n * @attr {string} value - Selected item's value (only meaningful when `selectable`) — the single source of truth for selection\n * @attr {string} variant - Visual variant: 'plain' | 'bordered' | 'separated'\n *\n * @fires change - Emitted when the selected value changes. detail: { value: string | null }\n *\n * @slot - `ore-list-item` elements\n *\n * @cssprop --list-radius - Border radius for the 'bordered'/'separated' variants\n *\n * @example\n * ```html\n * <ore-list variant=\"bordered\">\n * <ore-list-item>Inbox</ore-list-item>\n * <ore-list-item>Drafts</ore-list-item>\n * </ore-list>\n * <ore-list selectable value=\"inbox\">\n * <ore-list-item value=\"inbox\">Inbox</ore-list-item>\n * <ore-list-item value=\"drafts\">Drafts</ore-list-item>\n * </ore-list>\n * ```\n */\nexport const LIST_TAG = 'ore-list' as const;\ndefine<OreListProps>(LIST_TAG, {\n props: {\n ...disablableBundle,\n ...sizableBundle,\n selectable: prop.bool(false),\n value: prop.string(),\n variant: prop.string<ListVariant>(),\n },\n\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreListEvents>();\n\n const getItems = (): HTMLElement[] => [\n ...el.querySelectorAll<HTMLElement>(':scope > ore-list-item:not([disabled])'),\n ];\n\n const getAllItems = (): HTMLElement[] => [...el.querySelectorAll<HTMLElement>(':scope > ore-list-item')];\n\n // Reaches into each item's shadow root for its focusable row — mirrors `ore-accordion`'s\n // `getSummaryElements()` — rather than relying on `item.focus()` + `shadow: { delegatesFocus:\n // true }` to land focus correctly, since that cross-boundary reporting is inconsistent enough\n // between real browsers and jsdom that other multi-item components in this package\n // (`ore-menu`, `ore-tabs`) defensively check both forms too. Queried via `[part=\"row\"]`, not\n // the `.row` class — `part` is list-item's declared public seam for exactly this kind of\n // cross-component reach; the class name is a private styling detail that could change.\n const getRow = (item: Element): HTMLElement | null =>\n item.shadowRoot?.querySelector<HTMLElement>('[part=\"row\"]') ?? null;\n\n const getRows = (): HTMLElement[] =>\n getItems()\n .map(getRow)\n .filter((row): row is HTMLElement => row != null);\n\n const listControl = createListControl<HTMLElement>({\n getItems,\n loop: true,\n onNavigate: ({ item }) => {\n getRow(item)?.focus();\n },\n signal: lifecycleSignal(onCleanup),\n });\n\n // Selection — `selectedValue` is the single source of truth (mirrors `ore-radio-group`'s\n // `selectedValue`/`RadioGroupContext.value` pattern): reflected onto the `value` attribute,\n // synced back in when set externally, and read by every item via context to derive its own\n // `selected` state. No sibling-clearing needed anywhere — changing this one signal is enough.\n const selectedValue = signal<string | undefined>(props.value.value);\n\n watch(props.value, (value) => {\n selectedValue.value = value;\n });\n\n const select = (value: string | undefined): void => {\n if (selectedValue.value === value) return;\n\n selectedValue.value = value;\n emit('change', { value: value ?? null });\n };\n\n // Only one item's swipe-revealed action panel is open at a time. The item calls this\n // directly the moment its own `revealed` attribute transitions to non-null — see\n // `ListContext.requestReveal`'s doc comment for why this replaced a bubbled event.\n const requestReveal = (item: HTMLElement): void => {\n for (const sibling of getAllItems()) {\n if (sibling !== item) sibling.removeAttribute('revealed');\n }\n };\n\n // Closes any swipe-revealed item when the user interacts anywhere outside of it — matches\n // the outside-pointerdown-closes pattern used by ore-date-picker/ore-time-picker's popovers.\n const handleOutsidePointerDown = (event: PointerEvent): void => {\n const open = getAllItems().find((item) => item.hasAttribute('revealed'));\n\n if (!open || event.composedPath().includes(open)) return;\n\n open.removeAttribute('revealed');\n };\n\n document.addEventListener('pointerdown', handleOutsidePointerDown, { capture: true });\n onCleanup(() => document.removeEventListener('pointerdown', handleOutsidePointerDown, { capture: true }));\n\n provide(LIST_CTX, {\n requestReveal,\n select,\n selectable: computed(() => Boolean(props.selectable.value)),\n value: selectedValue,\n });\n\n bind({\n attr: {\n 'aria-disabled': () => (props.disabled.value ? 'true' : null),\n role: () => (props.selectable.value ? 'listbox' : 'list'),\n value: () => selectedValue.value ?? null,\n },\n on: {\n keydown: (event: KeyboardEvent) => {\n if (!props.selectable.value || props.disabled.value) return;\n\n const row = event\n .composedPath()\n .find((node): node is HTMLElement => node instanceof HTMLElement && node.getAttribute('part') === 'row');\n\n if (!row) return;\n\n const focused = getRows().indexOf(row);\n\n if (focused === -1) return;\n\n listControl.set(focused);\n listControl.handleKeydown(event);\n },\n },\n });\n\n return html`\n <slot></slot>\n `;\n },\n\n styles: [sizeVariantMixin(LIST_SIZE_PRESET), componentStyles],\n});\n"],"mappings":"gWAoCA,IAAa,GAAA,EAAW,EAAA,cAAA,CAA2B,aAAa,EA+DnD,EAAW,YACxB,EAAA,EAAA,OAAA,CAAqB,EAAU,CAC7B,MAAO,CACL,GAAG,EAAA,iBACH,GAAG,EAAA,cACH,WAAY,EAAA,KAAK,KAAK,EAAK,EAC3B,MAAO,EAAA,KAAK,OAAO,EACnB,QAAS,EAAA,KAAK,OAAoB,CACpC,EAEA,MAAM,EAAO,CACX,IAAM,GAAA,EAAK,EAAA,QAAA,CAAQ,EACb,GAAA,EAAO,EAAA,QAAA,CAAuB,EAE9B,MAAgC,CACpC,GAAG,EAAG,iBAA8B,wCAAwC,CAC9E,EAEM,MAAmC,CAAC,GAAG,EAAG,iBAA8B,wBAAwB,CAAC,EASjG,EAAU,GACd,EAAK,YAAY,cAA2B,cAAc,GAAK,KAE3D,MACJ,EAAS,CAAC,CACP,IAAI,CAAM,CAAC,CACX,OAAQ,GAA4B,GAAO,IAAI,EAE9C,EAAc,EAAA,kBAA+B,CACjD,WACA,KAAM,GACN,YAAa,CAAE,UAAW,CACxB,EAAO,CAAI,CAAC,EAAE,MAAM,CACtB,EACA,OAAQ,EAAA,gBAAgB,EAAA,SAAS,CACnC,CAAC,EAMK,GAAA,EAAgB,EAAA,OAAA,CAA2B,EAAM,MAAM,KAAK,GAElE,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C,CACF,CACF,CAAC,EAEM,EAAA,IAAI;;KAGb,EAEA,OAAQ,CAAC,EAAA,iBAAiB,EAAA,gBAAgB,EAAG,EAAA,OAAe,CAC9D,CAAC"}
|
package/dist/list.js
CHANGED
|
@@ -20,8 +20,8 @@ l(b, {
|
|
|
20
20
|
let r = u(), i = h(), a = () => [...r.querySelectorAll(":scope > ore-list-item:not([disabled])")], o = () => [...r.querySelectorAll(":scope > ore-list-item")], c = (e) => e.shadowRoot?.querySelector("[part=\"row\"]") ?? null, l = () => a().map(c).filter((e) => e != null), p = n({
|
|
21
21
|
getItems: a,
|
|
22
22
|
loop: !0,
|
|
23
|
-
onNavigate: (e
|
|
24
|
-
c(
|
|
23
|
+
onNavigate: ({ item: e }) => {
|
|
24
|
+
c(e)?.focus();
|
|
25
25
|
},
|
|
26
26
|
signal: t(f)
|
|
27
27
|
}), b = _(e.value.value);
|
package/dist/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":[],"sources":["../src/content/list/list.ts"],"sourcesContent":["import { bind, createContext, define, getHost, html, onCleanup, prop, provide, useEmit } from '@vielzeug/ore';\nimport { computed, type Readable, signal, watch } from '@vielzeug/ripple';\nimport { createListControl, lifecycleSignal } from '../../core';\nimport { disablableBundle, LIST_SIZE_PRESET, sizableBundle } from '../../shared';\nimport { sizeVariantMixin } from '../../styles';\nimport type { ComponentSize } from '../../types';\nimport componentStyles from './list.css?inline';\n\n/** Visual variant for `ore-list`. */\nexport type ListVariant = 'bordered' | 'plain' | 'separated';\n\n/** Context provided by `ore-list` to its `ore-list-item` children. */\nexport type ListContext = {\n /**\n * Closes every other item's swipe-revealed action panel. Called directly by an item the moment\n * its own `revealed` attribute transitions to non-null (gesture or direct attribute set) —\n * replaces listening for a bubbled `reveal` event and re-deriving \"is this actually my direct\n * child\" with a plain function call, the same shape as `select` below.\n */\n requestReveal: (item: HTMLElement) => void;\n /**\n * Selects `value` (or clears the selection when `undefined`) and fires `change`. Called\n * directly by an activated item — mirrors `ore-radio-group`'s `RadioGroupContext.select()`.\n * No sibling bookkeeping needed here: every item's `selected` is *derived* from `value`, so\n * changing it here is the only thing that has to happen.\n */\n select: (value: string | undefined) => void;\n selectable: Readable<boolean>;\n /**\n * Single source of truth for the current selection — `ore-list-item` never owns its own\n * \"selected\" state; it's always derived by comparing its own `value` against this one (the\n * same shape as `ore-radio-group`'s `RadioGroupContext.value`).\n */\n value: Readable<string | undefined>;\n};\n/** Injection key for the list context. */\nexport const LIST_CTX = createContext<ListContext>('ListContext');\n\n/** Events emitted by the list component */\nexport type OreListEvents = {\n /** Emitted when the selected value changes (only when `selectable` is set). */\n change: { value: null | string };\n};\n\n/** List component properties */\nexport type OreListProps = {\n /** Disable the entire list — blocks pointer interaction and removes items from tab order */\n disabled?: boolean;\n /**\n * Enables single-selection listbox behavior: clicking (or pressing Enter/Space on) an item\n * selects it and deselects any previously-selected sibling. Arrow keys / Home / End move\n * focus between items. Omit for a plain, non-interactive display list.\n */\n selectable?: boolean;\n /** Size applied to all items (propagated via inherited CSS custom properties) */\n size?: ComponentSize;\n /**\n * Selected item's `value` (only meaningful when `selectable`) — the single source of truth for\n * selection. `ore-list-item` never owns its own selected state; set this directly, bind it for\n * two-way control, or read it back from `change`.\n */\n value?: string;\n /** Visual variant: 'plain' (default, no dividers) | 'bordered' (outer border + row dividers) | 'separated' (each item is its own card) */\n variant?: ListVariant;\n};\n\n/**\n * A vertical list container for `ore-list-item` children — plain display list by default, or a\n * keyboard-navigable single-select listbox via `selectable`. Each item can independently reveal\n * a left/right action panel via touch/pointer swipe (see `ore-list-item`'s `actions-left`/\n * `actions-right` slots) — useful for mobile-style row actions (archive, delete, …).\n *\n * @element ore-list\n * @element ore-list-item - Child element for each row\n *\n * @attr {boolean} disabled - Disable the entire list\n * @attr {boolean} selectable - Enable single-selection listbox behavior with arrow-key navigation\n * @attr {string} size - Size applied to all items: 'sm' | 'md' | 'lg'\n * @attr {string} value - Selected item's value (only meaningful when `selectable`) — the single source of truth for selection\n * @attr {string} variant - Visual variant: 'plain' | 'bordered' | 'separated'\n *\n * @fires change - Emitted when the selected value changes. detail: { value: string | null }\n *\n * @slot - `ore-list-item` elements\n *\n * @cssprop --list-radius - Border radius for the 'bordered'/'separated' variants\n *\n * @example\n * ```html\n * <ore-list variant=\"bordered\">\n * <ore-list-item>Inbox</ore-list-item>\n * <ore-list-item>Drafts</ore-list-item>\n * </ore-list>\n * <ore-list selectable value=\"inbox\">\n * <ore-list-item value=\"inbox\">Inbox</ore-list-item>\n * <ore-list-item value=\"drafts\">Drafts</ore-list-item>\n * </ore-list>\n * ```\n */\nexport const LIST_TAG = 'ore-list' as const;\ndefine<OreListProps>(LIST_TAG, {\n props: {\n ...disablableBundle,\n ...sizableBundle,\n selectable: prop.bool(false),\n value: prop.string(),\n variant: prop.string<ListVariant>(),\n },\n\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreListEvents>();\n\n const getItems = (): HTMLElement[] => [\n ...el.querySelectorAll<HTMLElement>(':scope > ore-list-item:not([disabled])'),\n ];\n\n const getAllItems = (): HTMLElement[] => [...el.querySelectorAll<HTMLElement>(':scope > ore-list-item')];\n\n // Reaches into each item's shadow root for its focusable row — mirrors `ore-accordion`'s\n // `getSummaryElements()` — rather than relying on `item.focus()` + `shadow: { delegatesFocus:\n // true }` to land focus correctly, since that cross-boundary reporting is inconsistent enough\n // between real browsers and jsdom that other multi-item components in this package\n // (`ore-menu`, `ore-tabs`) defensively check both forms too. Queried via `[part=\"row\"]`, not\n // the `.row` class — `part` is list-item's declared public seam for exactly this kind of\n // cross-component reach; the class name is a private styling detail that could change.\n const getRow = (item: Element): HTMLElement | null =>\n item.shadowRoot?.querySelector<HTMLElement>('[part=\"row\"]') ?? null;\n\n const getRows = (): HTMLElement[] =>\n getItems()\n .map(getRow)\n .filter((row): row is HTMLElement => row != null);\n\n const listControl = createListControl<HTMLElement>({\n getItems,\n loop: true,\n onNavigate: (_action, index) => {\n getRow(getItems()[index])?.focus();\n },\n signal: lifecycleSignal(onCleanup),\n });\n\n // Selection — `selectedValue` is the single source of truth (mirrors `ore-radio-group`'s\n // `selectedValue`/`RadioGroupContext.value` pattern): reflected onto the `value` attribute,\n // synced back in when set externally, and read by every item via context to derive its own\n // `selected` state. No sibling-clearing needed anywhere — changing this one signal is enough.\n const selectedValue = signal<string | undefined>(props.value.value);\n\n watch(props.value, (value) => {\n selectedValue.value = value;\n });\n\n const select = (value: string | undefined): void => {\n if (selectedValue.value === value) return;\n\n selectedValue.value = value;\n emit('change', { value: value ?? null });\n };\n\n // Only one item's swipe-revealed action panel is open at a time. The item calls this\n // directly the moment its own `revealed` attribute transitions to non-null — see\n // `ListContext.requestReveal`'s doc comment for why this replaced a bubbled event.\n const requestReveal = (item: HTMLElement): void => {\n for (const sibling of getAllItems()) {\n if (sibling !== item) sibling.removeAttribute('revealed');\n }\n };\n\n // Closes any swipe-revealed item when the user interacts anywhere outside of it — matches\n // the outside-pointerdown-closes pattern used by ore-date-picker/ore-time-picker's popovers.\n const handleOutsidePointerDown = (event: PointerEvent): void => {\n const open = getAllItems().find((item) => item.hasAttribute('revealed'));\n\n if (!open || event.composedPath().includes(open)) return;\n\n open.removeAttribute('revealed');\n };\n\n document.addEventListener('pointerdown', handleOutsidePointerDown, { capture: true });\n onCleanup(() => document.removeEventListener('pointerdown', handleOutsidePointerDown, { capture: true }));\n\n provide(LIST_CTX, {\n requestReveal,\n select,\n selectable: computed(() => Boolean(props.selectable.value)),\n value: selectedValue,\n });\n\n bind({\n attr: {\n 'aria-disabled': () => (props.disabled.value ? 'true' : null),\n role: () => (props.selectable.value ? 'listbox' : 'list'),\n value: () => selectedValue.value ?? null,\n },\n on: {\n keydown: (event: KeyboardEvent) => {\n if (!props.selectable.value || props.disabled.value) return;\n\n const row = event\n .composedPath()\n .find((node): node is HTMLElement => node instanceof HTMLElement && node.getAttribute('part') === 'row');\n\n if (!row) return;\n\n const focused = getRows().indexOf(row);\n\n if (focused === -1) return;\n\n listControl.set(focused);\n listControl.handleKeydown(event);\n },\n },\n });\n\n return html`\n <slot></slot>\n `;\n },\n\n styles: [sizeVariantMixin(LIST_SIZE_PRESET), componentStyles],\n});\n"],"mappings":";;;;;;;;;AAoCA,IAAa,IAAW,EAA2B,aAAa,GA+DnD,IAAW;AACxB,EAAqB,GAAU;CAC7B,OAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,EAAK,KAAK,EAAK;EAC3B,OAAO,EAAK,OAAO;EACnB,SAAS,EAAK,OAAoB;CACpC;CAEA,MAAM,GAAO;EACX,IAAM,IAAK,EAAQ,GACb,IAAO,EAAuB,GAE9B,UAAgC,CACpC,GAAG,EAAG,iBAA8B,wCAAwC,CAC9E,GAEM,UAAmC,CAAC,GAAG,EAAG,iBAA8B,wBAAwB,CAAC,GASjG,KAAU,MACd,EAAK,YAAY,cAA2B,gBAAc,KAAK,MAE3D,UACJ,EAAS,CAAC,CACP,IAAI,CAAM,CAAC,CACX,QAAQ,MAA4B,KAAO,IAAI,GAE9C,IAAc,EAA+B;GACjD;GACA,MAAM;GACN,aAAa,GAAS,MAAU;IAC9B,EAAO,EAAS,CAAC,CAAC,EAAM,CAAC,EAAE,MAAM;GACnC;GACA,QAAQ,EAAgB,CAAS;EACnC,CAAC,GAMK,IAAgB,EAA2B,EAAM,MAAM,KAAK;EAElE,EAAM,EAAM,QAAQ,MAAU;GAC5B,EAAc,QAAQ;EACxB,CAAC;EAED,IAAM,KAAU,MAAoC;GAC9C,EAAc,UAAU,MAE5B,EAAc,QAAQ,GACtB,EAAK,UAAU,EAAE,OAAO,KAAS,KAAK,CAAC;EACzC,GAKM,KAAiB,MAA4B;GACjD,KAAK,IAAM,KAAW,EAAY,GAChC,AAAI,MAAY,KAAM,EAAQ,gBAAgB,UAAU;EAE5D,GAIM,KAA4B,MAA8B;GAC9D,IAAM,IAAO,EAAY,CAAC,CAAC,MAAM,MAAS,EAAK,aAAa,UAAU,CAAC;GAEnE,CAAC,KAAQ,EAAM,aAAa,CAAC,CAAC,SAAS,CAAI,KAE/C,EAAK,gBAAgB,UAAU;EACjC;EAsCA,OApCA,SAAS,iBAAiB,eAAe,GAA0B,EAAE,SAAS,GAAK,CAAC,GACpF,QAAgB,SAAS,oBAAoB,eAAe,GAA0B,EAAE,SAAS,GAAK,CAAC,CAAC,GAExG,EAAQ,GAAU;GAChB;GACA;GACA,YAAY,QAAe,EAAQ,EAAM,WAAW,KAAM;GAC1D,OAAO;EACT,CAAC,GAED,EAAK;GACH,MAAM;IACJ,uBAAwB,EAAM,SAAS,QAAQ,SAAS;IACxD,YAAa,EAAM,WAAW,QAAQ,YAAY;IAClD,aAAa,EAAc,SAAS;GACtC;GACA,IAAI,EACF,UAAU,MAAyB;IACjC,IAAI,CAAC,EAAM,WAAW,SAAS,EAAM,SAAS,OAAO;IAErD,IAAM,IAAM,EACT,aAAa,CAAC,CACd,MAAM,MAA8B,aAAgB,eAAe,EAAK,aAAa,MAAM,MAAM,KAAK;IAEzG,IAAI,CAAC,GAAK;IAEV,IAAM,IAAU,EAAQ,CAAC,CAAC,QAAQ,CAAG;IAEjC,MAAY,OAEhB,EAAY,IAAI,CAAO,GACvB,EAAY,cAAc,CAAK;GACjC,EACF;EACF,CAAC,GAEM,CAAI;;;CAGb;CAEA,QAAQ,CAAC,EAAiB,CAAgB,GAAG,CAAe;AAC9D,CAAC"}
|
|
1
|
+
{"version":3,"file":"list.js","names":[],"sources":["../src/content/list/list.ts"],"sourcesContent":["import { bind, createContext, define, getHost, html, onCleanup, prop, provide, useEmit } from '@vielzeug/ore';\nimport { computed, type Readable, signal, watch } from '@vielzeug/ripple';\nimport { createListControl, lifecycleSignal } from '../../core';\nimport { disablableBundle, LIST_SIZE_PRESET, sizableBundle } from '../../shared';\nimport { sizeVariantMixin } from '../../styles';\nimport type { ComponentSize } from '../../types';\nimport componentStyles from './list.css?inline';\n\n/** Visual variant for `ore-list`. */\nexport type ListVariant = 'bordered' | 'plain' | 'separated';\n\n/** Context provided by `ore-list` to its `ore-list-item` children. */\nexport type ListContext = {\n /**\n * Closes every other item's swipe-revealed action panel. Called directly by an item the moment\n * its own `revealed` attribute transitions to non-null (gesture or direct attribute set) —\n * replaces listening for a bubbled `reveal` event and re-deriving \"is this actually my direct\n * child\" with a plain function call, the same shape as `select` below.\n */\n requestReveal: (item: HTMLElement) => void;\n /**\n * Selects `value` (or clears the selection when `undefined`) and fires `change`. Called\n * directly by an activated item — mirrors `ore-radio-group`'s `RadioGroupContext.select()`.\n * No sibling bookkeeping needed here: every item's `selected` is *derived* from `value`, so\n * changing it here is the only thing that has to happen.\n */\n select: (value: string | undefined) => void;\n selectable: Readable<boolean>;\n /**\n * Single source of truth for the current selection — `ore-list-item` never owns its own\n * \"selected\" state; it's always derived by comparing its own `value` against this one (the\n * same shape as `ore-radio-group`'s `RadioGroupContext.value`).\n */\n value: Readable<string | undefined>;\n};\n/** Injection key for the list context. */\nexport const LIST_CTX = createContext<ListContext>('ListContext');\n\n/** Events emitted by the list component */\nexport type OreListEvents = {\n /** Emitted when the selected value changes (only when `selectable` is set). */\n change: { value: null | string };\n};\n\n/** List component properties */\nexport type OreListProps = {\n /** Disable the entire list — blocks pointer interaction and removes items from tab order */\n disabled?: boolean;\n /**\n * Enables single-selection listbox behavior: clicking (or pressing Enter/Space on) an item\n * selects it and deselects any previously-selected sibling. Arrow keys / Home / End move\n * focus between items. Omit for a plain, non-interactive display list.\n */\n selectable?: boolean;\n /** Size applied to all items (propagated via inherited CSS custom properties) */\n size?: ComponentSize;\n /**\n * Selected item's `value` (only meaningful when `selectable`) — the single source of truth for\n * selection. `ore-list-item` never owns its own selected state; set this directly, bind it for\n * two-way control, or read it back from `change`.\n */\n value?: string;\n /** Visual variant: 'plain' (default, no dividers) | 'bordered' (outer border + row dividers) | 'separated' (each item is its own card) */\n variant?: ListVariant;\n};\n\n/**\n * A vertical list container for `ore-list-item` children — plain display list by default, or a\n * keyboard-navigable single-select listbox via `selectable`. Each item can independently reveal\n * a left/right action panel via touch/pointer swipe (see `ore-list-item`'s `actions-left`/\n * `actions-right` slots) — useful for mobile-style row actions (archive, delete, …).\n *\n * @element ore-list\n * @element ore-list-item - Child element for each row\n *\n * @attr {boolean} disabled - Disable the entire list\n * @attr {boolean} selectable - Enable single-selection listbox behavior with arrow-key navigation\n * @attr {string} size - Size applied to all items: 'sm' | 'md' | 'lg'\n * @attr {string} value - Selected item's value (only meaningful when `selectable`) — the single source of truth for selection\n * @attr {string} variant - Visual variant: 'plain' | 'bordered' | 'separated'\n *\n * @fires change - Emitted when the selected value changes. detail: { value: string | null }\n *\n * @slot - `ore-list-item` elements\n *\n * @cssprop --list-radius - Border radius for the 'bordered'/'separated' variants\n *\n * @example\n * ```html\n * <ore-list variant=\"bordered\">\n * <ore-list-item>Inbox</ore-list-item>\n * <ore-list-item>Drafts</ore-list-item>\n * </ore-list>\n * <ore-list selectable value=\"inbox\">\n * <ore-list-item value=\"inbox\">Inbox</ore-list-item>\n * <ore-list-item value=\"drafts\">Drafts</ore-list-item>\n * </ore-list>\n * ```\n */\nexport const LIST_TAG = 'ore-list' as const;\ndefine<OreListProps>(LIST_TAG, {\n props: {\n ...disablableBundle,\n ...sizableBundle,\n selectable: prop.bool(false),\n value: prop.string(),\n variant: prop.string<ListVariant>(),\n },\n\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreListEvents>();\n\n const getItems = (): HTMLElement[] => [\n ...el.querySelectorAll<HTMLElement>(':scope > ore-list-item:not([disabled])'),\n ];\n\n const getAllItems = (): HTMLElement[] => [...el.querySelectorAll<HTMLElement>(':scope > ore-list-item')];\n\n // Reaches into each item's shadow root for its focusable row — mirrors `ore-accordion`'s\n // `getSummaryElements()` — rather than relying on `item.focus()` + `shadow: { delegatesFocus:\n // true }` to land focus correctly, since that cross-boundary reporting is inconsistent enough\n // between real browsers and jsdom that other multi-item components in this package\n // (`ore-menu`, `ore-tabs`) defensively check both forms too. Queried via `[part=\"row\"]`, not\n // the `.row` class — `part` is list-item's declared public seam for exactly this kind of\n // cross-component reach; the class name is a private styling detail that could change.\n const getRow = (item: Element): HTMLElement | null =>\n item.shadowRoot?.querySelector<HTMLElement>('[part=\"row\"]') ?? null;\n\n const getRows = (): HTMLElement[] =>\n getItems()\n .map(getRow)\n .filter((row): row is HTMLElement => row != null);\n\n const listControl = createListControl<HTMLElement>({\n getItems,\n loop: true,\n onNavigate: ({ item }) => {\n getRow(item)?.focus();\n },\n signal: lifecycleSignal(onCleanup),\n });\n\n // Selection — `selectedValue` is the single source of truth (mirrors `ore-radio-group`'s\n // `selectedValue`/`RadioGroupContext.value` pattern): reflected onto the `value` attribute,\n // synced back in when set externally, and read by every item via context to derive its own\n // `selected` state. No sibling-clearing needed anywhere — changing this one signal is enough.\n const selectedValue = signal<string | undefined>(props.value.value);\n\n watch(props.value, (value) => {\n selectedValue.value = value;\n });\n\n const select = (value: string | undefined): void => {\n if (selectedValue.value === value) return;\n\n selectedValue.value = value;\n emit('change', { value: value ?? null });\n };\n\n // Only one item's swipe-revealed action panel is open at a time. The item calls this\n // directly the moment its own `revealed` attribute transitions to non-null — see\n // `ListContext.requestReveal`'s doc comment for why this replaced a bubbled event.\n const requestReveal = (item: HTMLElement): void => {\n for (const sibling of getAllItems()) {\n if (sibling !== item) sibling.removeAttribute('revealed');\n }\n };\n\n // Closes any swipe-revealed item when the user interacts anywhere outside of it — matches\n // the outside-pointerdown-closes pattern used by ore-date-picker/ore-time-picker's popovers.\n const handleOutsidePointerDown = (event: PointerEvent): void => {\n const open = getAllItems().find((item) => item.hasAttribute('revealed'));\n\n if (!open || event.composedPath().includes(open)) return;\n\n open.removeAttribute('revealed');\n };\n\n document.addEventListener('pointerdown', handleOutsidePointerDown, { capture: true });\n onCleanup(() => document.removeEventListener('pointerdown', handleOutsidePointerDown, { capture: true }));\n\n provide(LIST_CTX, {\n requestReveal,\n select,\n selectable: computed(() => Boolean(props.selectable.value)),\n value: selectedValue,\n });\n\n bind({\n attr: {\n 'aria-disabled': () => (props.disabled.value ? 'true' : null),\n role: () => (props.selectable.value ? 'listbox' : 'list'),\n value: () => selectedValue.value ?? null,\n },\n on: {\n keydown: (event: KeyboardEvent) => {\n if (!props.selectable.value || props.disabled.value) return;\n\n const row = event\n .composedPath()\n .find((node): node is HTMLElement => node instanceof HTMLElement && node.getAttribute('part') === 'row');\n\n if (!row) return;\n\n const focused = getRows().indexOf(row);\n\n if (focused === -1) return;\n\n listControl.set(focused);\n listControl.handleKeydown(event);\n },\n },\n });\n\n return html`\n <slot></slot>\n `;\n },\n\n styles: [sizeVariantMixin(LIST_SIZE_PRESET), componentStyles],\n});\n"],"mappings":";;;;;;;;;AAoCA,IAAa,IAAW,EAA2B,aAAa,GA+DnD,IAAW;AACxB,EAAqB,GAAU;CAC7B,OAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,EAAK,KAAK,EAAK;EAC3B,OAAO,EAAK,OAAO;EACnB,SAAS,EAAK,OAAoB;CACpC;CAEA,MAAM,GAAO;EACX,IAAM,IAAK,EAAQ,GACb,IAAO,EAAuB,GAE9B,UAAgC,CACpC,GAAG,EAAG,iBAA8B,wCAAwC,CAC9E,GAEM,UAAmC,CAAC,GAAG,EAAG,iBAA8B,wBAAwB,CAAC,GASjG,KAAU,MACd,EAAK,YAAY,cAA2B,gBAAc,KAAK,MAE3D,UACJ,EAAS,CAAC,CACP,IAAI,CAAM,CAAC,CACX,QAAQ,MAA4B,KAAO,IAAI,GAE9C,IAAc,EAA+B;GACjD;GACA,MAAM;GACN,aAAa,EAAE,cAAW;IACxB,EAAO,CAAI,CAAC,EAAE,MAAM;GACtB;GACA,QAAQ,EAAgB,CAAS;EACnC,CAAC,GAMK,IAAgB,EAA2B,EAAM,MAAM,KAAK;EAElE,EAAM,EAAM,QAAQ,MAAU;GAC5B,EAAc,QAAQ;EACxB,CAAC;EAED,IAAM,KAAU,MAAoC;GAC9C,EAAc,UAAU,MAE5B,EAAc,QAAQ,GACtB,EAAK,UAAU,EAAE,OAAO,KAAS,KAAK,CAAC;EACzC,GAKM,KAAiB,MAA4B;GACjD,KAAK,IAAM,KAAW,EAAY,GAChC,AAAI,MAAY,KAAM,EAAQ,gBAAgB,UAAU;EAE5D,GAIM,KAA4B,MAA8B;GAC9D,IAAM,IAAO,EAAY,CAAC,CAAC,MAAM,MAAS,EAAK,aAAa,UAAU,CAAC;GAEnE,CAAC,KAAQ,EAAM,aAAa,CAAC,CAAC,SAAS,CAAI,KAE/C,EAAK,gBAAgB,UAAU;EACjC;EAsCA,OApCA,SAAS,iBAAiB,eAAe,GAA0B,EAAE,SAAS,GAAK,CAAC,GACpF,QAAgB,SAAS,oBAAoB,eAAe,GAA0B,EAAE,SAAS,GAAK,CAAC,CAAC,GAExG,EAAQ,GAAU;GAChB;GACA;GACA,YAAY,QAAe,EAAQ,EAAM,WAAW,KAAM;GAC1D,OAAO;EACT,CAAC,GAED,EAAK;GACH,MAAM;IACJ,uBAAwB,EAAM,SAAS,QAAQ,SAAS;IACxD,YAAa,EAAM,WAAW,QAAQ,YAAY;IAClD,aAAa,EAAc,SAAS;GACtC;GACA,IAAI,EACF,UAAU,MAAyB;IACjC,IAAI,CAAC,EAAM,WAAW,SAAS,EAAM,SAAS,OAAO;IAErD,IAAM,IAAM,EACT,aAAa,CAAC,CACd,MAAM,MAA8B,aAAgB,eAAe,EAAK,aAAa,MAAM,MAAM,KAAK;IAEzG,IAAI,CAAC,GAAK;IAEV,IAAM,IAAU,EAAQ,CAAC,CAAC,QAAQ,CAAG;IAEjC,MAAY,OAEhB,EAAY,IAAI,CAAO,GACvB,EAAY,cAAc,CAAK;GACjC,EACF;EACF,CAAC,GAEM,CAAI;;;CAGb;CAEA,QAAQ,CAAC,EAAiB,CAAgB,GAAG,CAAe;AAC9D,CAAC"}
|
package/dist/marquee.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./content/marquee/marquee.css.cjs");let t=require("@vielzeug/ore"),n=require("@vielzeug/ripple");var r=`ore-marquee`;(0,t.define)(r,{props:{color:t.prop.string(),direction:t.prop.string(`left`),duration:t.prop.number(20),"pause-on-hover":t.prop.bool(!1),"show-controls":t.prop.bool(!0)},setup(e){let r=(0,t.getHost)(),i=0,a=[],o=[],s=null,c=0,l=null,u=null,d=t=>{if(!u||o.length===0)return;i=(t+o.length)%o.length;let n=o[i];if(!n||c===0)return;let r=e.duration.value??20,a=-(n.offsetLeft/c*r);u.style.setProperty(`animation-delay`,`${a}s`)};return(0,n.watch)(e.duration,e=>{r.style.setProperty(`--_marquee-duration`,`${e??20}s`)},{immediate:!0}),(0,t.onMounted)(()=>{u=r.shadowRoot?.querySelector(`.track`)??null;let e=r.shadowRoot?.querySelector(`slot`)??null,t=()=>{a.forEach(e=>e.remove()),a=[]},n=()=>{a.push(...o.map(e=>{let t=e.cloneNode(!0);return t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`data-marquee-clone`,``),t.setAttribute(`inert`,``),r.appendChild(t),t}))},d=()=>{if(!u||o.length===0)return;let e=u;s!==null&&cancelAnimationFrame(s),t(),c=0,e.style.removeProperty(`--_marquee-translate`),n(),s=requestAnimationFrame(()=>{s=null;let t=a[0],i=o[0];if(!t||!i||(c=t.offsetLeft-i.offsetLeft,c<=0))return;let l=Math.max(2,Math.ceil((r.clientWidth+c)/c));for(let e=2;e<l;e+=1)n();e.style.setProperty(`--_marquee-translate`,`-${c}px`)})},f=()=>{let t=(e?.assignedElements()??[]).filter(e=>e instanceof HTMLElement&&!e.hasAttribute(`data-marquee-clone`));(t.length!==o.length||t.some((e,t)=>e!==o[t]))&&(o=t,i=Math.min(i,Math.max(o.length-1,0)),d())};return l=typeof ResizeObserver>`u`?null:new ResizeObserver(d),l?.observe(r),e?.addEventListener(`slotchange`,f),f(),()=>{s!==null&&cancelAnimationFrame(s),l?.disconnect(),e?.removeEventListener(`slotchange`,f),t(),u=null,o=[],c=0}}),t.html`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./content/marquee/marquee.css.cjs");let t=require("@vielzeug/ore"),n=require("@vielzeug/ripple");var r=`ore-marquee`;(0,t.define)(r,{props:{color:t.prop.string(),direction:t.prop.string(`left`),duration:t.prop.number(20),"pause-on-hover":t.prop.bool(!1),"show-controls":t.prop.bool(!0)},setup(e){let r=(0,t.getHost)(),i=0,a=[],o=[],s=null,c=0,l=null,u=null,d=t=>{if(!u||o.length===0)return;i=(t+o.length)%o.length;let n=o[i];if(!n||c===0)return;let r=e.duration.value??20,a=-(n.offsetLeft/c*r);u.style.setProperty(`animation-delay`,`${a}s`)};return(0,n.watch)(e.duration,e=>{r.style.setProperty(`--_marquee-duration`,`${e??20}s`)},{immediate:!0}),(0,t.onMounted)(()=>{u=r.shadowRoot?.querySelector(`.track`)??null;let e=r.shadowRoot?.querySelector(`slot`)??null,t=()=>{a.forEach(e=>{e.remove()}),a=[]},n=()=>{a.push(...o.map(e=>{let t=e.cloneNode(!0);return t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`data-marquee-clone`,``),t.setAttribute(`inert`,``),r.appendChild(t),t}))},d=()=>{if(!u||o.length===0)return;let e=u;s!==null&&cancelAnimationFrame(s),t(),c=0,e.style.removeProperty(`--_marquee-translate`),n(),s=requestAnimationFrame(()=>{s=null;let t=a[0],i=o[0];if(!t||!i||(c=t.offsetLeft-i.offsetLeft,c<=0))return;let l=Math.max(2,Math.ceil((r.clientWidth+c)/c));for(let e=2;e<l;e+=1)n();e.style.setProperty(`--_marquee-translate`,`-${c}px`)})},f=()=>{let t=(e?.assignedElements()??[]).filter(e=>e instanceof HTMLElement&&!e.hasAttribute(`data-marquee-clone`));(t.length!==o.length||t.some((e,t)=>e!==o[t]))&&(o=t,i=Math.min(i,Math.max(o.length-1,0)),d())};return l=typeof ResizeObserver>`u`?null:new ResizeObserver(d),l?.observe(r),e?.addEventListener(`slotchange`,f),f(),()=>{s!==null&&cancelAnimationFrame(s),l?.disconnect(),e?.removeEventListener(`slotchange`,f),t(),u=null,o=[],c=0}}),t.html`
|
|
2
2
|
<div class="track" part="track" aria-live="off">
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</div>
|
package/dist/marquee.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.cjs","names":[],"sources":["../src/content/marquee/marquee.ts"],"sourcesContent":["import { define, getHost, html, onMounted, prop } from '@vielzeug/ore';\nimport { watch } from '@vielzeug/ripple';\n\nimport type { ThemeColor } from '../../types';\n\nimport '../icon/icon';\nimport '../../inputs/button/button';\nimport componentStyles from './marquee.css?inline';\n\nexport type MarqueeDirection = 'left' | 'right';\n\nexport type OreMarqueeProps = {\n /** Theme color for the navigation controls. */\n color?: ThemeColor;\n /** Scroll direction. Defaults to `'left'`. */\n direction?: MarqueeDirection;\n /** Duration in seconds for one complete ticker cycle. Defaults to `20`. */\n duration?: number;\n /** Pause the ticker while it is hovered. Defaults to `false`. */\n 'pause-on-hover'?: boolean;\n /** Show previous/next navigation controls. Defaults to `true`. */\n 'show-controls'?: boolean;\n};\n\n/**\n * A CSS-driven, continuously scrolling ticker.\n *\n * Direct child elements are duplicated internally for a seamless loop. Cloned\n * content is inert and hidden from assistive technology, so author interactive\n * content only in the original children.\n *\n * @element ore-marquee\n *\n * @attr {string} color - Theme color for the navigation controls.\n * @attr {number} duration - Duration in seconds for one ticker cycle (default: 20)\n * @attr {string} direction - 'left' (default) | 'right'\n * @attr {boolean} pause-on-hover - Pause while hovered (default: false)\n * @attr {boolean} show-controls - Show previous/next controls (default: true)\n *\n * @cssprop --marquee-gap - Gap between ticker items (default: var(--size-4))\n *\n * @part track - The animated ticker track.\n * @example\n * ```html\n * <ore-marquee duration=\"24\" pause-on-hover>\n * <span>Free shipping</span>\n * <span>New arrivals</span>\n * </ore-marquee>\n * ```\n */\nexport const MARQUEE_TAG = 'ore-marquee' as const;\n\ndefine<OreMarqueeProps>(MARQUEE_TAG, {\n props: {\n color: prop.string<ThemeColor>(),\n direction: prop.string<MarqueeDirection>('left'),\n duration: prop.number(20),\n 'pause-on-hover': prop.bool(false),\n 'show-controls': prop.bool(true),\n },\n setup(props) {\n const el = getHost();\n let activeIndex = 0;\n let clones: HTMLElement[] = [];\n let items: HTMLElement[] = [];\n let layoutFrame: number | null = null;\n let loopWidth = 0;\n let resizeObserver: ResizeObserver | null = null;\n let track: HTMLElement | null = null;\n\n const seekTo = (index: number): void => {\n if (!track || items.length === 0) return;\n\n activeIndex = (index + items.length) % items.length;\n\n const item = items[activeIndex];\n\n if (!item || loopWidth === 0) return;\n\n const duration = props.duration.value ?? 20;\n const delay = -((item.offsetLeft / loopWidth) * duration);\n\n track.style.setProperty('animation-delay', `${delay}s`);\n };\n\n watch(\n props.duration,\n (duration) => {\n el.style.setProperty('--_marquee-duration', `${duration ?? 20}s`);\n },\n { immediate: true },\n );\n\n onMounted(() => {\n track = el.shadowRoot?.querySelector<HTMLElement>('.track') ?? null;\n\n const slot = el.shadowRoot?.querySelector<HTMLSlotElement>('slot') ?? null;\n\n const removeClones = (): void => {\n clones.forEach((clone) => clone.remove());\n clones = [];\n };\n\n const appendCloneSet = (): void => {\n clones.push(\n ...items.map((item) => {\n const clone = item.cloneNode(true) as HTMLElement;\n\n clone.setAttribute('aria-hidden', 'true');\n clone.setAttribute('data-marquee-clone', '');\n clone.setAttribute('inert', '');\n el.appendChild(clone);\n\n return clone;\n }),\n );\n };\n\n const syncLoop = (): void => {\n if (!track || items.length === 0) return;\n\n const marqueeTrack = track;\n\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n removeClones();\n loopWidth = 0;\n marqueeTrack.style.removeProperty('--_marquee-translate');\n appendCloneSet();\n\n layoutFrame = requestAnimationFrame(() => {\n layoutFrame = null;\n\n const firstClone = clones[0];\n const firstItem = items[0];\n\n if (!firstClone || !firstItem) return;\n\n loopWidth = firstClone.offsetLeft - firstItem.offsetLeft;\n\n if (loopWidth <= 0) return;\n\n const requiredSets = Math.max(2, Math.ceil((el.clientWidth + loopWidth) / loopWidth));\n\n for (let set = 2; set < requiredSets; set += 1) appendCloneSet();\n\n marqueeTrack.style.setProperty('--_marquee-translate', `-${loopWidth}px`);\n });\n };\n\n const refreshItems = (): void => {\n const nextItems = (slot?.assignedElements() ?? []).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.hasAttribute('data-marquee-clone'),\n );\n const itemsChanged =\n nextItems.length !== items.length || nextItems.some((item, index) => item !== items[index]);\n\n if (!itemsChanged) return;\n\n items = nextItems;\n activeIndex = Math.min(activeIndex, Math.max(items.length - 1, 0));\n syncLoop();\n };\n\n resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(syncLoop);\n resizeObserver?.observe(el);\n slot?.addEventListener('slotchange', refreshItems);\n refreshItems();\n\n return () => {\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n resizeObserver?.disconnect();\n slot?.removeEventListener('slotchange', refreshItems);\n removeClones();\n track = null;\n items = [];\n loopWidth = 0;\n };\n });\n\n return html`\n <div class=\"track\" part=\"track\" aria-live=\"off\">\n <slot></slot>\n </div>\n ${() =>\n props['show-controls'].value !== false\n ? html`\n <div class=\"controls\" part=\"controls\">\n <ore-button\n class=\"nav-btn prev-btn\"\n part=\"prev-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Previous item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex - 1);\n }}>\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n <ore-button\n class=\"nav-btn next-btn\"\n part=\"next-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Next item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex + 1);\n }}>\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n </div>\n `\n : null}\n `;\n },\n styles: [componentStyles],\n});\n"],"mappings":"qLAkDA,IAAa,EAAc,eAE3B,EAAA,EAAA,OAAA,CAAwB,EAAa,CACnC,MAAO,CACL,MAAO,EAAA,KAAK,OAAmB,EAC/B,UAAW,EAAA,KAAK,OAAyB,MAAM,EAC/C,SAAU,EAAA,KAAK,OAAO,EAAE,EACxB,iBAAkB,EAAA,KAAK,KAAK,EAAK,EACjC,gBAAiB,EAAA,KAAK,KAAK,EAAI,CACjC,EACA,MAAM,EAAO,CACX,IAAM,GAAA,EAAK,EAAA,QAAA,CAAQ,EACf,EAAc,EACd,EAAwB,CAAC,EACzB,EAAuB,CAAC,EACxB,EAA6B,KAC7B,EAAY,EACZ,EAAwC,KACxC,EAA4B,KAE1B,EAAU,GAAwB,CACtC,GAAI,CAAC,GAAS,EAAM,SAAW,EAAG,OAElC,GAAe,EAAQ,EAAM,QAAU,EAAM,OAE7C,IAAM,EAAO,EAAM,GAEnB,GAAI,CAAC,GAAQ,IAAc,EAAG,OAE9B,IAAM,EAAW,EAAM,SAAS,OAAS,GACnC,EAAQ,EAAG,EAAK,WAAa,EAAa,GAEhD,EAAM,MAAM,YAAY,kBAAmB,GAAG,EAAM,EAAE,CACxD,
|
|
1
|
+
{"version":3,"file":"marquee.cjs","names":[],"sources":["../src/content/marquee/marquee.ts"],"sourcesContent":["import { define, getHost, html, onMounted, prop } from '@vielzeug/ore';\nimport { watch } from '@vielzeug/ripple';\n\nimport type { ThemeColor } from '../../types';\n\nimport '../icon/icon';\nimport '../../inputs/button/button';\nimport componentStyles from './marquee.css?inline';\n\nexport type MarqueeDirection = 'left' | 'right';\n\nexport type OreMarqueeProps = {\n /** Theme color for the navigation controls. */\n color?: ThemeColor;\n /** Scroll direction. Defaults to `'left'`. */\n direction?: MarqueeDirection;\n /** Duration in seconds for one complete ticker cycle. Defaults to `20`. */\n duration?: number;\n /** Pause the ticker while it is hovered. Defaults to `false`. */\n 'pause-on-hover'?: boolean;\n /** Show previous/next navigation controls. Defaults to `true`. */\n 'show-controls'?: boolean;\n};\n\n/**\n * A CSS-driven, continuously scrolling ticker.\n *\n * Direct child elements are duplicated internally for a seamless loop. Cloned\n * content is inert and hidden from assistive technology, so author interactive\n * content only in the original children.\n *\n * @element ore-marquee\n *\n * @attr {string} color - Theme color for the navigation controls.\n * @attr {number} duration - Duration in seconds for one ticker cycle (default: 20)\n * @attr {string} direction - 'left' (default) | 'right'\n * @attr {boolean} pause-on-hover - Pause while hovered (default: false)\n * @attr {boolean} show-controls - Show previous/next controls (default: true)\n *\n * @cssprop --marquee-gap - Gap between ticker items (default: var(--size-4))\n *\n * @part track - The animated ticker track.\n * @example\n * ```html\n * <ore-marquee duration=\"24\" pause-on-hover>\n * <span>Free shipping</span>\n * <span>New arrivals</span>\n * </ore-marquee>\n * ```\n */\nexport const MARQUEE_TAG = 'ore-marquee' as const;\n\ndefine<OreMarqueeProps>(MARQUEE_TAG, {\n props: {\n color: prop.string<ThemeColor>(),\n direction: prop.string<MarqueeDirection>('left'),\n duration: prop.number(20),\n 'pause-on-hover': prop.bool(false),\n 'show-controls': prop.bool(true),\n },\n setup(props) {\n const el = getHost();\n let activeIndex = 0;\n let clones: HTMLElement[] = [];\n let items: HTMLElement[] = [];\n let layoutFrame: number | null = null;\n let loopWidth = 0;\n let resizeObserver: ResizeObserver | null = null;\n let track: HTMLElement | null = null;\n\n const seekTo = (index: number): void => {\n if (!track || items.length === 0) return;\n\n activeIndex = (index + items.length) % items.length;\n\n const item = items[activeIndex];\n\n if (!item || loopWidth === 0) return;\n\n const duration = props.duration.value ?? 20;\n const delay = -((item.offsetLeft / loopWidth) * duration);\n\n track.style.setProperty('animation-delay', `${delay}s`);\n };\n\n watch(\n props.duration,\n (duration) => {\n el.style.setProperty('--_marquee-duration', `${duration ?? 20}s`);\n },\n { immediate: true },\n );\n\n onMounted(() => {\n track = el.shadowRoot?.querySelector<HTMLElement>('.track') ?? null;\n\n const slot = el.shadowRoot?.querySelector<HTMLSlotElement>('slot') ?? null;\n\n const removeClones = (): void => {\n clones.forEach((clone) => {\n clone.remove();\n });\n clones = [];\n };\n\n const appendCloneSet = (): void => {\n clones.push(\n ...items.map((item) => {\n const clone = item.cloneNode(true) as HTMLElement;\n\n clone.setAttribute('aria-hidden', 'true');\n clone.setAttribute('data-marquee-clone', '');\n clone.setAttribute('inert', '');\n el.appendChild(clone);\n\n return clone;\n }),\n );\n };\n\n const syncLoop = (): void => {\n if (!track || items.length === 0) return;\n\n const marqueeTrack = track;\n\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n removeClones();\n loopWidth = 0;\n marqueeTrack.style.removeProperty('--_marquee-translate');\n appendCloneSet();\n\n layoutFrame = requestAnimationFrame(() => {\n layoutFrame = null;\n\n const firstClone = clones[0];\n const firstItem = items[0];\n\n if (!firstClone || !firstItem) return;\n\n loopWidth = firstClone.offsetLeft - firstItem.offsetLeft;\n\n if (loopWidth <= 0) return;\n\n const requiredSets = Math.max(2, Math.ceil((el.clientWidth + loopWidth) / loopWidth));\n\n for (let set = 2; set < requiredSets; set += 1) appendCloneSet();\n\n marqueeTrack.style.setProperty('--_marquee-translate', `-${loopWidth}px`);\n });\n };\n\n const refreshItems = (): void => {\n const nextItems = (slot?.assignedElements() ?? []).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.hasAttribute('data-marquee-clone'),\n );\n const itemsChanged =\n nextItems.length !== items.length || nextItems.some((item, index) => item !== items[index]);\n\n if (!itemsChanged) return;\n\n items = nextItems;\n activeIndex = Math.min(activeIndex, Math.max(items.length - 1, 0));\n syncLoop();\n };\n\n resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(syncLoop);\n resizeObserver?.observe(el);\n slot?.addEventListener('slotchange', refreshItems);\n refreshItems();\n\n return () => {\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n resizeObserver?.disconnect();\n slot?.removeEventListener('slotchange', refreshItems);\n removeClones();\n track = null;\n items = [];\n loopWidth = 0;\n };\n });\n\n return html`\n <div class=\"track\" part=\"track\" aria-live=\"off\">\n <slot></slot>\n </div>\n ${() =>\n props['show-controls'].value !== false\n ? html`\n <div class=\"controls\" part=\"controls\">\n <ore-button\n class=\"nav-btn prev-btn\"\n part=\"prev-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Previous item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex - 1);\n }}>\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n <ore-button\n class=\"nav-btn next-btn\"\n part=\"next-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Next item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex + 1);\n }}>\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n </div>\n `\n : null}\n `;\n },\n styles: [componentStyles],\n});\n"],"mappings":"qLAkDA,IAAa,EAAc,eAE3B,EAAA,EAAA,OAAA,CAAwB,EAAa,CACnC,MAAO,CACL,MAAO,EAAA,KAAK,OAAmB,EAC/B,UAAW,EAAA,KAAK,OAAyB,MAAM,EAC/C,SAAU,EAAA,KAAK,OAAO,EAAE,EACxB,iBAAkB,EAAA,KAAK,KAAK,EAAK,EACjC,gBAAiB,EAAA,KAAK,KAAK,EAAI,CACjC,EACA,MAAM,EAAO,CACX,IAAM,GAAA,EAAK,EAAA,QAAA,CAAQ,EACf,EAAc,EACd,EAAwB,CAAC,EACzB,EAAuB,CAAC,EACxB,EAA6B,KAC7B,EAAY,EACZ,EAAwC,KACxC,EAA4B,KAE1B,EAAU,GAAwB,CACtC,GAAI,CAAC,GAAS,EAAM,SAAW,EAAG,OAElC,GAAe,EAAQ,EAAM,QAAU,EAAM,OAE7C,IAAM,EAAO,EAAM,GAEnB,GAAI,CAAC,GAAQ,IAAc,EAAG,OAE9B,IAAM,EAAW,EAAM,SAAS,OAAS,GACnC,EAA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CACH,EAEM,MAA2B,CAC/B,IAAM,GAAa,GAAM,iBAAiB,GAAK,CAAC,EAAA,CAAG,OAChD,GAAgC,aAAiB,aAAe,CAAC,EAAM,aAAa,oBAAoB,CAC3G,GAEE,EAAU,SAAW,EAAM,QAAU,EAAU,MAAM,EAAM,IAAU,IAAS,EAAM,EAAM,KAI5F,EAAQ,EACR,EAAc,KAAK,IAAI,EAAa,KAAK,IAAI,EAAM,OAAS,EAAG,CAAC,CAAC,EACjE,EAAS,EACX,EAOA,MALA,GAAiB,OAAO,eAAmB,IAAc,KAAO,IAAI,eAAe,CAAQ,EAC3F,GAAgB,QAAQ,CAAE,EAC1B,GAAM,iBAAiB,aAAc,CAAY,EACjD,EAAa,MAEA,CACP,IAAgB,MAAM,qBAAqB,CAAW,EAE1D,GAAgB,WAAW,EAC3B,GAAM,oBAAoB,aAAc,CAAY,EACpD,EAAa,EACb,EAAQ,KACR,EAAQ,CAAC,EACT,EAAY,CACd,CACF,CAAC,EAEM,EAAA,IAAI;;;;YAKP,EAAM,gBAAgB,CAAC,QAAU,GAiC7B,KAhCA,EAAA,IAAI;;;;;;8BAMgB,EAAM,MAAM,MAAM;;;;2BAItB,GAAiB,CACzB,EAAM,gBAAgB,EACtB,EAAO,EAAc,CAAC,CACxB,EAAE;;;;;;;8BAOY,EAAM,MAAM,MAAM;;;;2BAItB,GAAiB,CACzB,EAAM,gBAAgB,EACtB,EAAO,EAAc,CAAC,CACxB,EAAE;;;;cAKH;KAEf,EACA,OAAQ,CAAC,EAAA,OAAe,CAC1B,CAAC"}
|
package/dist/marquee.js
CHANGED
|
@@ -25,7 +25,9 @@ t(s, {
|
|
|
25
25
|
}, { immediate: !0 }), i(() => {
|
|
26
26
|
f = t.shadowRoot?.querySelector(".track") ?? null;
|
|
27
27
|
let e = t.shadowRoot?.querySelector("slot") ?? null, n = () => {
|
|
28
|
-
s.forEach((e) =>
|
|
28
|
+
s.forEach((e) => {
|
|
29
|
+
e.remove();
|
|
30
|
+
}), s = [];
|
|
29
31
|
}, r = () => {
|
|
30
32
|
s.push(...c.map((e) => {
|
|
31
33
|
let n = e.cloneNode(!0);
|
package/dist/marquee.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.js","names":[],"sources":["../src/content/marquee/marquee.ts"],"sourcesContent":["import { define, getHost, html, onMounted, prop } from '@vielzeug/ore';\nimport { watch } from '@vielzeug/ripple';\n\nimport type { ThemeColor } from '../../types';\n\nimport '../icon/icon';\nimport '../../inputs/button/button';\nimport componentStyles from './marquee.css?inline';\n\nexport type MarqueeDirection = 'left' | 'right';\n\nexport type OreMarqueeProps = {\n /** Theme color for the navigation controls. */\n color?: ThemeColor;\n /** Scroll direction. Defaults to `'left'`. */\n direction?: MarqueeDirection;\n /** Duration in seconds for one complete ticker cycle. Defaults to `20`. */\n duration?: number;\n /** Pause the ticker while it is hovered. Defaults to `false`. */\n 'pause-on-hover'?: boolean;\n /** Show previous/next navigation controls. Defaults to `true`. */\n 'show-controls'?: boolean;\n};\n\n/**\n * A CSS-driven, continuously scrolling ticker.\n *\n * Direct child elements are duplicated internally for a seamless loop. Cloned\n * content is inert and hidden from assistive technology, so author interactive\n * content only in the original children.\n *\n * @element ore-marquee\n *\n * @attr {string} color - Theme color for the navigation controls.\n * @attr {number} duration - Duration in seconds for one ticker cycle (default: 20)\n * @attr {string} direction - 'left' (default) | 'right'\n * @attr {boolean} pause-on-hover - Pause while hovered (default: false)\n * @attr {boolean} show-controls - Show previous/next controls (default: true)\n *\n * @cssprop --marquee-gap - Gap between ticker items (default: var(--size-4))\n *\n * @part track - The animated ticker track.\n * @example\n * ```html\n * <ore-marquee duration=\"24\" pause-on-hover>\n * <span>Free shipping</span>\n * <span>New arrivals</span>\n * </ore-marquee>\n * ```\n */\nexport const MARQUEE_TAG = 'ore-marquee' as const;\n\ndefine<OreMarqueeProps>(MARQUEE_TAG, {\n props: {\n color: prop.string<ThemeColor>(),\n direction: prop.string<MarqueeDirection>('left'),\n duration: prop.number(20),\n 'pause-on-hover': prop.bool(false),\n 'show-controls': prop.bool(true),\n },\n setup(props) {\n const el = getHost();\n let activeIndex = 0;\n let clones: HTMLElement[] = [];\n let items: HTMLElement[] = [];\n let layoutFrame: number | null = null;\n let loopWidth = 0;\n let resizeObserver: ResizeObserver | null = null;\n let track: HTMLElement | null = null;\n\n const seekTo = (index: number): void => {\n if (!track || items.length === 0) return;\n\n activeIndex = (index + items.length) % items.length;\n\n const item = items[activeIndex];\n\n if (!item || loopWidth === 0) return;\n\n const duration = props.duration.value ?? 20;\n const delay = -((item.offsetLeft / loopWidth) * duration);\n\n track.style.setProperty('animation-delay', `${delay}s`);\n };\n\n watch(\n props.duration,\n (duration) => {\n el.style.setProperty('--_marquee-duration', `${duration ?? 20}s`);\n },\n { immediate: true },\n );\n\n onMounted(() => {\n track = el.shadowRoot?.querySelector<HTMLElement>('.track') ?? null;\n\n const slot = el.shadowRoot?.querySelector<HTMLSlotElement>('slot') ?? null;\n\n const removeClones = (): void => {\n clones.forEach((clone) => clone.remove());\n clones = [];\n };\n\n const appendCloneSet = (): void => {\n clones.push(\n ...items.map((item) => {\n const clone = item.cloneNode(true) as HTMLElement;\n\n clone.setAttribute('aria-hidden', 'true');\n clone.setAttribute('data-marquee-clone', '');\n clone.setAttribute('inert', '');\n el.appendChild(clone);\n\n return clone;\n }),\n );\n };\n\n const syncLoop = (): void => {\n if (!track || items.length === 0) return;\n\n const marqueeTrack = track;\n\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n removeClones();\n loopWidth = 0;\n marqueeTrack.style.removeProperty('--_marquee-translate');\n appendCloneSet();\n\n layoutFrame = requestAnimationFrame(() => {\n layoutFrame = null;\n\n const firstClone = clones[0];\n const firstItem = items[0];\n\n if (!firstClone || !firstItem) return;\n\n loopWidth = firstClone.offsetLeft - firstItem.offsetLeft;\n\n if (loopWidth <= 0) return;\n\n const requiredSets = Math.max(2, Math.ceil((el.clientWidth + loopWidth) / loopWidth));\n\n for (let set = 2; set < requiredSets; set += 1) appendCloneSet();\n\n marqueeTrack.style.setProperty('--_marquee-translate', `-${loopWidth}px`);\n });\n };\n\n const refreshItems = (): void => {\n const nextItems = (slot?.assignedElements() ?? []).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.hasAttribute('data-marquee-clone'),\n );\n const itemsChanged =\n nextItems.length !== items.length || nextItems.some((item, index) => item !== items[index]);\n\n if (!itemsChanged) return;\n\n items = nextItems;\n activeIndex = Math.min(activeIndex, Math.max(items.length - 1, 0));\n syncLoop();\n };\n\n resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(syncLoop);\n resizeObserver?.observe(el);\n slot?.addEventListener('slotchange', refreshItems);\n refreshItems();\n\n return () => {\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n resizeObserver?.disconnect();\n slot?.removeEventListener('slotchange', refreshItems);\n removeClones();\n track = null;\n items = [];\n loopWidth = 0;\n };\n });\n\n return html`\n <div class=\"track\" part=\"track\" aria-live=\"off\">\n <slot></slot>\n </div>\n ${() =>\n props['show-controls'].value !== false\n ? html`\n <div class=\"controls\" part=\"controls\">\n <ore-button\n class=\"nav-btn prev-btn\"\n part=\"prev-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Previous item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex - 1);\n }}>\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n <ore-button\n class=\"nav-btn next-btn\"\n part=\"next-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Next item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex + 1);\n }}>\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n </div>\n `\n : null}\n `;\n },\n styles: [componentStyles],\n});\n"],"mappings":";;;;AAkDA,IAAa,IAAc;AAE3B,EAAwB,GAAa;CACnC,OAAO;EACL,OAAO,EAAK,OAAmB;EAC/B,WAAW,EAAK,OAAyB,MAAM;EAC/C,UAAU,EAAK,OAAO,EAAE;EACxB,kBAAkB,EAAK,KAAK,EAAK;EACjC,iBAAiB,EAAK,KAAK,EAAI;CACjC;CACA,MAAM,GAAO;EACX,IAAM,IAAK,EAAQ,GACf,IAAc,GACd,IAAwB,CAAC,GACzB,IAAuB,CAAC,GACxB,IAA6B,MAC7B,IAAY,GACZ,IAAwC,MACxC,IAA4B,MAE1B,KAAU,MAAwB;GACtC,IAAI,CAAC,KAAS,EAAM,WAAW,GAAG;GAElC,KAAe,IAAQ,EAAM,UAAU,EAAM;GAE7C,IAAM,IAAO,EAAM;GAEnB,IAAI,CAAC,KAAQ,MAAc,GAAG;GAE9B,IAAM,IAAW,EAAM,SAAS,SAAS,IACnC,IAAQ,EAAG,EAAK,aAAa,IAAa;GAEhD,EAAM,MAAM,YAAY,mBAAmB,GAAG,EAAM,EAAE;EACxD;
|
|
1
|
+
{"version":3,"file":"marquee.js","names":[],"sources":["../src/content/marquee/marquee.ts"],"sourcesContent":["import { define, getHost, html, onMounted, prop } from '@vielzeug/ore';\nimport { watch } from '@vielzeug/ripple';\n\nimport type { ThemeColor } from '../../types';\n\nimport '../icon/icon';\nimport '../../inputs/button/button';\nimport componentStyles from './marquee.css?inline';\n\nexport type MarqueeDirection = 'left' | 'right';\n\nexport type OreMarqueeProps = {\n /** Theme color for the navigation controls. */\n color?: ThemeColor;\n /** Scroll direction. Defaults to `'left'`. */\n direction?: MarqueeDirection;\n /** Duration in seconds for one complete ticker cycle. Defaults to `20`. */\n duration?: number;\n /** Pause the ticker while it is hovered. Defaults to `false`. */\n 'pause-on-hover'?: boolean;\n /** Show previous/next navigation controls. Defaults to `true`. */\n 'show-controls'?: boolean;\n};\n\n/**\n * A CSS-driven, continuously scrolling ticker.\n *\n * Direct child elements are duplicated internally for a seamless loop. Cloned\n * content is inert and hidden from assistive technology, so author interactive\n * content only in the original children.\n *\n * @element ore-marquee\n *\n * @attr {string} color - Theme color for the navigation controls.\n * @attr {number} duration - Duration in seconds for one ticker cycle (default: 20)\n * @attr {string} direction - 'left' (default) | 'right'\n * @attr {boolean} pause-on-hover - Pause while hovered (default: false)\n * @attr {boolean} show-controls - Show previous/next controls (default: true)\n *\n * @cssprop --marquee-gap - Gap between ticker items (default: var(--size-4))\n *\n * @part track - The animated ticker track.\n * @example\n * ```html\n * <ore-marquee duration=\"24\" pause-on-hover>\n * <span>Free shipping</span>\n * <span>New arrivals</span>\n * </ore-marquee>\n * ```\n */\nexport const MARQUEE_TAG = 'ore-marquee' as const;\n\ndefine<OreMarqueeProps>(MARQUEE_TAG, {\n props: {\n color: prop.string<ThemeColor>(),\n direction: prop.string<MarqueeDirection>('left'),\n duration: prop.number(20),\n 'pause-on-hover': prop.bool(false),\n 'show-controls': prop.bool(true),\n },\n setup(props) {\n const el = getHost();\n let activeIndex = 0;\n let clones: HTMLElement[] = [];\n let items: HTMLElement[] = [];\n let layoutFrame: number | null = null;\n let loopWidth = 0;\n let resizeObserver: ResizeObserver | null = null;\n let track: HTMLElement | null = null;\n\n const seekTo = (index: number): void => {\n if (!track || items.length === 0) return;\n\n activeIndex = (index + items.length) % items.length;\n\n const item = items[activeIndex];\n\n if (!item || loopWidth === 0) return;\n\n const duration = props.duration.value ?? 20;\n const delay = -((item.offsetLeft / loopWidth) * duration);\n\n track.style.setProperty('animation-delay', `${delay}s`);\n };\n\n watch(\n props.duration,\n (duration) => {\n el.style.setProperty('--_marquee-duration', `${duration ?? 20}s`);\n },\n { immediate: true },\n );\n\n onMounted(() => {\n track = el.shadowRoot?.querySelector<HTMLElement>('.track') ?? null;\n\n const slot = el.shadowRoot?.querySelector<HTMLSlotElement>('slot') ?? null;\n\n const removeClones = (): void => {\n clones.forEach((clone) => {\n clone.remove();\n });\n clones = [];\n };\n\n const appendCloneSet = (): void => {\n clones.push(\n ...items.map((item) => {\n const clone = item.cloneNode(true) as HTMLElement;\n\n clone.setAttribute('aria-hidden', 'true');\n clone.setAttribute('data-marquee-clone', '');\n clone.setAttribute('inert', '');\n el.appendChild(clone);\n\n return clone;\n }),\n );\n };\n\n const syncLoop = (): void => {\n if (!track || items.length === 0) return;\n\n const marqueeTrack = track;\n\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n removeClones();\n loopWidth = 0;\n marqueeTrack.style.removeProperty('--_marquee-translate');\n appendCloneSet();\n\n layoutFrame = requestAnimationFrame(() => {\n layoutFrame = null;\n\n const firstClone = clones[0];\n const firstItem = items[0];\n\n if (!firstClone || !firstItem) return;\n\n loopWidth = firstClone.offsetLeft - firstItem.offsetLeft;\n\n if (loopWidth <= 0) return;\n\n const requiredSets = Math.max(2, Math.ceil((el.clientWidth + loopWidth) / loopWidth));\n\n for (let set = 2; set < requiredSets; set += 1) appendCloneSet();\n\n marqueeTrack.style.setProperty('--_marquee-translate', `-${loopWidth}px`);\n });\n };\n\n const refreshItems = (): void => {\n const nextItems = (slot?.assignedElements() ?? []).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.hasAttribute('data-marquee-clone'),\n );\n const itemsChanged =\n nextItems.length !== items.length || nextItems.some((item, index) => item !== items[index]);\n\n if (!itemsChanged) return;\n\n items = nextItems;\n activeIndex = Math.min(activeIndex, Math.max(items.length - 1, 0));\n syncLoop();\n };\n\n resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(syncLoop);\n resizeObserver?.observe(el);\n slot?.addEventListener('slotchange', refreshItems);\n refreshItems();\n\n return () => {\n if (layoutFrame !== null) cancelAnimationFrame(layoutFrame);\n\n resizeObserver?.disconnect();\n slot?.removeEventListener('slotchange', refreshItems);\n removeClones();\n track = null;\n items = [];\n loopWidth = 0;\n };\n });\n\n return html`\n <div class=\"track\" part=\"track\" aria-live=\"off\">\n <slot></slot>\n </div>\n ${() =>\n props['show-controls'].value !== false\n ? html`\n <div class=\"controls\" part=\"controls\">\n <ore-button\n class=\"nav-btn prev-btn\"\n part=\"prev-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Previous item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex - 1);\n }}>\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n <ore-button\n class=\"nav-btn next-btn\"\n part=\"next-btn\"\n variant=\"ghost\"\n color=${() => props.color.value}\n rounded\n icon-only\n label=\"Next item\"\n @click=${(event: Event) => {\n event.stopPropagation();\n seekTo(activeIndex + 1);\n }}>\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </ore-button>\n </div>\n `\n : null}\n `;\n },\n styles: [componentStyles],\n});\n"],"mappings":";;;;AAkDA,IAAa,IAAc;AAE3B,EAAwB,GAAa;CACnC,OAAO;EACL,OAAO,EAAK,OAAmB;EAC/B,WAAW,EAAK,OAAyB,MAAM;EAC/C,UAAU,EAAK,OAAO,EAAE;EACxB,kBAAkB,EAAK,KAAK,EAAK;EACjC,iBAAiB,EAAK,KAAK,EAAI;CACjC;CACA,MAAM,GAAO;EACX,IAAM,IAAK,EAAQ,GACf,IAAc,GACd,IAAwB,CAAC,GACzB,IAAuB,CAAC,GACxB,IAA6B,MAC7B,IAAY,GACZ,IAAwC,MACxC,IAA4B,MAE1B,KAAU,MAAwB;GACtC,IAAI,CAAC,KAAS,EAAM,WAAW,GAAG;GAElC,KAAe,IAAQ,EAAM,UAAU,EAAM;GAE7C,IAAM,IAAO,EAAM;GAEnB,IAAI,CAAC,KAAQ,MAAc,GAAG;GAE9B,IAAM,IAAW,EAAM,SAAS,SAAS,IACnC,IAAQ,EAAG,EAAK,aAAa,IAAa;GAEhD,EAAM,MAAM,YAAY,mBAAmB,GAAG,EAAM,EAAE;EACxD;EAoGA,OAlGA,EACE,EAAM,WACL,MAAa;GACZ,EAAG,M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UAAU,EAAU,MAAM,GAAM,MAAU,MAAS,EAAM,EAAM,OAI5F,IAAQ,GACR,IAAc,KAAK,IAAI,GAAa,KAAK,IAAI,EAAM,SAAS,GAAG,CAAC,CAAC,GACjE,EAAS;GACX;GAOA,OALA,IAAiB,OAAO,iBAAmB,MAAc,OAAO,IAAI,eAAe,CAAQ,GAC3F,GAAgB,QAAQ,CAAE,GAC1B,GAAM,iBAAiB,cAAc,CAAY,GACjD,EAAa,SAEA;IAQX,AAPI,MAAgB,QAAM,qBAAqB,CAAW,GAE1D,GAAgB,WAAW,GAC3B,GAAM,oBAAoB,cAAc,CAAY,GACpD,EAAa,GACb,IAAQ,MACR,IAAQ,CAAC,GACT,IAAY;GACd;EACF,CAAC,GAEM,CAAI;;;;cAKP,EAAM,gBAAgB,CAAC,UAAU,KAiC7B,OAhCA,CAAI;;;;;;gCAMgB,EAAM,MAAM,MAAM;;;;4BAItB,MAAiB;GAEzB,AADA,EAAM,gBAAgB,GACtB,EAAO,IAAc,CAAC;EACxB,EAAE;;;;;;;gCAOY,EAAM,MAAM,MAAM;;;;4BAItB,MAAiB;GAEzB,AADA,EAAM,gBAAgB,GACtB,EAAO,IAAc,CAAC;EACxB,EAAE;;;;cAKH;;CAEf;CACA,QAAQ,CAAC,CAAe;AAC1B,CAAC"}
|
package/dist/menu.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/shape.css.cjs"),t=require("./styles/mixins/theme.css.cjs"),n=require("./core/keyboard.cjs"),r=require("./core/ore.cjs"),i=require("./core/overlay.cjs"),a=require("./core/nav.cjs"),o=require("./core/positioner.cjs"),s=require("./shared/prop-bundles.cjs"),c=require("./shared/size-presets.cjs"),l=require("./overlay/menu/menu.css.cjs"),u=require("./overlay/menu/menu-item.css.cjs"),d=require("./overlay/menu/menu-separator.css.cjs");let f=require("@vielzeug/ore"),p=require("@vielzeug/ripple");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/shape.css.cjs"),t=require("./styles/mixins/theme.css.cjs"),n=require("./core/keyboard.cjs"),r=require("./core/ore.cjs"),i=require("./core/overlay.cjs"),a=require("./core/nav.cjs"),o=require("./core/positioner.cjs"),s=require("./shared/prop-bundles.cjs"),c=require("./shared/size-presets.cjs"),l=require("./overlay/menu/menu.css.cjs"),u=require("./overlay/menu/menu-item.css.cjs"),d=require("./overlay/menu/menu-separator.css.cjs");let f=require("@vielzeug/ore"),p=require("@vielzeug/ripple"),m=require("@vielzeug/focus");var h=`ore-menu-item`;(0,f.define)(h,{props:{checked:f.prop.bool(!1),disabled:f.prop.bool(!1),type:f.prop.string(),value:f.prop.string()},setup(e){let t=()=>e.type.value===`checkbox`||e.type.value===`radio`,n=()=>t()&&e.checked.value;return t()?f.html`
|
|
2
2
|
<div
|
|
3
3
|
class="${()=>{let t=e.type.value;return[`item`,t===`checkbox`?`is-checkbox`:``,t===`radio`?`is-radio`:``,n()?`is-checked`:``].filter(Boolean).join(` `)}}"
|
|
4
4
|
tabindex="-1"
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
14
14
|
<span class="icon-slot"><slot name="icon"></slot></span>
|
|
15
15
|
<span class="item-label"><slot></slot></span>
|
|
16
16
|
</div>
|
|
17
|
-
`},styles:[t.colorThemeMixin,u.default]});var
|
|
17
|
+
`},styles:[t.colorThemeMixin,u.default]});var g=`ore-menu-separator`;(0,f.define)(g,{setup(){return f.html``},styles:[d.default]});var _=e=>e===`checkbox`||e===`radio`,v=e=>e==null?void 0:e===``||e===`true`,y=`ore-menu`;(0,f.define)(y,{props:{...s.sizableBundle,...s.disablableBundle,"default-open":f.prop.bool(!1),open:{default:void 0,parse:v},placement:f.prop.oneOf([`bottom`,`bottom-start`,`bottom-end`,`top`,`top-start`,`top-end`],`bottom-start`)},setup(e){let t=(0,f.getHost)(),s=(0,f.useEmit)(),c=(0,f.useSlots)(),l=f.watchEffect,u=(0,f.createStableId)(`menu`),d=(0,p.computed)(()=>!!e.disabled.value),h=r.lifecycleSignal(f.onCleanup),g=null,v=null,y=null;function b(){return Array.from(t.querySelectorAll(`ore-menu-item:not([disabled])`))}function x(e){return e?e.shadowRoot?.querySelector(`[role^="menuitem"]`)??e:null}function S(){return b().findIndex(e=>{let t=x(e);return e===document.activeElement||t===document.activeElement})}let C=(0,p.signal)(!1),w=null,T=o.createDropdownPositioner({getFloating:()=>v,getPlacement:()=>e.placement.value??`bottom-start`,getReference:()=>g,matchWidth:!1,offsetPx:4,padding:6}),E=a.createListControl({disabled:(0,p.computed)(()=>!C.value),getItems:b,isItemDisabled:e=>e.hasAttribute(`disabled`),onNavigate:({item:e})=>{x(e)?.focus()},signal:h}),D=(e=`programmatic`,t=!0)=>{C.value&&(C.value=!1,E.reset(),w?.(),w=null,t&&(0,m.restoreFocus)(()=>g),s(`open-change`,{open:!1,reason:e}))},O=(e=`programmatic`)=>{d.value||C.value||(C.value=!0,T.update(),w=T.startAutoUpdate?.()??null,s(`open-change`,{open:!0,reason:e}))},k=()=>{C.value?D(`trigger`):O(`click`)};i.createOutsidePointerDismissal({getTargets:()=>[t,v],isActive:()=>C.value,onDismiss:()=>D(`outsideClick`),signal:h});let A=!1;(0,p.watch)(e.open,t=>{t===void 0?A?D(`programmatic`):e[`default-open`].value&&O(`programmatic`):t?O(`programmatic`):D(`programmatic`),A=!0},{immediate:!0}),h.addEventListener(`abort`,()=>{C.value&&(C.value=!1,E.reset(),w?.(),w=null)},{once:!0});let j=e=>{let n=e.getAttribute(`type`),r=_(n);if(n===`checkbox`)e.toggleAttribute(`checked`,!e.hasAttribute(`checked`));else if(n===`radio`)for(let n of t.querySelectorAll(`ore-menu-item[type="radio"]`))n.toggleAttribute(`checked`,n===e);let i=e.getAttribute(`value`)??``,a=r?e.hasAttribute(`checked`):void 0;s(`select`,{checked:a,value:i}),r||D(`programmatic`)},M=n.createInteraction({keys:[`Enter`,` `,`ArrowDown`],onPress:()=>{O(`keyboard`),requestAnimationFrame(()=>E.set(0))}}),N=n.createInteraction({onPress:()=>{let e=E.getActiveItem();e&&j(e)}});function P(e){if(d.value)return;if(!C.value){M.handleKeydown(e);return}let t=S();if(t>=0&&E.set(t),e.key===`Escape`){e.preventDefault(),D(`escape`);return}if(!E.handleKeydown(e)){if(e.key===` `||e.key===`Enter`){N.handleKeydown(e);return}e.key===`Tab`&&D(`programmatic`)}}(0,f.bind)({on:{click:e=>{let t=e.composedPath();if(!C.value)return;let n=t.find(e=>e instanceof HTMLElement&&e.tagName===`ORE-MENU-ITEM`)??e.target?.closest(`ore-menu-item`)??null;!n||n.hasAttribute(`disabled`)||j(n)}}}),l(()=>{let e=C.value;v&&v.toggleAttribute(`data-open`,e)});function F(){if(y?.(),y=null,g=c.elements(`trigger`).value?.[0]??null,!g)return;let e=[],t=(0,f.bind)({aria:{controls:()=>u,disabled:()=>d.value,expanded:()=>String(C.value),haspopup:`menu`}},{target:g}),n=e=>{e.stopPropagation(),!d.value&&k()},r=e=>{P(e)};g.addEventListener(`click`,n),g.addEventListener(`keydown`,r),e.push(()=>g?.removeEventListener(`click`,n)),e.push(()=>g?.removeEventListener(`keydown`,r)),y=()=>{t();for(let t of e)t()}}return(0,p.watch)(c.elements(`trigger`),F,{immediate:!0}),(0,f.onMounted)(()=>(F(),()=>{y?.(),y=null})),f.html`
|
|
18
18
|
<slot name="trigger"></slot>
|
|
19
19
|
<div
|
|
20
20
|
class="menu-panel"
|
|
@@ -22,9 +22,9 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
22
22
|
id="${u}"
|
|
23
23
|
role="menu"
|
|
24
24
|
aria-orientation="vertical"
|
|
25
|
-
@keydown="${
|
|
26
|
-
ref="${e=>{
|
|
25
|
+
@keydown="${P}"
|
|
26
|
+
ref="${e=>{v=e,v?.toggleAttribute(`data-open`,C.value)}}">
|
|
27
27
|
<slot></slot>
|
|
28
28
|
</div>
|
|
29
|
-
`},styles:[l.default,e.sizeVariantMixin(c.MENU_SIZE_PRESET),t.forcedColorsMixin]}),exports.MENU_ITEM_TAG=
|
|
29
|
+
`},styles:[l.default,e.sizeVariantMixin(c.MENU_SIZE_PRESET),t.forcedColorsMixin]}),exports.MENU_ITEM_TAG=h,exports.MENU_TAG=y,exports.SEPARATOR_TAG=g;
|
|
30
30
|
//# sourceMappingURL=menu.cjs.map
|
package/dist/menu.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.cjs","names":[],"sources":["../src/overlay/menu/menu.ts"],"sourcesContent":["import type { Placement } from '@vielzeug/orbit';\n\nimport {\n bind,\n createStableId,\n define,\n getHost,\n html,\n onCleanup,\n onMounted,\n prop,\n useEmit,\n useSlots,\n watchEffect,\n} from '@vielzeug/ore';\nimport { computed, watch as rippleWatch, signal } from '@vielzeug/ripple';\nimport {\n createDropdownPositioner,\n createInteraction,\n createListControl,\n createOutsidePointerDismissal,\n type DropdownCloseReason,\n lifecycleSignal,\n type OverlayOpenChangeDetail,\n type OverlayOpenReason,\n restoreTriggerFocus,\n} from '../../core';\nimport { disablableBundle, MENU_SIZE_PRESET, sizableBundle } from '../../shared';\nimport { colorThemeMixin, forcedColorsMixin, sizeVariantMixin } from '../../styles';\nimport type { ComponentSize } from '../../types';\nimport componentStyles from './menu.css?inline';\nimport menuItemStyles from './menu-item.css?inline';\nimport menuSeparatorStyles from './menu-separator.css?inline';\n\n// ── Types ─────────────────────────────────────────────────────────────\n\nexport interface MenuSelectDetail {\n checked?: boolean;\n value: string;\n}\n\nexport type OreMenuItemType = 'checkbox' | 'radio';\n\nexport type OreMenuEvents = {\n 'open-change': OverlayOpenChangeDetail;\n select: MenuSelectDetail;\n};\n\nexport type OreMenuItemProps = {\n checked?: boolean;\n disabled?: boolean;\n type?: OreMenuItemType;\n value?: string;\n};\n\nexport type OreMenuProps = {\n /** Initial uncontrolled open state. Ignored when `open` is set. */\n 'default-open'?: boolean;\n disabled?: boolean;\n /** Controlled open state. */\n open?: boolean;\n placement?: 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end';\n size?: ComponentSize;\n};\n\n// ── Styles ─────────────────────────────────────────────────────────────\n\n// ── Menu Item Component ─────────────────────────────────────────────────────────────\n\n/**\n * A selectable action item used inside `<ore-menu>`.\n *\n * @element ore-menu-item\n *\n * @attr {boolean} checked - Checked state for `checkbox` and `radio` item types\n * @attr {boolean} disabled - Disables selection and pointer interaction\n * @attr {'checkbox'|'radio'} type - Optional checkable menu item mode\n * @attr {string} value - Value emitted by parent menu on selection\n *\n * @slot - Item label/content\n * @slot icon - Optional leading icon content\n *\n * @cssprop --menu-item-hover-bg - Background on hover\n * @cssprop --menu-item-focus-color - Text color when keyboard-focused\n * @cssprop --menu-item-focus-bg - Background when keyboard-focused\n * @cssprop --menu-item-selection-bg - Background for checkbox/radio items (unselected)\n * @cssprop --menu-item-checked-color - Text color when checked\n * @cssprop --menu-item-checked-bg - Background when checked\n *\n * @part item - Root item container element.\n * @part item-label - Label text container.\n * @part icon-slot - Leading icon slot container.\n *\n * @example\n * ```html\n * <ore-menu-item value=\"edit\">Edit</ore-menu-item>\n * <ore-menu-item value=\"delete\" disabled>Delete</ore-menu-item>\n * <ore-menu-item type=\"checkbox\" value=\"wrap\" checked>Word wrap</ore-menu-item>\n * <ore-menu-item type=\"radio\" value=\"left\">Align left</ore-menu-item>\n * ```\n */\nexport const MENU_ITEM_TAG = 'ore-menu-item' as const;\ndefine<OreMenuItemProps>(MENU_ITEM_TAG, {\n props: {\n checked: prop.bool(false),\n disabled: prop.bool(false),\n type: prop.string<OreMenuItemType>(),\n value: prop.string(),\n },\n setup(props) {\n const isCheckable = () => props.type.value === 'checkbox' || props.type.value === 'radio';\n const isChecked = () => isCheckable() && props.checked.value;\n const itemRole = () => {\n if (props.type.value === 'checkbox') return 'menuitemcheckbox';\n\n if (props.type.value === 'radio') return 'menuitemradio';\n\n return 'menuitem';\n };\n const itemClass = () => {\n const type = props.type.value;\n\n return [\n 'item',\n type === 'checkbox' ? 'is-checkbox' : '',\n type === 'radio' ? 'is-radio' : '',\n isChecked() ? 'is-checked' : '',\n ]\n .filter(Boolean)\n .join(' ');\n };\n\n return isCheckable()\n ? html`\n <div\n class=\"${itemClass}\"\n tabindex=\"-1\"\n role=\"${itemRole}\"\n aria-checked=\"${() => String(isChecked())}\"\n aria-disabled=\"${props.disabled}\">\n <span class=\"item-check\" aria-hidden=\"true\"></span>\n <span class=\"icon-slot\"><slot name=\"icon\"></slot></span>\n <span class=\"item-label\"><slot></slot></span>\n </div>\n `\n : html`\n <div class=\"item\" tabindex=\"-1\" role=\"menuitem\" aria-disabled=\"${props.disabled}\">\n <span class=\"icon-slot\"><slot name=\"icon\"></slot></span>\n <span class=\"item-label\"><slot></slot></span>\n </div>\n `;\n },\n styles: [colorThemeMixin, menuItemStyles],\n});\n\n// ── Menu Separator ─────────────────────────────────────────────────────────────\n\n/**\n * Visual separator used to group menu items inside `<ore-menu>`.\n *\n * @element ore-menu-separator\n *\n * @example\n * ```html\n * <ore-menu-item value=\"cut\">Cut</ore-menu-item>\n * <ore-menu-separator></ore-menu-separator>\n * <ore-menu-item value=\"paste\">Paste</ore-menu-item>\n * ```\n */\nexport const SEPARATOR_TAG = 'ore-menu-separator' as const;\ndefine(SEPARATOR_TAG, {\n setup() {\n return html``;\n },\n styles: [menuSeparatorStyles],\n});\n\n// ── Menu Component ─────────────────────────────────────────────────────────────\n\nconst isCheckableItemType = (value: string | null): value is OreMenuItemType =>\n value === 'checkbox' || value === 'radio';\n\nconst parseOptionalBool = (value: string | null): boolean | undefined =>\n value == null ? undefined : value === '' || value === 'true';\n\n/**\n * Action dropdown menu triggered by a slotted trigger element.\n *\n * @element ore-menu\n * @element ore-menu-item - Clickable menu option (place in default slot)\n * @element ore-menu-separator - Visual divider between menu groups\n *\n * @attr {boolean} disabled - Disables opening and keyboard interaction\n * @attr {boolean} open - Controlled open state\n * @attr {boolean} default-open - Initial uncontrolled open state\n * @attr {string} placement - Panel placement: 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end' (default: 'bottom-start')\n * @attr {string} size - Size: 'sm' | 'md' | 'lg'\n *\n * @fires open-change - Fired when the menu state changes. detail: { open, reason }\n * @fires select - Fired when an item is selected. detail: { value: string, checked?: boolean }\n *\n * @slot trigger - Trigger element that toggles menu visibility\n * @slot - Menu content (`<ore-menu-item>` and `<ore-menu-separator>`)\n *\n * @part panel - Floating menu panel container\n *\n * @cssprop --menu-panel-bg - Background of the floating panel\n * @cssprop --menu-panel-border-color - Border color of the floating panel\n * @cssprop --menu-panel-shadow - Box shadow of the floating panel\n * @cssprop --menu-panel-blur - Backdrop blur amount for the floating panel\n * @cssprop --menu-panel-min-width - Minimum width of the floating panel\n * @cssprop --menu-panel-max-height - Maximum height of the floating panel before it scrolls\n * @cssprop --menu-panel-radius - Border radius of the floating panel\n *\n * @example\n * ```html\n * <ore-menu>\n * <button slot=\"trigger\">Actions</button>\n * <ore-menu-item value=\"edit\">Edit</ore-menu-item>\n * <ore-menu-item value=\"delete\">Delete</ore-menu-item>\n * </ore-menu>\n * ```\n */\nexport const MENU_TAG = 'ore-menu' as const;\ndefine<OreMenuProps>(MENU_TAG, {\n props: {\n ...sizableBundle,\n ...disablableBundle,\n 'default-open': prop.bool(false),\n open: { default: undefined as boolean | undefined, parse: parseOptionalBool },\n placement: prop.oneOf(\n ['bottom', 'bottom-start', 'bottom-end', 'top', 'top-start', 'top-end'] as const,\n 'bottom-start',\n ),\n },\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreMenuEvents>();\n const slots = useSlots();\n const watch = watchEffect;\n\n const menuId = createStableId('menu');\n const isDisabled = computed(() => Boolean(props.disabled.value));\n const abortSignal = lifecycleSignal(onCleanup);\n let triggerEl: HTMLElement | null = null;\n let panelEl: HTMLElement | null = null;\n let cleanupTrigger: (() => void) | null = null;\n\n // ── Helpers ───────────────────────────────────────────────────────────────\n function getItems(): HTMLElement[] {\n return Array.from(el.querySelectorAll<HTMLElement>('ore-menu-item:not([disabled])'));\n }\n\n function getItemFocusable(item: HTMLElement | null | undefined): HTMLElement | null {\n if (!item) return null;\n\n return item.shadowRoot?.querySelector<HTMLElement>('[role^=\"menuitem\"]') ?? item;\n }\n\n function getFocusedItemIndex(): number {\n const items = getItems();\n\n return items.findIndex((item) => {\n const focusable = getItemFocusable(item);\n\n return item === document.activeElement || focusable === document.activeElement;\n });\n }\n\n const isOpenSignal = signal(false);\n let stopPositioning: (() => void) | null = null;\n const positioner = createDropdownPositioner({\n getFloating: () => panelEl,\n getPlacement: () => (props.placement.value ?? 'bottom-start') as Placement,\n getReference: () => triggerEl,\n matchWidth: false,\n offsetPx: 4,\n padding: 6,\n });\n const list = createListControl<HTMLElement>({\n disabled: computed(() => !isOpenSignal.value),\n getItems: getItems,\n isItemDisabled: (item) => item.hasAttribute('disabled'),\n onNavigate: (_action, index) => {\n const nextItem = getItems()[index];\n\n getItemFocusable(nextItem)?.focus();\n },\n signal: abortSignal,\n });\n\n const close = (reason: DropdownCloseReason = 'programmatic', shouldRestoreFocus = true): void => {\n if (!isOpenSignal.value) return;\n\n isOpenSignal.value = false;\n list.reset();\n stopPositioning?.();\n stopPositioning = null;\n\n if (shouldRestoreFocus) restoreTriggerFocus(() => triggerEl);\n\n emit('open-change', { open: false, reason });\n };\n\n const open = (reason: OverlayOpenReason = 'programmatic'): void => {\n if (isDisabled.value || isOpenSignal.value) return;\n\n isOpenSignal.value = true;\n positioner.update();\n stopPositioning = positioner.startAutoUpdate?.() ?? null;\n emit('open-change', { open: true, reason });\n };\n\n const toggle = (): void => {\n if (isOpenSignal.value) close('trigger');\n else open('click');\n };\n\n createOutsidePointerDismissal({\n getTargets: () => [el, panelEl],\n isActive: () => isOpenSignal.value,\n onDismiss: () => close('outsideClick'),\n signal: abortSignal,\n });\n\n let initialized = false;\n\n rippleWatch(\n props.open,\n (value) => {\n if (value === undefined) {\n if (!initialized) {\n if (props['default-open'].value) open('programmatic');\n } else {\n close('programmatic');\n }\n } else if (value) {\n open('programmatic');\n } else {\n close('programmatic');\n }\n\n initialized = true;\n },\n { immediate: true },\n );\n abortSignal.addEventListener(\n 'abort',\n () => {\n if (!isOpenSignal.value) return;\n\n isOpenSignal.value = false;\n list.reset();\n stopPositioning?.();\n stopPositioning = null;\n },\n { once: true },\n );\n\n const activateItem = (item: HTMLElement): void => {\n const type = item.getAttribute('type');\n const isCheckable = isCheckableItemType(type);\n\n if (type === 'checkbox') {\n item.toggleAttribute('checked', !item.hasAttribute('checked'));\n } else if (type === 'radio') {\n for (const radio of el.querySelectorAll<HTMLElement>('ore-menu-item[type=\"radio\"]')) {\n radio.toggleAttribute('checked', radio === item);\n }\n }\n\n const value = item.getAttribute('value') ?? '';\n const checked = isCheckable ? item.hasAttribute('checked') : undefined;\n\n emit('select', { checked, value });\n\n if (!isCheckable) {\n close('programmatic');\n }\n };\n\n const openFromKeyboardPress = createInteraction({\n keys: ['Enter', ' ', 'ArrowDown'],\n onPress: () => {\n open('keyboard');\n requestAnimationFrame(() => list.set(0));\n },\n });\n\n const activateFocusedFromKeyboardPress = createInteraction({\n onPress: () => {\n const focused = list.getActiveItem();\n\n if (focused) activateItem(focused);\n },\n });\n\n // ── Keyboard Navigation ───────────────────────────────────────────────────\n function handleMenuKeydown(e: KeyboardEvent) {\n if (isDisabled.value) return;\n\n const open = isOpenSignal.value;\n\n // When closed: open on Enter / Space / ArrowDown\n if (!open) {\n openFromKeyboardPress.handleKeydown(e);\n\n return;\n }\n\n const currentFocusedIndex = getFocusedItemIndex();\n\n if (currentFocusedIndex >= 0) list.set(currentFocusedIndex);\n\n if (e.key === 'Escape') {\n e.preventDefault();\n close('escape');\n\n return;\n }\n\n if (list.handleKeydown(e)) return;\n\n // When open: navigate and activate\n if (e.key === ' ' || e.key === 'Enter') {\n activateFocusedFromKeyboardPress.handleKeydown(e);\n\n return;\n }\n\n if (e.key === 'Tab') {\n close('programmatic');\n }\n }\n\n // ── Lifecycle ─────────────────────────────────────────────────────────────\n bind({\n on: {\n click: (e: MouseEvent) => {\n const path = e.composedPath();\n\n if (!isOpenSignal.value) return;\n\n const itemFromPath = path.find(\n (node): node is HTMLElement => node instanceof HTMLElement && node.tagName === 'ORE-MENU-ITEM',\n );\n const item = itemFromPath ?? (e.target as HTMLElement | null)?.closest<HTMLElement>('ore-menu-item') ?? null;\n\n if (!item || item.hasAttribute('disabled')) return;\n\n activateItem(item);\n },\n },\n });\n\n watch(() => {\n const open = isOpenSignal.value;\n\n if (!panelEl) return;\n\n panelEl.toggleAttribute('data-open', open);\n });\n\n function resolveTrigger() {\n cleanupTrigger?.();\n cleanupTrigger = null;\n\n const assigned = slots.elements('trigger').value;\n\n triggerEl = (assigned?.[0] as HTMLElement | undefined) ?? null;\n\n if (!triggerEl) return;\n\n const cleanups: Array<() => void> = [];\n const removeAria = bind(\n {\n aria: {\n controls: () => menuId,\n disabled: () => isDisabled.value,\n expanded: () => String(isOpenSignal.value),\n haspopup: 'menu',\n },\n },\n { target: triggerEl },\n );\n\n const onTriggerClick = (event: MouseEvent) => {\n event.stopPropagation();\n\n if (isDisabled.value) return;\n\n toggle();\n };\n const onTriggerKeydown = (event: KeyboardEvent) => {\n handleMenuKeydown(event);\n };\n\n triggerEl.addEventListener('click', onTriggerClick);\n triggerEl.addEventListener('keydown', onTriggerKeydown);\n cleanups.push(() => triggerEl?.removeEventListener('click', onTriggerClick));\n cleanups.push(() => triggerEl?.removeEventListener('keydown', onTriggerKeydown));\n\n cleanupTrigger = () => {\n removeAria();\n\n for (const cleanup of cleanups) cleanup();\n };\n }\n\n rippleWatch(slots.elements('trigger'), resolveTrigger, { immediate: true });\n\n onMounted(() => {\n resolveTrigger();\n\n return () => {\n cleanupTrigger?.();\n cleanupTrigger = null;\n };\n });\n\n return html`\n <slot name=\"trigger\"></slot>\n <div\n class=\"menu-panel\"\n part=\"panel\"\n id=\"${menuId}\"\n role=\"menu\"\n aria-orientation=\"vertical\"\n @keydown=\"${handleMenuKeydown}\"\n ref=\"${(el: HTMLElement | null) => {\n panelEl = el;\n panelEl?.toggleAttribute('data-open', isOpenSignal.value);\n }}\">\n <slot></slot>\n </div>\n `;\n },\n styles: [componentStyles, sizeVariantMixin(MENU_SIZE_PRESET), forcedColorsMixin],\n});\n"],"mappings":"glBAqGA,IAAa,EAAgB,iBAC7B,EAAA,EAAA,OAAA,CAAyB,EAAe,CACtC,MAAO,CACL,QAAS,EAAA,KAAK,KAAK,EAAK,EACxB,SAAU,EAAA,KAAK,KAAK,EAAK,EACzB,KAAM,EAAA,KAAK,OAAwB,EACnC,MAAO,EAAA,KAAK,OAAO,CACrB,EACA,MAAM,EAAO,CACX,IAAM,MAAoB,EAAM,KAAK,QAAU,YAAc,EAAM,KAAK,QAAU,QAC5E,MAAkB,EAAY,GAAK,EAAM,QAAQ,MAqBvD,OAAO,EAAY,EACf,EAAA,IAAI;;yBAdgB,CACtB,IAAM,EAAO,EAAM,KAAK,MAExB,MAAO,CACL,OACA,IAAS,WAAa,cAAgB,GACtC,IAAS,QAAU,WAAa,GAChC,EAAU,EAAI,aAAe,EAC/B,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,CACb,EAK2B;;wBAtBrB,EAAM,KAAK,QAAU,WAAmB,mBAExC,EAAM,KAAK,QAAU,QAAgB,gBAElC,WAoBgB;gCACK,OAAO,EAAU,CAAC,EAAE;6BACzB,EAAM,SAAS;;;;;UAMpC,EAAA,IAAI;2EAC+D,EAAM,SAAS;;;;SAKxF,EACA,OAAQ,CAAC,EAAA,gBAAiB,EAAA,OAAc,CAC1C,CAAC,EAgBD,IAAa,EAAgB,sBAC7B,EAAA,EAAA,OAAA,CAAO,EAAe,CACpB,OAAQ,CACN,MAAO,GAAA,IAAI,EACb,EACA,OAAQ,CAAC,EAAA,OAAmB,CAC9B,CAAC,EAID,IAAM,EAAuB,GAC3B,IAAU,YAAc,IAAU,QAE9B,EAAq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A,iBAAiB,EAAA,gBAAgB,EAAG,EAAA,iBAAiB,CACjF,CAAC"}
|
|
1
|
+
{"version":3,"file":"menu.cjs","names":[],"sources":["../src/overlay/menu/menu.ts"],"sourcesContent":["import { restoreFocus } from '@vielzeug/focus';\nimport type { Placement } from '@vielzeug/orbit';\nimport {\n bind,\n createStableId,\n define,\n getHost,\n html,\n onCleanup,\n onMounted,\n prop,\n useEmit,\n useSlots,\n watchEffect,\n} from '@vielzeug/ore';\nimport { computed, watch as rippleWatch, signal } from '@vielzeug/ripple';\nimport {\n createDropdownPositioner,\n createInteraction,\n createListControl,\n createOutsidePointerDismissal,\n type DropdownCloseReason,\n lifecycleSignal,\n type OverlayOpenChangeDetail,\n type OverlayOpenReason,\n} from '../../core';\nimport { disablableBundle, MENU_SIZE_PRESET, sizableBundle } from '../../shared';\nimport { colorThemeMixin, forcedColorsMixin, sizeVariantMixin } from '../../styles';\nimport type { ComponentSize } from '../../types';\nimport componentStyles from './menu.css?inline';\nimport menuItemStyles from './menu-item.css?inline';\nimport menuSeparatorStyles from './menu-separator.css?inline';\n\n// ── Types ─────────────────────────────────────────────────────────────\n\nexport interface MenuSelectDetail {\n checked?: boolean;\n value: string;\n}\n\nexport type OreMenuItemType = 'checkbox' | 'radio';\n\nexport type OreMenuEvents = {\n 'open-change': OverlayOpenChangeDetail;\n select: MenuSelectDetail;\n};\n\nexport type OreMenuItemProps = {\n checked?: boolean;\n disabled?: boolean;\n type?: OreMenuItemType;\n value?: string;\n};\n\nexport type OreMenuProps = {\n /** Initial uncontrolled open state. Ignored when `open` is set. */\n 'default-open'?: boolean;\n disabled?: boolean;\n /** Controlled open state. */\n open?: boolean;\n placement?: 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end';\n size?: ComponentSize;\n};\n\n// ── Styles ─────────────────────────────────────────────────────────────\n\n// ── Menu Item Component ─────────────────────────────────────────────────────────────\n\n/**\n * A selectable action item used inside `<ore-menu>`.\n *\n * @element ore-menu-item\n *\n * @attr {boolean} checked - Checked state for `checkbox` and `radio` item types\n * @attr {boolean} disabled - Disables selection and pointer interaction\n * @attr {'checkbox'|'radio'} type - Optional checkable menu item mode\n * @attr {string} value - Value emitted by parent menu on selection\n *\n * @slot - Item label/content\n * @slot icon - Optional leading icon content\n *\n * @cssprop --menu-item-hover-bg - Background on hover\n * @cssprop --menu-item-focus-color - Text color when keyboard-focused\n * @cssprop --menu-item-focus-bg - Background when keyboard-focused\n * @cssprop --menu-item-selection-bg - Background for checkbox/radio items (unselected)\n * @cssprop --menu-item-checked-color - Text color when checked\n * @cssprop --menu-item-checked-bg - Background when checked\n *\n * @part item - Root item container element.\n * @part item-label - Label text container.\n * @part icon-slot - Leading icon slot container.\n *\n * @example\n * ```html\n * <ore-menu-item value=\"edit\">Edit</ore-menu-item>\n * <ore-menu-item value=\"delete\" disabled>Delete</ore-menu-item>\n * <ore-menu-item type=\"checkbox\" value=\"wrap\" checked>Word wrap</ore-menu-item>\n * <ore-menu-item type=\"radio\" value=\"left\">Align left</ore-menu-item>\n * ```\n */\nexport const MENU_ITEM_TAG = 'ore-menu-item' as const;\ndefine<OreMenuItemProps>(MENU_ITEM_TAG, {\n props: {\n checked: prop.bool(false),\n disabled: prop.bool(false),\n type: prop.string<OreMenuItemType>(),\n value: prop.string(),\n },\n setup(props) {\n const isCheckable = () => props.type.value === 'checkbox' || props.type.value === 'radio';\n const isChecked = () => isCheckable() && props.checked.value;\n const itemRole = () => {\n if (props.type.value === 'checkbox') return 'menuitemcheckbox';\n\n if (props.type.value === 'radio') return 'menuitemradio';\n\n return 'menuitem';\n };\n const itemClass = () => {\n const type = props.type.value;\n\n return [\n 'item',\n type === 'checkbox' ? 'is-checkbox' : '',\n type === 'radio' ? 'is-radio' : '',\n isChecked() ? 'is-checked' : '',\n ]\n .filter(Boolean)\n .join(' ');\n };\n\n return isCheckable()\n ? html`\n <div\n class=\"${itemClass}\"\n tabindex=\"-1\"\n role=\"${itemRole}\"\n aria-checked=\"${() => String(isChecked())}\"\n aria-disabled=\"${props.disabled}\">\n <span class=\"item-check\" aria-hidden=\"true\"></span>\n <span class=\"icon-slot\"><slot name=\"icon\"></slot></span>\n <span class=\"item-label\"><slot></slot></span>\n </div>\n `\n : html`\n <div class=\"item\" tabindex=\"-1\" role=\"menuitem\" aria-disabled=\"${props.disabled}\">\n <span class=\"icon-slot\"><slot name=\"icon\"></slot></span>\n <span class=\"item-label\"><slot></slot></span>\n </div>\n `;\n },\n styles: [colorThemeMixin, menuItemStyles],\n});\n\n// ── Menu Separator ─────────────────────────────────────────────────────────────\n\n/**\n * Visual separator used to group menu items inside `<ore-menu>`.\n *\n * @element ore-menu-separator\n *\n * @example\n * ```html\n * <ore-menu-item value=\"cut\">Cut</ore-menu-item>\n * <ore-menu-separator></ore-menu-separator>\n * <ore-menu-item value=\"paste\">Paste</ore-menu-item>\n * ```\n */\nexport const SEPARATOR_TAG = 'ore-menu-separator' as const;\ndefine(SEPARATOR_TAG, {\n setup() {\n return html``;\n },\n styles: [menuSeparatorStyles],\n});\n\n// ── Menu Component ─────────────────────────────────────────────────────────────\n\nconst isCheckableItemType = (value: string | null): value is OreMenuItemType =>\n value === 'checkbox' || value === 'radio';\n\nconst parseOptionalBool = (value: string | null): boolean | undefined =>\n value == null ? undefined : value === '' || value === 'true';\n\n/**\n * Action dropdown menu triggered by a slotted trigger element.\n *\n * @element ore-menu\n * @element ore-menu-item - Clickable menu option (place in default slot)\n * @element ore-menu-separator - Visual divider between menu groups\n *\n * @attr {boolean} disabled - Disables opening and keyboard interaction\n * @attr {boolean} open - Controlled open state\n * @attr {boolean} default-open - Initial uncontrolled open state\n * @attr {string} placement - Panel placement: 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end' (default: 'bottom-start')\n * @attr {string} size - Size: 'sm' | 'md' | 'lg'\n *\n * @fires open-change - Fired when the menu state changes. detail: { open, reason }\n * @fires select - Fired when an item is selected. detail: { value: string, checked?: boolean }\n *\n * @slot trigger - Trigger element that toggles menu visibility\n * @slot - Menu content (`<ore-menu-item>` and `<ore-menu-separator>`)\n *\n * @part panel - Floating menu panel container\n *\n * @cssprop --menu-panel-bg - Background of the floating panel\n * @cssprop --menu-panel-border-color - Border color of the floating panel\n * @cssprop --menu-panel-shadow - Box shadow of the floating panel\n * @cssprop --menu-panel-blur - Backdrop blur amount for the floating panel\n * @cssprop --menu-panel-min-width - Minimum width of the floating panel\n * @cssprop --menu-panel-max-height - Maximum height of the floating panel before it scrolls\n * @cssprop --menu-panel-radius - Border radius of the floating panel\n *\n * @example\n * ```html\n * <ore-menu>\n * <button slot=\"trigger\">Actions</button>\n * <ore-menu-item value=\"edit\">Edit</ore-menu-item>\n * <ore-menu-item value=\"delete\">Delete</ore-menu-item>\n * </ore-menu>\n * ```\n */\nexport const MENU_TAG = 'ore-menu' as const;\ndefine<OreMenuProps>(MENU_TAG, {\n props: {\n ...sizableBundle,\n ...disablableBundle,\n 'default-open': prop.bool(false),\n open: { default: undefined as boolean | undefined, parse: parseOptionalBool },\n placement: prop.oneOf(\n ['bottom', 'bottom-start', 'bottom-end', 'top', 'top-start', 'top-end'] as const,\n 'bottom-start',\n ),\n },\n setup(props) {\n const el = getHost();\n const emit = useEmit<OreMenuEvents>();\n const slots = useSlots();\n const watch = watchEffect;\n\n const menuId = createStableId('menu');\n const isDisabled = computed(() => Boolean(props.disabled.value));\n const abortSignal = lifecycleSignal(onCleanup);\n let triggerEl: HTMLElement | null = null;\n let panelEl: HTMLElement | null = null;\n let cleanupTrigger: (() => void) | null = null;\n\n // ── Helpers ───────────────────────────────────────────────────────────────\n function getItems(): HTMLElement[] {\n return Array.from(el.querySelectorAll<HTMLElement>('ore-menu-item:not([disabled])'));\n }\n\n function getItemFocusable(item: HTMLElement | null | undefined): HTMLElement | null {\n if (!item) return null;\n\n return item.shadowRoot?.querySelector<HTMLElement>('[role^=\"menuitem\"]') ?? item;\n }\n\n function getFocusedItemIndex(): number {\n const items = getItems();\n\n return items.findIndex((item) => {\n const focusable = getItemFocusable(item);\n\n return item === document.activeElement || focusable === document.activeElement;\n });\n }\n\n const isOpenSignal = signal(false);\n let stopPositioning: (() => void) | null = null;\n const positioner = createDropdownPositioner({\n getFloating: () => panelEl,\n getPlacement: () => (props.placement.value ?? 'bottom-start') as Placement,\n getReference: () => triggerEl,\n matchWidth: false,\n offsetPx: 4,\n padding: 6,\n });\n const list = createListControl<HTMLElement>({\n disabled: computed(() => !isOpenSignal.value),\n getItems: getItems,\n isItemDisabled: (item) => item.hasAttribute('disabled'),\n onNavigate: ({ item }) => {\n getItemFocusable(item)?.focus();\n },\n signal: abortSignal,\n });\n\n const close = (reason: DropdownCloseReason = 'programmatic', shouldRestoreFocus = true): void => {\n if (!isOpenSignal.value) return;\n\n isOpenSignal.value = false;\n list.reset();\n stopPositioning?.();\n stopPositioning = null;\n\n if (shouldRestoreFocus) restoreFocus(() => triggerEl);\n\n emit('open-change', { open: false, reason });\n };\n\n const open = (reason: OverlayOpenReason = 'programmatic'): void => {\n if (isDisabled.value || isOpenSignal.value) return;\n\n isOpenSignal.value = true;\n positioner.update();\n stopPositioning = positioner.startAutoUpdate?.() ?? null;\n emit('open-change', { open: true, reason });\n };\n\n const toggle = (): void => {\n if (isOpenSignal.value) close('trigger');\n else open('click');\n };\n\n createOutsidePointerDismissal({\n getTargets: () => [el, panelEl],\n isActive: () => isOpenSignal.value,\n onDismiss: () => close('outsideClick'),\n signal: abortSignal,\n });\n\n let initialized = false;\n\n rippleWatch(\n props.open,\n (value) => {\n if (value === undefined) {\n if (!initialized) {\n if (props['default-open'].value) open('programmatic');\n } else {\n close('programmatic');\n }\n } else if (value) {\n open('programmatic');\n } else {\n close('programmatic');\n }\n\n initialized = true;\n },\n { immediate: true },\n );\n abortSignal.addEventListener(\n 'abort',\n () => {\n if (!isOpenSignal.value) return;\n\n isOpenSignal.value = false;\n list.reset();\n stopPositioning?.();\n stopPositioning = null;\n },\n { once: true },\n );\n\n const activateItem = (item: HTMLElement): void => {\n const type = item.getAttribute('type');\n const isCheckable = isCheckableItemType(type);\n\n if (type === 'checkbox') {\n item.toggleAttribute('checked', !item.hasAttribute('checked'));\n } else if (type === 'radio') {\n for (const radio of el.querySelectorAll<HTMLElement>('ore-menu-item[type=\"radio\"]')) {\n radio.toggleAttribute('checked', radio === item);\n }\n }\n\n const value = item.getAttribute('value') ?? '';\n const checked = isCheckable ? item.hasAttribute('checked') : undefined;\n\n emit('select', { checked, value });\n\n if (!isCheckable) {\n close('programmatic');\n }\n };\n\n const openFromKeyboardPress = createInteraction({\n keys: ['Enter', ' ', 'ArrowDown'],\n onPress: () => {\n open('keyboard');\n requestAnimationFrame(() => list.set(0));\n },\n });\n\n const activateFocusedFromKeyboardPress = createInteraction({\n onPress: () => {\n const focused = list.getActiveItem();\n\n if (focused) activateItem(focused);\n },\n });\n\n // ── Keyboard Navigation ───────────────────────────────────────────────────\n function handleMenuKeydown(e: KeyboardEvent) {\n if (isDisabled.value) return;\n\n const open = isOpenSignal.value;\n\n // When closed: open on Enter / Space / ArrowDown\n if (!open) {\n openFromKeyboardPress.handleKeydown(e);\n\n return;\n }\n\n const currentFocusedIndex = getFocusedItemIndex();\n\n if (currentFocusedIndex >= 0) list.set(currentFocusedIndex);\n\n if (e.key === 'Escape') {\n e.preventDefault();\n close('escape');\n\n return;\n }\n\n if (list.handleKeydown(e)) return;\n\n // When open: navigate and activate\n if (e.key === ' ' || e.key === 'Enter') {\n activateFocusedFromKeyboardPress.handleKeydown(e);\n\n return;\n }\n\n if (e.key === 'Tab') {\n close('programmatic');\n }\n }\n\n // ── Lifecycle ─────────────────────────────────────────────────────────────\n bind({\n on: {\n click: (e: MouseEvent) => {\n const path = e.composedPath();\n\n if (!isOpenSignal.value) return;\n\n const itemFromPath = path.find(\n (node): node is HTMLElement => node instanceof HTMLElement && node.tagName === 'ORE-MENU-ITEM',\n );\n const item = itemFromPath ?? (e.target as HTMLElement | null)?.closest<HTMLElement>('ore-menu-item') ?? null;\n\n if (!item || item.hasAttribute('disabled')) return;\n\n activateItem(item);\n },\n },\n });\n\n watch(() => {\n const open = isOpenSignal.value;\n\n if (!panelEl) return;\n\n panelEl.toggleAttribute('data-open', open);\n });\n\n function resolveTrigger() {\n cleanupTrigger?.();\n cleanupTrigger = null;\n\n const assigned = slots.elements('trigger').value;\n\n triggerEl = (assigned?.[0] as HTMLElement | undefined) ?? null;\n\n if (!triggerEl) return;\n\n const cleanups: Array<() => void> = [];\n const removeAria = bind(\n {\n aria: {\n controls: () => menuId,\n disabled: () => isDisabled.value,\n expanded: () => String(isOpenSignal.value),\n haspopup: 'menu',\n },\n },\n { target: triggerEl },\n );\n\n const onTriggerClick = (event: MouseEvent) => {\n event.stopPropagation();\n\n if (isDisabled.value) return;\n\n toggle();\n };\n const onTriggerKeydown = (event: KeyboardEvent) => {\n handleMenuKeydown(event);\n };\n\n triggerEl.addEventListener('click', onTriggerClick);\n triggerEl.addEventListener('keydown', onTriggerKeydown);\n cleanups.push(() => triggerEl?.removeEventListener('click', onTriggerClick));\n cleanups.push(() => triggerEl?.removeEventListener('keydown', onTriggerKeydown));\n\n cleanupTrigger = () => {\n removeAria();\n\n for (const cleanup of cleanups) cleanup();\n };\n }\n\n rippleWatch(slots.elements('trigger'), resolveTrigger, { immediate: true });\n\n onMounted(() => {\n resolveTrigger();\n\n return () => {\n cleanupTrigger?.();\n cleanupTrigger = null;\n };\n });\n\n return html`\n <slot name=\"trigger\"></slot>\n <div\n class=\"menu-panel\"\n part=\"panel\"\n id=\"${menuId}\"\n role=\"menu\"\n aria-orientation=\"vertical\"\n @keydown=\"${handleMenuKeydown}\"\n ref=\"${(el: HTMLElement | null) => {\n panelEl = el;\n panelEl?.toggleAttribute('data-open', isOpenSignal.value);\n }}\">\n <slot></slot>\n </div>\n `;\n },\n styles: [componentStyles, sizeVariantMixin(MENU_SIZE_PRESET), forcedColorsMixin],\n});\n"],"mappings":"6mBAoGA,IAAa,EAAgB,iBAC7B,EAAA,EAAA,OAAA,CAAyB,EAAe,C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