@llui/components 0.4.10 → 0.5.1
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/components/accordion.d.ts +13 -13
- package/dist/components/accordion.d.ts.map +1 -1
- package/dist/components/accordion.js +9 -9
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.d.ts +8 -8
- package/dist/components/alert-dialog.d.ts.map +1 -1
- package/dist/components/alert-dialog.js +2 -2
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/angle-slider.d.ts +13 -13
- package/dist/components/angle-slider.d.ts.map +1 -1
- package/dist/components/angle-slider.js +11 -11
- package/dist/components/angle-slider.js.map +1 -1
- package/dist/components/async-list.d.ts +7 -7
- package/dist/components/async-list.d.ts.map +1 -1
- package/dist/components/async-list.js +5 -8
- package/dist/components/async-list.js.map +1 -1
- package/dist/components/avatar.d.ts +9 -9
- package/dist/components/avatar.d.ts.map +1 -1
- package/dist/components/avatar.js +7 -7
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/carousel.d.ts +18 -18
- package/dist/components/carousel.d.ts.map +1 -1
- package/dist/components/carousel.js +12 -12
- package/dist/components/carousel.js.map +1 -1
- package/dist/components/cascade-select.d.ts +12 -12
- package/dist/components/cascade-select.d.ts.map +1 -1
- package/dist/components/cascade-select.js +8 -8
- package/dist/components/cascade-select.js.map +1 -1
- package/dist/components/checkbox.d.ts +14 -14
- package/dist/components/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox.js +12 -12
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/clipboard.d.ts +8 -8
- package/dist/components/clipboard.d.ts.map +1 -1
- package/dist/components/clipboard.js +6 -6
- package/dist/components/clipboard.js.map +1 -1
- package/dist/components/collapsible.d.ts +11 -11
- package/dist/components/collapsible.d.ts.map +1 -1
- package/dist/components/collapsible.js +9 -9
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/color-picker.d.ts +19 -19
- package/dist/components/color-picker.d.ts.map +1 -1
- package/dist/components/color-picker.js +21 -21
- package/dist/components/color-picker.js.map +1 -1
- package/dist/components/combobox.d.ts +25 -25
- package/dist/components/combobox.d.ts.map +1 -1
- package/dist/components/combobox.js +54 -59
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/context-menu.d.ts +14 -14
- package/dist/components/context-menu.d.ts.map +1 -1
- package/dist/components/context-menu.js +15 -19
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/date-input.d.ts +13 -13
- package/dist/components/date-input.d.ts.map +1 -1
- package/dist/components/date-input.js +11 -11
- package/dist/components/date-input.js.map +1 -1
- package/dist/components/date-picker.d.ts +11 -11
- package/dist/components/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker.js +7 -7
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dialog.d.ts +15 -15
- package/dist/components/dialog.d.ts.map +1 -1
- package/dist/components/dialog.js +45 -50
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/drawer.d.ts +13 -13
- package/dist/components/drawer.d.ts.map +1 -1
- package/dist/components/drawer.js +44 -49
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/editable.d.ts +11 -11
- package/dist/components/editable.d.ts.map +1 -1
- package/dist/components/editable.js +9 -9
- package/dist/components/editable.js.map +1 -1
- package/dist/components/file-upload.d.ts +19 -19
- package/dist/components/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload.js +14 -14
- package/dist/components/file-upload.js.map +1 -1
- package/dist/components/floating-panel.d.ts +14 -14
- package/dist/components/floating-panel.d.ts.map +1 -1
- package/dist/components/floating-panel.js +13 -14
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form.d.ts +9 -9
- package/dist/components/form.d.ts.map +1 -1
- package/dist/components/form.js +7 -7
- package/dist/components/form.js.map +1 -1
- package/dist/components/hover-card.d.ts +9 -9
- package/dist/components/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card.js +12 -13
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/image-cropper.d.ts +8 -8
- package/dist/components/image-cropper.d.ts.map +1 -1
- package/dist/components/image-cropper.js +7 -8
- package/dist/components/image-cropper.js.map +1 -1
- package/dist/components/in-view.d.ts +6 -6
- package/dist/components/in-view.d.ts.map +1 -1
- package/dist/components/in-view.js +2 -2
- package/dist/components/in-view.js.map +1 -1
- package/dist/components/listbox.d.ts +16 -16
- package/dist/components/listbox.d.ts.map +1 -1
- package/dist/components/listbox.js +16 -16
- package/dist/components/listbox.js.map +1 -1
- package/dist/components/marquee.d.ts +8 -8
- package/dist/components/marquee.d.ts.map +1 -1
- package/dist/components/marquee.js +8 -11
- package/dist/components/marquee.js.map +1 -1
- package/dist/components/menu.d.ts +15 -15
- package/dist/components/menu.d.ts.map +1 -1
- package/dist/components/menu.js +16 -17
- package/dist/components/menu.js.map +1 -1
- package/dist/components/navigation-menu.d.ts +12 -12
- package/dist/components/navigation-menu.d.ts.map +1 -1
- package/dist/components/navigation-menu.js +8 -8
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/number-input.d.ts +18 -18
- package/dist/components/number-input.d.ts.map +1 -1
- package/dist/components/number-input.js +16 -20
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/pagination.d.ts +13 -13
- package/dist/components/pagination.d.ts.map +1 -1
- package/dist/components/pagination.js +11 -17
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/password-input.d.ts +11 -11
- package/dist/components/password-input.d.ts.map +1 -1
- package/dist/components/password-input.js +11 -11
- package/dist/components/password-input.js.map +1 -1
- package/dist/components/pin-input.d.ts +9 -9
- package/dist/components/pin-input.d.ts.map +1 -1
- package/dist/components/pin-input.js +9 -9
- package/dist/components/pin-input.js.map +1 -1
- package/dist/components/popover.d.ts +11 -11
- package/dist/components/popover.d.ts.map +1 -1
- package/dist/components/popover.js +61 -60
- package/dist/components/popover.js.map +1 -1
- package/dist/components/presence.d.ts +7 -5
- package/dist/components/presence.d.ts.map +1 -1
- package/dist/components/presence.js +5 -3
- package/dist/components/presence.js.map +1 -1
- package/dist/components/progress.d.ts +14 -14
- package/dist/components/progress.d.ts.map +1 -1
- package/dist/components/progress.js +12 -12
- package/dist/components/progress.js.map +1 -1
- package/dist/components/qr-code.d.ts +7 -7
- package/dist/components/qr-code.d.ts.map +1 -1
- package/dist/components/qr-code.js +7 -7
- package/dist/components/qr-code.js.map +1 -1
- package/dist/components/radio-group.d.ts +15 -15
- package/dist/components/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group.js +12 -13
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/rating-group.d.ts +13 -13
- package/dist/components/rating-group.d.ts.map +1 -1
- package/dist/components/rating-group.js +10 -11
- package/dist/components/rating-group.js.map +1 -1
- package/dist/components/scroll-area.d.ts +10 -10
- package/dist/components/scroll-area.d.ts.map +1 -1
- package/dist/components/scroll-area.js +10 -15
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/select.d.ts +26 -26
- package/dist/components/select.d.ts.map +1 -1
- package/dist/components/select.js +29 -33
- package/dist/components/select.js.map +1 -1
- package/dist/components/signature-pad.d.ts +12 -12
- package/dist/components/signature-pad.d.ts.map +1 -1
- package/dist/components/signature-pad.js +10 -10
- package/dist/components/signature-pad.js.map +1 -1
- package/dist/components/slider.d.ts +22 -22
- package/dist/components/slider.d.ts.map +1 -1
- package/dist/components/slider.js +17 -17
- package/dist/components/slider.js.map +1 -1
- package/dist/components/sortable.d.ts +11 -11
- package/dist/components/sortable.d.ts.map +1 -1
- package/dist/components/sortable.js +20 -20
- package/dist/components/sortable.js.map +1 -1
- package/dist/components/splitter.d.ts +15 -15
- package/dist/components/splitter.d.ts.map +1 -1
- package/dist/components/splitter.js +15 -15
- package/dist/components/splitter.js.map +1 -1
- package/dist/components/steps.d.ts +14 -14
- package/dist/components/steps.d.ts.map +1 -1
- package/dist/components/steps.js +10 -16
- package/dist/components/steps.js.map +1 -1
- package/dist/components/switch.d.ts +12 -12
- package/dist/components/switch.d.ts.map +1 -1
- package/dist/components/switch.js +10 -10
- package/dist/components/switch.js.map +1 -1
- package/dist/components/tabs.d.ts +15 -15
- package/dist/components/tabs.d.ts.map +1 -1
- package/dist/components/tabs.js +11 -11
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags-input.d.ts +14 -14
- package/dist/components/tags-input.d.ts.map +1 -1
- package/dist/components/tags-input.js +10 -10
- package/dist/components/tags-input.js.map +1 -1
- package/dist/components/theme-switch.d.ts +5 -5
- package/dist/components/theme-switch.d.ts.map +1 -1
- package/dist/components/theme-switch.js +3 -3
- package/dist/components/theme-switch.js.map +1 -1
- package/dist/components/time-picker.d.ts +19 -19
- package/dist/components/time-picker.d.ts.map +1 -1
- package/dist/components/time-picker.js +17 -17
- package/dist/components/time-picker.js.map +1 -1
- package/dist/components/timer.d.ts +10 -10
- package/dist/components/timer.d.ts.map +1 -1
- package/dist/components/timer.js +8 -8
- package/dist/components/timer.js.map +1 -1
- package/dist/components/toast.d.ts +8 -8
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +4 -4
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toc.d.ts +12 -12
- package/dist/components/toc.d.ts.map +1 -1
- package/dist/components/toc.js +8 -8
- package/dist/components/toc.js.map +1 -1
- package/dist/components/toggle-group.d.ts +13 -13
- package/dist/components/toggle-group.d.ts.map +1 -1
- package/dist/components/toggle-group.js +9 -9
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.d.ts +8 -8
- package/dist/components/toggle.d.ts.map +1 -1
- package/dist/components/toggle.js +6 -6
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.d.ts +10 -10
- package/dist/components/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip.js +13 -14
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/tour.d.ts +7 -7
- package/dist/components/tour.d.ts.map +1 -1
- package/dist/components/tour.js +5 -5
- package/dist/components/tour.js.map +1 -1
- package/dist/components/tree-view.d.ts +19 -19
- package/dist/components/tree-view.d.ts.map +1 -1
- package/dist/components/tree-view.js +23 -23
- package/dist/components/tree-view.js.map +1 -1
- package/dist/patterns/confirm-dialog.d.ts +4 -4
- package/dist/patterns/confirm-dialog.d.ts.map +1 -1
- package/dist/patterns/confirm-dialog.js +7 -9
- package/dist/patterns/confirm-dialog.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/enter-view.d.ts +0 -73
- package/dist/components/enter-view.d.ts.map +0 -1
- package/dist/components/enter-view.js +0 -51
- package/dist/utils/validators.d.ts +0 -34
- package/dist/utils/validators.d.ts.map +0 -1
- package/dist/utils/validators.js +0 -83
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-cropper.js","sourceRoot":"","sources":["../../src/components/image-cropper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAmE5C,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,SAAS,SAAS,CAAC,IAAc,EAAE,KAAwC;IACzE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAClD,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IACjD,O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,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,CAAA;YAC7D,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;SAC/E;QACD,YAAY,EAAE,CAAC,MAAoB,EAAE,EAAE,CAAC,CAAC;YACvC,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,MAAM;YACrB,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;SAC3F,CAAC;QACF,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,CAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC;YACzE,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,eAAe;YAC5B,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;SACjE;KACF,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA","sourcesContent":["import type { Send } from '@llui/dom'\nimport { useContext, tagSend } from '@llui/dom'\nimport { LocaleContext } from '../locale.js'\nimport type { Locale } from '../locale.js'\n\n/**\n * Image cropper — select a rectangular crop region over an image,\n * optionally constrained to an aspect ratio. The machine tracks the\n * image's natural dimensions, the crop rectangle, and in-progress\n * drag/resize state. The view layer wires pointer events on the crop\n * box and its resize handles.\n *\n * Coordinates are in image-native pixels (0..naturalWidth, 0..naturalHeight).\n * The consumer converts to display pixels using the image's rendered size.\n */\n\nexport type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw'\n\nexport interface CropRect {\n x: number\n y: number\n width: number\n height: number\n}\n\nexport interface ImageCropperState {\n /** Natural dimensions of the source image. */\n image: { width: number; height: number }\n crop: CropRect\n /** Constrain the crop to this aspect ratio (width / height), or null to free-form. */\n aspectRatio: number | null\n minSize: number\n dragging: boolean\n resizing: ResizeHandle | null\n disabled: boolean\n}\n\nexport type ImageCropperMsg =\n /** @humanOnly */\n | { type: 'setImage'; width: number; height: number }\n /** @intent(\"Set the crop rectangle (x/y/width/height in image-native pixels)\") */\n | { type: 'setCrop'; crop: CropRect }\n /** @intent(\"Lock the crop to a specific aspect ratio (width/height), or null for free-form\") */\n | { type: 'setAspectRatio'; ratio: number | null }\n /** @humanOnly */\n | { type: 'dragStart' }\n /** @humanOnly */\n | { type: 'dragMove'; dx: number; dy: number }\n /** @humanOnly */\n | { type: 'dragEnd' }\n /** @humanOnly */\n | { type: 'resizeStart'; handle: ResizeHandle }\n /** @humanOnly */\n | { type: 'resizeMove'; dx: number; dy: number }\n /** @humanOnly */\n | { type: 'resizeEnd' }\n /** @intent(\"Reset the crop to a default selection (full image or aspect-fit)\") */\n | { type: 'reset' }\n /** @intent(\"Set the crop to a maximum-area centered selection\") */\n | { type: 'centerFill' }\n\nexport interface ImageCropperInit {\n image?: { width: number; height: number }\n crop?: CropRect\n aspectRatio?: number | null\n minSize?: number\n disabled?: boolean\n}\n\nfunction clamp(v: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, v))\n}\n\nfunction clampCrop(crop: CropRect, image: { width: number; height: number }): CropRect {\n const width = clamp(crop.width, 0, image.width)\n const height = clamp(crop.height, 0, image.height)\n const x = clamp(crop.x, 0, image.width - width)\n const y = clamp(crop.y, 0, image.height - height)\n return { x, y, width, height }\n}\n\nfunction enforceAspectRatio(crop: CropRect, ratio: number | null): CropRect {\n if (ratio === null) return crop\n // Keep width; compute height from ratio.\n const height = crop.width / ratio\n return { ...crop, height }\n}\n\n/**\n * Compute the largest centered crop that fits `image` while respecting the\n * aspect ratio (if any).\n */\nexport function centerFill(\n image: { width: number; height: number },\n aspectRatio: number | null,\n): CropRect {\n if (aspectRatio === null) {\n return { x: 0, y: 0, width: image.width, height: image.height }\n }\n const imgRatio = image.width / image.height\n let width: number, height: number\n if (aspectRatio > imgRatio) {\n width = image.width\n height = width / aspectRatio\n } else {\n height = image.height\n width = height * aspectRatio\n }\n return {\n x: (image.width - width) / 2,\n y: (image.height - height) / 2,\n width,\n height,\n }\n}\n\nexport function init(opts: ImageCropperInit = {}): ImageCropperState {\n const image = opts.image ?? { width: 0, height: 0 }\n const aspectRatio = opts.aspectRatio ?? null\n const crop = opts.crop ?? centerFill(image, aspectRatio)\n return {\n image,\n crop: clampCrop(crop, image),\n aspectRatio,\n minSize: opts.minSize ?? 20,\n dragging: false,\n resizing: null,\n disabled: opts.disabled ?? false,\n }\n}\n\nfunction applyResize(\n state: ImageCropperState,\n dx: number,\n dy: number,\n handle: ResizeHandle,\n): ImageCropperState {\n let { x, y, width, height } = state.crop\n if (handle.includes('e')) width += dx\n if (handle.includes('w')) {\n width -= dx\n x += dx\n }\n if (handle.includes('s')) height += dy\n if (handle.includes('n')) {\n height -= dy\n y += dy\n }\n // Aspect ratio: if set, let the axis with the bigger delta drive the\n // other, keeping the handle's corner anchored.\n if (state.aspectRatio !== null) {\n const isHoriz = handle === 'e' || handle === 'w'\n const isVert = handle === 'n' || handle === 's'\n if (isHoriz) {\n const newHeight = width / state.aspectRatio\n // Keep vertical center.\n y = state.crop.y + (state.crop.height - newHeight) / 2\n height = newHeight\n } else if (isVert) {\n const newWidth = height * state.aspectRatio\n x = state.crop.x + (state.crop.width - newWidth) / 2\n width = newWidth\n } else {\n // Corner: use the axis with the larger pointer delta (expressed in\n // width-equivalent units) to drive the other. This keeps the thumb\n // tracking the pointer linearly instead of snapping to whichever\n // current dimension happens to match the aspect ratio closer.\n const dw = width - state.crop.width\n const dh = height - state.crop.height\n const dhAsDw = dh * state.aspectRatio\n if (Math.abs(dw) >= Math.abs(dhAsDw)) {\n // Width leads; derive height, re-anchor top if resizing from north.\n height = width / state.aspectRatio\n if (handle.includes('n')) y = state.crop.y + (state.crop.height - height)\n } else {\n // Height leads; derive width, re-anchor left if resizing from west.\n width = height * state.aspectRatio\n if (handle.includes('w')) x = state.crop.x + (state.crop.width - width)\n }\n }\n }\n // Enforce min size + clamp to image.\n if (width < state.minSize) width = state.minSize\n if (height < state.minSize) height = state.minSize\n return { ...state, crop: clampCrop({ x, y, width, height }, state.image) }\n}\n\nexport function update(\n state: ImageCropperState,\n msg: ImageCropperMsg,\n): [ImageCropperState, never[]] {\n if (state.disabled && msg.type !== 'setImage' && msg.type !== 'reset') {\n return [state, []]\n }\n switch (msg.type) {\n case 'setImage': {\n const image = { width: msg.width, height: msg.height }\n const crop = centerFill(image, state.aspectRatio)\n return [{ ...state, image, crop }, []]\n }\n case 'setCrop':\n return [{ ...state, crop: clampCrop(msg.crop, state.image) }, []]\n case 'setAspectRatio': {\n const next = enforceAspectRatio(state.crop, msg.ratio)\n return [{ ...state, aspectRatio: msg.ratio, crop: clampCrop(next, state.image) }, []]\n }\n case 'dragStart':\n return [{ ...state, dragging: true }, []]\n case 'dragMove': {\n if (!state.dragging) return [state, []]\n const crop = {\n ...state.crop,\n x: state.crop.x + msg.dx,\n y: state.crop.y + msg.dy,\n }\n return [{ ...state, crop: clampCrop(crop, state.image) }, []]\n }\n case 'dragEnd':\n return [{ ...state, dragging: false }, []]\n case 'resizeStart':\n return [{ ...state, resizing: msg.handle }, []]\n case 'resizeMove':\n if (state.resizing === null) return [state, []]\n return [applyResize(state, msg.dx, msg.dy, state.resizing), []]\n case 'resizeEnd':\n return [{ ...state, resizing: null }, []]\n case 'reset':\n case 'centerFill':\n return [{ ...state, crop: centerFill(state.image, state.aspectRatio) }, []]\n }\n}\n\nexport interface ImageCropperParts<S> {\n root: {\n 'data-scope': 'image-cropper'\n 'data-part': 'root'\n 'data-dragging': (s: S) => '' | undefined\n 'data-resizing': (s: S) => '' | undefined\n 'data-disabled': (s: S) => '' | undefined\n }\n image: {\n 'data-scope': 'image-cropper'\n 'data-part': 'image'\n onLoad: (e: Event) => void\n draggable: false\n }\n cropBox: {\n 'data-scope': 'image-cropper'\n 'data-part': 'crop-box'\n style: (s: S) => string\n onPointerDown: (e: PointerEvent) => void\n }\n resizeHandle: (handle: ResizeHandle) => {\n 'data-scope': 'image-cropper'\n 'data-part': 'resize-handle'\n 'data-handle': ResizeHandle\n onPointerDown: (e: PointerEvent) => void\n }\n resetTrigger: {\n type: 'button'\n 'aria-label': string | ((s: S) => string)\n 'data-scope': 'image-cropper'\n 'data-part': 'reset-trigger'\n onClick: (e: MouseEvent) => void\n }\n}\n\nexport interface ConnectOptions {\n resetLabel?: string\n}\n\nexport function connect<S>(\n get: (s: S) => ImageCropperState,\n send: Send<ImageCropperMsg>,\n opts: ConnectOptions = {},\n): ImageCropperParts<S> {\n const locale = useContext<S, Locale>(LocaleContext)\n return {\n root: {\n 'data-scope': 'image-cropper',\n 'data-part': 'root',\n 'data-dragging': (s) => (get(s).dragging ? '' : undefined),\n 'data-resizing': (s) => (get(s).resizing !== null ? '' : undefined),\n 'data-disabled': (s) => (get(s).disabled ? '' : undefined),\n },\n image: {\n 'data-scope': 'image-cropper',\n 'data-part': 'image',\n onLoad: tagSend(send, ['setImage'], (e) => {\n const img = e.target as HTMLImageElement\n send({ type: 'setImage', width: img.naturalWidth, height: img.naturalHeight })\n }),\n draggable: false,\n },\n cropBox: {\n 'data-scope': 'image-cropper',\n 'data-part': 'crop-box',\n style: (s) => {\n const st = get(s)\n if (st.image.width === 0 || st.image.height === 0) return 'display:none;'\n // Express as percentages so the crop box scales with the rendered image.\n const xp = (st.crop.x / st.image.width) * 100\n const yp = (st.crop.y / st.image.height) * 100\n const wp = (st.crop.width / st.image.width) * 100\n const hp = (st.crop.height / st.image.height) * 100\n return `left:${xp}%;top:${yp}%;width:${wp}%;height:${hp}%;`\n },\n onPointerDown: tagSend(send, ['dragStart'], () => send({ type: 'dragStart' })),\n },\n resizeHandle: (handle: ResizeHandle) => ({\n 'data-scope': 'image-cropper',\n 'data-part': 'resize-handle',\n 'data-handle': handle,\n onPointerDown: tagSend(send, ['resizeStart'], () => send({ type: 'resizeStart', handle })),\n }),\n resetTrigger: {\n type: 'button',\n 'aria-label': opts.resetLabel ?? ((s: S) => locale(s).imageCropper.reset),\n 'data-scope': 'image-cropper',\n 'data-part': 'reset-trigger',\n onClick: tagSend(send, ['reset'], () => send({ type: 'reset' })),\n },\n }\n}\n\nexport const imageCropper = { init, update, connect, centerFill }\n"]}
|
|
1
|
+
{"version":3,"file":"image-cropper.js","sourceRoot":"","sources":["../../src/components/image-cropper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAkE5C,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,SAAS,SAAS,CAAC,IAAc,EAAE,KAAwC;IACzE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAClD,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA;IAC/C,MAA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E,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAA;gBACnD,OAAO,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,CAAA;YAC7D,CAAC,CAAC;YACF,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;SAC/E;QACD,YAAY,EAAE,CAAC,MAAoB,EAAE,EAAE,CAAC,CAAC;YACvC,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,MAAM;YACrB,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;SAC3F,CAAC;QACF,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK;YAC1D,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,eAAe;YAC5B,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;SACjE;KACF,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA","sourcesContent":["import type { Send, Signal } from '@llui/dom'\nimport { useContext, tagSend } from '@llui/dom'\nimport { LocaleContext } from '../locale.js'\n\n/**\n * Image cropper — select a rectangular crop region over an image,\n * optionally constrained to an aspect ratio. The machine tracks the\n * image's natural dimensions, the crop rectangle, and in-progress\n * drag/resize state. The view layer wires pointer events on the crop\n * box and its resize handles.\n *\n * Coordinates are in image-native pixels (0..naturalWidth, 0..naturalHeight).\n * The consumer converts to display pixels using the image's rendered size.\n */\n\nexport type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw'\n\nexport interface CropRect {\n x: number\n y: number\n width: number\n height: number\n}\n\nexport interface ImageCropperState {\n /** Natural dimensions of the source image. */\n image: { width: number; height: number }\n crop: CropRect\n /** Constrain the crop to this aspect ratio (width / height), or null to free-form. */\n aspectRatio: number | null\n minSize: number\n dragging: boolean\n resizing: ResizeHandle | null\n disabled: boolean\n}\n\nexport type ImageCropperMsg =\n /** @humanOnly */\n | { type: 'setImage'; width: number; height: number }\n /** @intent(\"Set the crop rectangle (x/y/width/height in image-native pixels)\") */\n | { type: 'setCrop'; crop: CropRect }\n /** @intent(\"Lock the crop to a specific aspect ratio (width/height), or null for free-form\") */\n | { type: 'setAspectRatio'; ratio: number | null }\n /** @humanOnly */\n | { type: 'dragStart' }\n /** @humanOnly */\n | { type: 'dragMove'; dx: number; dy: number }\n /** @humanOnly */\n | { type: 'dragEnd' }\n /** @humanOnly */\n | { type: 'resizeStart'; handle: ResizeHandle }\n /** @humanOnly */\n | { type: 'resizeMove'; dx: number; dy: number }\n /** @humanOnly */\n | { type: 'resizeEnd' }\n /** @intent(\"Reset the crop to a default selection (full image or aspect-fit)\") */\n | { type: 'reset' }\n /** @intent(\"Set the crop to a maximum-area centered selection\") */\n | { type: 'centerFill' }\n\nexport interface ImageCropperInit {\n image?: { width: number; height: number }\n crop?: CropRect\n aspectRatio?: number | null\n minSize?: number\n disabled?: boolean\n}\n\nfunction clamp(v: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, v))\n}\n\nfunction clampCrop(crop: CropRect, image: { width: number; height: number }): CropRect {\n const width = clamp(crop.width, 0, image.width)\n const height = clamp(crop.height, 0, image.height)\n const x = clamp(crop.x, 0, image.width - width)\n const y = clamp(crop.y, 0, image.height - height)\n return { x, y, width, height }\n}\n\nfunction enforceAspectRatio(crop: CropRect, ratio: number | null): CropRect {\n if (ratio === null) return crop\n // Keep width; compute height from ratio.\n const height = crop.width / ratio\n return { ...crop, height }\n}\n\n/**\n * Compute the largest centered crop that fits `image` while respecting the\n * aspect ratio (if any).\n */\nexport function centerFill(\n image: { width: number; height: number },\n aspectRatio: number | null,\n): CropRect {\n if (aspectRatio === null) {\n return { x: 0, y: 0, width: image.width, height: image.height }\n }\n const imgRatio = image.width / image.height\n let width: number, height: number\n if (aspectRatio > imgRatio) {\n width = image.width\n height = width / aspectRatio\n } else {\n height = image.height\n width = height * aspectRatio\n }\n return {\n x: (image.width - width) / 2,\n y: (image.height - height) / 2,\n width,\n height,\n }\n}\n\nexport function init(opts: ImageCropperInit = {}): ImageCropperState {\n const image = opts.image ?? { width: 0, height: 0 }\n const aspectRatio = opts.aspectRatio ?? null\n const crop = opts.crop ?? centerFill(image, aspectRatio)\n return {\n image,\n crop: clampCrop(crop, image),\n aspectRatio,\n minSize: opts.minSize ?? 20,\n dragging: false,\n resizing: null,\n disabled: opts.disabled ?? false,\n }\n}\n\nfunction applyResize(\n state: ImageCropperState,\n dx: number,\n dy: number,\n handle: ResizeHandle,\n): ImageCropperState {\n let { x, y, width, height } = state.crop\n if (handle.includes('e')) width += dx\n if (handle.includes('w')) {\n width -= dx\n x += dx\n }\n if (handle.includes('s')) height += dy\n if (handle.includes('n')) {\n height -= dy\n y += dy\n }\n // Aspect ratio: if set, let the axis with the bigger delta drive the\n // other, keeping the handle's corner anchored.\n if (state.aspectRatio !== null) {\n const isHoriz = handle === 'e' || handle === 'w'\n const isVert = handle === 'n' || handle === 's'\n if (isHoriz) {\n const newHeight = width / state.aspectRatio\n // Keep vertical center.\n y = state.crop.y + (state.crop.height - newHeight) / 2\n height = newHeight\n } else if (isVert) {\n const newWidth = height * state.aspectRatio\n x = state.crop.x + (state.crop.width - newWidth) / 2\n width = newWidth\n } else {\n // Corner: use the axis with the larger pointer delta (expressed in\n // width-equivalent units) to drive the other. This keeps the thumb\n // tracking the pointer linearly instead of snapping to whichever\n // current dimension happens to match the aspect ratio closer.\n const dw = width - state.crop.width\n const dh = height - state.crop.height\n const dhAsDw = dh * state.aspectRatio\n if (Math.abs(dw) >= Math.abs(dhAsDw)) {\n // Width leads; derive height, re-anchor top if resizing from north.\n height = width / state.aspectRatio\n if (handle.includes('n')) y = state.crop.y + (state.crop.height - height)\n } else {\n // Height leads; derive width, re-anchor left if resizing from west.\n width = height * state.aspectRatio\n if (handle.includes('w')) x = state.crop.x + (state.crop.width - width)\n }\n }\n }\n // Enforce min size + clamp to image.\n if (width < state.minSize) width = state.minSize\n if (height < state.minSize) height = state.minSize\n return { ...state, crop: clampCrop({ x, y, width, height }, state.image) }\n}\n\nexport function update(\n state: ImageCropperState,\n msg: ImageCropperMsg,\n): [ImageCropperState, never[]] {\n if (state.disabled && msg.type !== 'setImage' && msg.type !== 'reset') {\n return [state, []]\n }\n switch (msg.type) {\n case 'setImage': {\n const image = { width: msg.width, height: msg.height }\n const crop = centerFill(image, state.aspectRatio)\n return [{ ...state, image, crop }, []]\n }\n case 'setCrop':\n return [{ ...state, crop: clampCrop(msg.crop, state.image) }, []]\n case 'setAspectRatio': {\n const next = enforceAspectRatio(state.crop, msg.ratio)\n return [{ ...state, aspectRatio: msg.ratio, crop: clampCrop(next, state.image) }, []]\n }\n case 'dragStart':\n return [{ ...state, dragging: true }, []]\n case 'dragMove': {\n if (!state.dragging) return [state, []]\n const crop = {\n ...state.crop,\n x: state.crop.x + msg.dx,\n y: state.crop.y + msg.dy,\n }\n return [{ ...state, crop: clampCrop(crop, state.image) }, []]\n }\n case 'dragEnd':\n return [{ ...state, dragging: false }, []]\n case 'resizeStart':\n return [{ ...state, resizing: msg.handle }, []]\n case 'resizeMove':\n if (state.resizing === null) return [state, []]\n return [applyResize(state, msg.dx, msg.dy, state.resizing), []]\n case 'resizeEnd':\n return [{ ...state, resizing: null }, []]\n case 'reset':\n case 'centerFill':\n return [{ ...state, crop: centerFill(state.image, state.aspectRatio) }, []]\n }\n}\n\nexport interface ImageCropperParts {\n root: {\n 'data-scope': 'image-cropper'\n 'data-part': 'root'\n 'data-dragging': Signal<'' | undefined>\n 'data-resizing': Signal<'' | undefined>\n 'data-disabled': Signal<'' | undefined>\n }\n image: {\n 'data-scope': 'image-cropper'\n 'data-part': 'image'\n onLoad: (e: Event) => void\n draggable: false\n }\n cropBox: {\n 'data-scope': 'image-cropper'\n 'data-part': 'crop-box'\n style: Signal<string>\n onPointerDown: (e: PointerEvent) => void\n }\n resizeHandle: (handle: ResizeHandle) => {\n 'data-scope': 'image-cropper'\n 'data-part': 'resize-handle'\n 'data-handle': ResizeHandle\n onPointerDown: (e: PointerEvent) => void\n }\n resetTrigger: {\n type: 'button'\n 'aria-label': string\n 'data-scope': 'image-cropper'\n 'data-part': 'reset-trigger'\n onClick: (e: MouseEvent) => void\n }\n}\n\nexport interface ConnectOptions {\n resetLabel?: string\n}\n\nexport function connect(\n state: Signal<ImageCropperState>,\n send: Send<ImageCropperMsg>,\n opts: ConnectOptions = {},\n): ImageCropperParts {\n const locale = useContext(LocaleContext)\n return {\n root: {\n 'data-scope': 'image-cropper',\n 'data-part': 'root',\n 'data-dragging': state.map((st) => (st.dragging ? '' : undefined)),\n 'data-resizing': state.map((st) => (st.resizing !== null ? '' : undefined)),\n 'data-disabled': state.map((st) => (st.disabled ? '' : undefined)),\n },\n image: {\n 'data-scope': 'image-cropper',\n 'data-part': 'image',\n onLoad: tagSend(send, ['setImage'], (e) => {\n const img = e.target as HTMLImageElement\n send({ type: 'setImage', width: img.naturalWidth, height: img.naturalHeight })\n }),\n draggable: false,\n },\n cropBox: {\n 'data-scope': 'image-cropper',\n 'data-part': 'crop-box',\n style: state.map((st) => {\n if (st.image.width === 0 || st.image.height === 0) return 'display:none;'\n // Express as percentages so the crop box scales with the rendered image.\n const xp = (st.crop.x / st.image.width) * 100\n const yp = (st.crop.y / st.image.height) * 100\n const wp = (st.crop.width / st.image.width) * 100\n const hp = (st.crop.height / st.image.height) * 100\n return `left:${xp}%;top:${yp}%;width:${wp}%;height:${hp}%;`\n }),\n onPointerDown: tagSend(send, ['dragStart'], () => send({ type: 'dragStart' })),\n },\n resizeHandle: (handle: ResizeHandle) => ({\n 'data-scope': 'image-cropper',\n 'data-part': 'resize-handle',\n 'data-handle': handle,\n onPointerDown: tagSend(send, ['resizeStart'], () => send({ type: 'resizeStart', handle })),\n }),\n resetTrigger: {\n type: 'button',\n 'aria-label': opts.resetLabel ?? locale.imageCropper.reset,\n 'data-scope': 'image-cropper',\n 'data-part': 'reset-trigger',\n onClick: tagSend(send, ['reset'], () => send({ type: 'reset' })),\n },\n }\n}\n\nexport const imageCropper = { init, update, connect, centerFill }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Send } from '@llui/dom';
|
|
1
|
+
import type { Send, Signal } from '@llui/dom';
|
|
2
2
|
/**
|
|
3
3
|
* In View — tracks whether an element is visible in the viewport
|
|
4
4
|
* using IntersectionObserver.
|
|
@@ -10,10 +10,10 @@ import type { Send } from '@llui/dom';
|
|
|
10
10
|
* scroll-triggered animations.
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
|
-
* const parts = inView.connect
|
|
13
|
+
* const parts = inView.connect(state.map((s) => s.iv), sendIv, { id: 'hero' })
|
|
14
14
|
*
|
|
15
15
|
* view: () => [
|
|
16
|
-
* div({ ...parts.root, class: (s) => s.iv.visible ? 'fade-in' : '' }, [
|
|
16
|
+
* div({ ...parts.root, class: state.map((s) => (s.iv.visible ? 'fade-in' : '')) }, [
|
|
17
17
|
* // content that animates on scroll
|
|
18
18
|
* ]),
|
|
19
19
|
* ]
|
|
@@ -34,17 +34,17 @@ export type InViewMsg = {
|
|
|
34
34
|
};
|
|
35
35
|
export declare function init(): InViewState;
|
|
36
36
|
export declare function update(state: InViewState, msg: InViewMsg): [InViewState, never[]];
|
|
37
|
-
export interface InViewParts
|
|
37
|
+
export interface InViewParts {
|
|
38
38
|
root: {
|
|
39
39
|
'data-scope': 'in-view';
|
|
40
40
|
'data-part': 'root';
|
|
41
|
-
'data-state':
|
|
41
|
+
'data-state': Signal<'visible' | 'hidden'>;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
export interface ConnectOptions {
|
|
45
45
|
id: string;
|
|
46
46
|
}
|
|
47
|
-
export declare function connect
|
|
47
|
+
export declare function connect(state: Signal<InViewState>, _send: Send<InViewMsg>, _opts: ConnectOptions): InViewParts;
|
|
48
48
|
export interface ObserverOptions {
|
|
49
49
|
threshold?: number;
|
|
50
50
|
rootMargin?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-view.d.ts","sourceRoot":"","sources":["../../src/components/in-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"in-view.d.ts","sourceRoot":"","sources":["../../src/components/in-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAA;AAE7D,wBAAgB,IAAI,IAAI,WAAW,CAElC;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,CAOjF;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE;QACJ,YAAY,EAAE,SAAS,CAAA;QACvB,WAAW,EAAE,MAAM,CAAA;QACnB,YAAY,EAAE,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAA;KAC3C,CAAA;CACF;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;CACX;AAED,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,EAC1B,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EACtB,KAAK,EAAE,cAAc,GACpB,WAAW,CAQb;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EACrB,IAAI,GAAE,eAAoB,GACzB,MAAM,IAAI,CAuBZ;AAED,eAAO,MAAM,MAAM;;;;;CAA4C,CAAA"}
|
|
@@ -9,12 +9,12 @@ export function update(state, msg) {
|
|
|
9
9
|
return state.visible ? [{ visible: false }, []] : [state, []];
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
export function connect(
|
|
12
|
+
export function connect(state, _send, _opts) {
|
|
13
13
|
return {
|
|
14
14
|
root: {
|
|
15
15
|
'data-scope': 'in-view',
|
|
16
16
|
'data-part': 'root',
|
|
17
|
-
'data-state': (s) => (
|
|
17
|
+
'data-state': state.map((s) => (s.visible ? 'visible' : 'hidden')),
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-view.js","sourceRoot":"","sources":["../../src/components/in-view.ts"],"names":[],"mappings":"AAkCA,MAAM,UAAU,IAAI;IAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAC3B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAkB,EAAE,GAAc;IACvD,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,O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C,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;SACnE;KACF,CAAA;AACH,CAAC;AAQD;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,EAAW,EACX,IAAqB,EACrB,OAAwB,EAAE;IAE1B,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,EAAE,EAAE;QACV,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;gBACzB,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;gBACvB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACd,QAAQ,CAAC,UAAU,EAAE,CAAA;oBACrB,OAAM;gBACR,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC,EACD;QACE,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC;QAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;KACrC,CACF,CAAA;IAED,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACpB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;AACpC,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,CAAA","sourcesContent":["import type { Send, Signal } from '@llui/dom'\n\n/**\n * In View — tracks whether an element is visible in the viewport\n * using IntersectionObserver.\n *\n * State machine: `{ visible: false }` → enter → `{ visible: true }` → leave → …\n *\n * With `once: true`, the observer disconnects after the first enter,\n * keeping `visible: true` permanently. Useful for lazy-load and\n * scroll-triggered animations.\n *\n * ```ts\n * const parts = inView.connect(state.map((s) => s.iv), sendIv, { id: 'hero' })\n *\n * view: () => [\n * div({ ...parts.root, class: state.map((s) => (s.iv.visible ? 'fade-in' : '')) }, [\n * // content that animates on scroll\n * ]),\n * ]\n * ```\n *\n * Wire up the observer in `onMount`:\n * ```ts\n * onMount((el) => inView.createObserver(el, sendIv, { threshold: 0.5, once: true }))\n * ```\n */\n\nexport interface InViewState {\n visible: boolean\n}\n\nexport type InViewMsg = { type: 'enter' } | { type: 'leave' }\n\nexport function init(): InViewState {\n return { visible: false }\n}\n\nexport function update(state: InViewState, msg: InViewMsg): [InViewState, never[]] {\n switch (msg.type) {\n case 'enter':\n return state.visible ? [state, []] : [{ visible: true }, []]\n case 'leave':\n return state.visible ? [{ visible: false }, []] : [state, []]\n }\n}\n\nexport interface InViewParts {\n root: {\n 'data-scope': 'in-view'\n 'data-part': 'root'\n 'data-state': Signal<'visible' | 'hidden'>\n }\n}\n\nexport interface ConnectOptions {\n id: string\n}\n\nexport function connect(\n state: Signal<InViewState>,\n _send: Send<InViewMsg>,\n _opts: ConnectOptions,\n): InViewParts {\n return {\n root: {\n 'data-scope': 'in-view',\n 'data-part': 'root',\n 'data-state': state.map((s) => (s.visible ? 'visible' : 'hidden')),\n },\n }\n}\n\nexport interface ObserverOptions {\n threshold?: number\n rootMargin?: string\n once?: boolean\n}\n\n/**\n * Create an IntersectionObserver for the given element. Returns a cleanup\n * function that disconnects the observer.\n *\n * Call this inside `onMount`:\n * ```ts\n * onMount((el) => inView.createObserver(el, send, { once: true }))\n * ```\n */\nexport function createObserver(\n el: Element,\n send: Send<InViewMsg>,\n opts: ObserverOptions = {},\n): () => void {\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n send({ type: 'enter' })\n if (opts.once) {\n observer.disconnect()\n return\n }\n } else {\n send({ type: 'leave' })\n }\n }\n },\n {\n threshold: opts.threshold ?? 0,\n rootMargin: opts.rootMargin ?? '0px',\n },\n )\n\n observer.observe(el)\n return () => observer.disconnect()\n}\n\nexport const inView = { init, update, connect, createObserver }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Send } from '@llui/dom';
|
|
1
|
+
import type { Send, Signal } from '@llui/dom';
|
|
2
2
|
/**
|
|
3
3
|
* Listbox — a list of selectable options. Supports single and multiple
|
|
4
4
|
* selection, keyboard navigation (arrows, Home, End), typeahead, and
|
|
@@ -76,15 +76,15 @@ export interface ListboxInit {
|
|
|
76
76
|
}
|
|
77
77
|
export declare function init(opts?: ListboxInit): ListboxState;
|
|
78
78
|
export declare function update(state: ListboxState, msg: ListboxMsg): [ListboxState, never[]];
|
|
79
|
-
export interface ListboxItemParts
|
|
79
|
+
export interface ListboxItemParts {
|
|
80
80
|
root: {
|
|
81
81
|
role: 'option';
|
|
82
82
|
id: string;
|
|
83
|
-
'aria-selected':
|
|
84
|
-
'aria-disabled':
|
|
85
|
-
'data-state':
|
|
86
|
-
'data-highlighted':
|
|
87
|
-
'data-disabled':
|
|
83
|
+
'aria-selected': Signal<boolean>;
|
|
84
|
+
'aria-disabled': Signal<'true' | undefined>;
|
|
85
|
+
'data-state': Signal<'selected' | undefined>;
|
|
86
|
+
'data-highlighted': Signal<'' | undefined>;
|
|
87
|
+
'data-disabled': Signal<'' | undefined>;
|
|
88
88
|
'data-scope': 'listbox';
|
|
89
89
|
'data-part': 'item';
|
|
90
90
|
'data-value': string;
|
|
@@ -93,26 +93,26 @@ export interface ListboxItemParts<S> {
|
|
|
93
93
|
onPointerMove: (e: PointerEvent) => void;
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
export interface ListboxParts
|
|
96
|
+
export interface ListboxParts {
|
|
97
97
|
root: {
|
|
98
98
|
role: 'listbox';
|
|
99
|
-
'aria-owns':
|
|
100
|
-
'aria-multiselectable':
|
|
101
|
-
'aria-disabled':
|
|
102
|
-
'aria-activedescendant':
|
|
103
|
-
tabIndex:
|
|
99
|
+
'aria-owns': Signal<string | undefined>;
|
|
100
|
+
'aria-multiselectable': Signal<'true' | undefined>;
|
|
101
|
+
'aria-disabled': Signal<'true' | undefined>;
|
|
102
|
+
'aria-activedescendant': Signal<string | undefined>;
|
|
103
|
+
tabIndex: Signal<number>;
|
|
104
104
|
id: string;
|
|
105
105
|
'data-scope': 'listbox';
|
|
106
106
|
'data-part': 'root';
|
|
107
|
-
'data-disabled':
|
|
107
|
+
'data-disabled': Signal<'' | undefined>;
|
|
108
108
|
onKeyDown: (e: KeyboardEvent) => void;
|
|
109
109
|
};
|
|
110
|
-
item: (value: string, index: number) => ListboxItemParts
|
|
110
|
+
item: (value: string, index: number) => ListboxItemParts;
|
|
111
111
|
}
|
|
112
112
|
export interface ConnectOptions {
|
|
113
113
|
id: string;
|
|
114
114
|
}
|
|
115
|
-
export declare function connect
|
|
115
|
+
export declare function connect(state: Signal<ListboxState>, send: Send<ListboxMsg>, opts: ConnectOptions): ListboxParts;
|
|
116
116
|
export declare const listbox: {
|
|
117
117
|
init: typeof init;
|
|
118
118
|
update: typeof update;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../src/components/listbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../src/components/listbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAQ7C;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAA;AAEjD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,aAAa,EAAE,aAAa,CAAA;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,SAAS,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ACvB,WAAW,EAAE,MAAM,CAAA;QACnB,eAAe,EAAE,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC,CAAA;QACvC,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,gBAAgB,CAAA;CACzD;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;CACX;AAED,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,EAC3B,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EACtB,IAAI,EAAE,cAAc,GACnB,YAAY,CAoFd;AAED,eAAO,MAAM,OAAO;;;;CAA4B,CAAA"}
|
|
@@ -106,29 +106,29 @@ export function update(state, msg) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
export function connect(
|
|
109
|
+
export function connect(state, send, opts) {
|
|
110
110
|
const rootId = `${opts.id}:root`;
|
|
111
111
|
const itemId = (index) => `${opts.id}:item:${index}`;
|
|
112
112
|
return {
|
|
113
113
|
root: {
|
|
114
114
|
role: 'listbox',
|
|
115
|
-
'aria-owns': (s) => {
|
|
116
|
-
const items =
|
|
115
|
+
'aria-owns': state.map((s) => {
|
|
116
|
+
const items = s.items;
|
|
117
117
|
if (items.length === 0)
|
|
118
118
|
return undefined;
|
|
119
119
|
return items.map((_, i) => itemId(i)).join(' ');
|
|
120
|
-
},
|
|
121
|
-
'aria-multiselectable': (s) =>
|
|
122
|
-
'aria-disabled': (s) => (
|
|
123
|
-
'aria-activedescendant': (s) => {
|
|
124
|
-
const idx =
|
|
120
|
+
}),
|
|
121
|
+
'aria-multiselectable': state.map((s) => s.selectionMode === 'multiple' ? 'true' : undefined),
|
|
122
|
+
'aria-disabled': state.map((s) => (s.disabled ? 'true' : undefined)),
|
|
123
|
+
'aria-activedescendant': state.map((s) => {
|
|
124
|
+
const idx = s.highlightedIndex;
|
|
125
125
|
return idx === null ? undefined : itemId(idx);
|
|
126
|
-
},
|
|
127
|
-
tabIndex: (s) => (
|
|
126
|
+
}),
|
|
127
|
+
tabIndex: state.map((s) => (s.disabled ? -1 : 0)),
|
|
128
128
|
id: rootId,
|
|
129
129
|
'data-scope': 'listbox',
|
|
130
130
|
'data-part': 'root',
|
|
131
|
-
'data-disabled': (s) => (
|
|
131
|
+
'data-disabled': state.map((s) => (s.disabled ? '' : undefined)),
|
|
132
132
|
onKeyDown: tagSend(send, [
|
|
133
133
|
'highlightNext',
|
|
134
134
|
'highlightPrev',
|
|
@@ -170,11 +170,11 @@ export function connect(get, send, opts) {
|
|
|
170
170
|
root: {
|
|
171
171
|
role: 'option',
|
|
172
172
|
id: itemId(index),
|
|
173
|
-
'aria-selected': (s) =>
|
|
174
|
-
'aria-disabled': (s) => (
|
|
175
|
-
'data-state': (s) => (
|
|
176
|
-
'data-highlighted': (s) => (
|
|
177
|
-
'data-disabled': (s) => (
|
|
173
|
+
'aria-selected': state.map((s) => s.value.includes(value)),
|
|
174
|
+
'aria-disabled': state.map((s) => (s.disabledItems.includes(value) ? 'true' : undefined)),
|
|
175
|
+
'data-state': state.map((s) => (s.value.includes(value) ? 'selected' : undefined)),
|
|
176
|
+
'data-highlighted': state.map((s) => (s.highlightedIndex === index ? '' : undefined)),
|
|
177
|
+
'data-disabled': state.map((s) => (s.disabledItems.includes(value) ? '' : undefined)),
|
|
178
178
|
'data-scope': 'listbox',
|
|
179
179
|
'data-part': 'item',
|
|
180
180
|
'data-value': value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.js","sourceRoot":"","sources":["../../src/components/listbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,GACrB,MAAM,uBAAuB,CAAA;AAq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AAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC/E,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC/E,YAAY,EAAE,SAAS;gBACvB,WAAW,EAAE,MAAM;gBACnB,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;gBAC3B,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzE,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;aACtF;SACF,CAAC;KACH,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA","sourcesContent":["import { tagSend } from '@llui/dom'\nimport type { Send } from '@llui/dom'\nimport {\n typeaheadAccumulate,\n typeaheadMatchByItems,\n isTypeaheadKey,\n TYPEAHEAD_TIMEOUT_MS,\n} from '../utils/typeahead.js'\n\n/**\n * Listbox — a list of selectable options. Supports single and multiple\n * selection, keyboard navigation (arrows, Home, End), typeahead, and\n * disabled items. Renders as `role=\"listbox\"` with `role=\"option\"` items.\n */\n\nexport type SelectionMode = 'single' | 'multiple'\n\nexport interface ListboxState {\n value: string[]\n items: string[]\n disabledItems: string[]\n disabled: boolean\n selectionMode: SelectionMode\n highlightedIndex: number | null\n typeahead: string\n typeaheadExpiresAt: number\n}\n\nexport type ListboxMsg =\n /** @intent(\"Pick the option with the given value (toggles in multi-select)\") */\n | { type: 'select'; value: string }\n /** @intent(\"Replace the selected values with the provided list\") */\n | { type: 'setValue'; value: string[] }\n /** @intent(\"Clear all selected values\") */\n | { type: 'clear' }\n /** @humanOnly */\n | { type: 'highlight'; index: number | null }\n /** @humanOnly */\n | { type: 'highlightNext' }\n /** @humanOnly */\n | { type: 'highlightPrev' }\n /** @humanOnly */\n | { type: 'highlightFirst' }\n /** @humanOnly */\n | { type: 'highlightLast' }\n /** @intent(\"Pick the currently-highlighted option\") */\n | { type: 'selectHighlighted' }\n /** @humanOnly */\n | { type: 'setItems'; items: string[]; disabled?: string[] }\n /** @humanOnly */\n | { type: 'typeahead'; char: string; now: number }\n\nexport interface ListboxInit {\n value?: string[]\n items?: string[]\n disabledItems?: string[]\n disabled?: boolean\n selectionMode?: SelectionMode\n}\n\nexport function init(opts: ListboxInit = {}): ListboxState {\n return {\n value: opts.value ?? [],\n items: opts.items ?? [],\n disabledItems: opts.disabledItems ?? [],\n disabled: opts.disabled ?? false,\n selectionMode: opts.selectionMode ?? 'single',\n highlightedIndex: null,\n typeahead: '',\n typeaheadExpiresAt: 0,\n }\n}\n\nfunction nextEnabledIndex(\n items: string[],\n disabled: string[],\n from: number | null,\n delta: 1 | -1,\n): number | null {\n if (items.length === 0) return null\n const start = from === null ? (delta === 1 ? -1 : items.length) : from\n const n = items.length\n for (let i = 1; i <= n; i++) {\n const idx = (start + delta * i + n * n) % n\n if (!disabled.includes(items[idx]!)) return idx\n }\n return null\n}\n\nfunction firstEnabledIndex(items: string[], disabled: string[]): number | null {\n for (let i = 0; i < items.length; i++) {\n if (!disabled.includes(items[i]!)) return i\n }\n return null\n}\n\nfunction lastEnabledIndex(items: string[], disabled: string[]): number | null {\n for (let i = items.length - 1; i >= 0; i--) {\n if (!disabled.includes(items[i]!)) return i\n }\n return null\n}\n\nfunction applySelection(state: ListboxState, value: string): string[] {\n if (state.disabledItems.includes(value)) return state.value\n if (state.selectionMode === 'single') return [value]\n // multiple\n const isActive = state.value.includes(value)\n return isActive ? state.value.filter((v) => v !== value) : [...state.value, value]\n}\n\nexport function update(state: ListboxState, msg: ListboxMsg): [ListboxState, never[]] {\n if (state.disabled) return [state, []]\n switch (msg.type) {\n case 'select':\n return [{ ...state, value: applySelection(state, msg.value) }, []]\n case 'setValue':\n return [{ ...state, value: msg.value }, []]\n case 'clear':\n return [{ ...state, value: [] }, []]\n case 'highlight':\n return [{ ...state, highlightedIndex: msg.index }, []]\n case 'highlightNext': {\n const to = nextEnabledIndex(state.items, state.disabledItems, state.highlightedIndex, 1)\n return [{ ...state, highlightedIndex: to }, []]\n }\n case 'highlightPrev': {\n const to = nextEnabledIndex(state.items, state.disabledItems, state.highlightedIndex, -1)\n return [{ ...state, highlightedIndex: to }, []]\n }\n case 'highlightFirst':\n return [\n { ...state, highlightedIndex: firstEnabledIndex(state.items, state.disabledItems) },\n [],\n ]\n case 'highlightLast':\n return [\n { ...state, highlightedIndex: lastEnabledIndex(state.items, state.disabledItems) },\n [],\n ]\n case 'selectHighlighted': {\n if (state.highlightedIndex === null) return [state, []]\n const v = state.items[state.highlightedIndex]\n if (v === undefined) return [state, []]\n return [{ ...state, value: applySelection(state, v) }, []]\n }\n case 'setItems': {\n const disabled = msg.disabled ?? state.disabledItems\n // Preserve only values still in the items list and not disabled\n const value = state.value.filter((v) => msg.items.includes(v) && !disabled.includes(v))\n return [{ ...state, items: msg.items, disabledItems: disabled, value }, []]\n }\n case 'typeahead': {\n const acc = typeaheadAccumulate(state.typeahead, msg.char, msg.now, state.typeaheadExpiresAt)\n const match = typeaheadMatchByItems(\n state.items,\n state.disabledItems,\n acc,\n state.highlightedIndex,\n )\n return [\n {\n ...state,\n typeahead: acc,\n typeaheadExpiresAt: msg.now + TYPEAHEAD_TIMEOUT_MS,\n highlightedIndex: match ?? state.highlightedIndex,\n },\n [],\n ]\n }\n }\n}\n\nexport interface ListboxItemParts<S> {\n root: {\n role: 'option'\n id: string\n 'aria-selected': (s: S) => boolean\n 'aria-disabled': (s: S) => 'true' | undefined\n 'data-state': (s: S) => 'selected' | undefined\n 'data-highlighted': (s: S) => '' | undefined\n 'data-disabled': (s: S) => '' | undefined\n 'data-scope': 'listbox'\n 'data-part': 'item'\n 'data-value': string\n 'data-index': string\n onClick: (e: MouseEvent) => void\n onPointerMove: (e: PointerEvent) => void\n }\n}\n\nexport interface ListboxParts<S> {\n root: {\n role: 'listbox'\n 'aria-owns': (s: S) => string | undefined\n 'aria-multiselectable': (s: S) => 'true' | undefined\n 'aria-disabled': (s: S) => 'true' | undefined\n 'aria-activedescendant': (s: S) => string | undefined\n tabIndex: (s: S) => number\n id: string\n 'data-scope': 'listbox'\n 'data-part': 'root'\n 'data-disabled': (s: S) => '' | undefined\n onKeyDown: (e: KeyboardEvent) => void\n }\n item: (value: string, index: number) => ListboxItemParts<S>\n}\n\nexport interface ConnectOptions {\n id: string\n}\n\nexport function connect<S>(\n get: (s: S) => ListboxState,\n send: Send<ListboxMsg>,\n opts: ConnectOptions,\n): ListboxParts<S> {\n const rootId = `${opts.id}:root`\n const itemId = (index: number): string => `${opts.id}:item:${index}`\n\n return {\n root: {\n role: 'listbox',\n 'aria-owns': (s) => {\n const items = get(s).items\n if (items.length === 0) return undefined\n return items.map((_, i) => itemId(i)).join(' ')\n },\n 'aria-multiselectable': (s) => (get(s).selectionMode === 'multiple' ? 'true' : undefined),\n 'aria-disabled': (s) => (get(s).disabled ? 'true' : undefined),\n 'aria-activedescendant': (s) => {\n const idx = get(s).highlightedIndex\n return idx === null ? undefined : itemId(idx)\n },\n tabIndex: (s) => (get(s).disabled ? -1 : 0),\n id: rootId,\n 'data-scope': 'listbox',\n 'data-part': 'root',\n 'data-disabled': (s) => (get(s).disabled ? '' : undefined),\n onKeyDown: tagSend(\n send,\n [\n 'highlightNext',\n 'highlightPrev',\n 'highlightFirst',\n 'highlightLast',\n 'selectHighlighted',\n 'typeahead',\n ],\n (e) => {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault()\n send({ type: 'highlightNext' })\n return\n case 'ArrowUp':\n e.preventDefault()\n send({ type: 'highlightPrev' })\n return\n case 'Home':\n e.preventDefault()\n send({ type: 'highlightFirst' })\n return\n case 'End':\n e.preventDefault()\n send({ type: 'highlightLast' })\n return\n case 'Enter':\n case ' ':\n e.preventDefault()\n send({ type: 'selectHighlighted' })\n return\n default:\n if (isTypeaheadKey(e)) {\n send({ type: 'typeahead', char: e.key, now: Date.now() })\n }\n }\n },\n ),\n },\n item: (value: string, index: number): ListboxItemParts<S> => ({\n root: {\n role: 'option',\n id: itemId(index),\n 'aria-selected': (s) => get(s).value.includes(value),\n 'aria-disabled': (s) => (get(s).disabledItems.includes(value) ? 'true' : undefined),\n 'data-state': (s) => (get(s).value.includes(value) ? 'selected' : undefined),\n 'data-highlighted': (s) => (get(s).highlightedIndex === index ? '' : undefined),\n 'data-disabled': (s) => (get(s).disabledItems.includes(value) ? '' : undefined),\n 'data-scope': 'listbox',\n 'data-part': 'item',\n 'data-value': value,\n 'data-index': String(index),\n onClick: tagSend(send, ['select'], () => send({ type: 'select', value })),\n onPointerMove: tagSend(send, ['highlight'], () => send({ type: 'highlight', index })),\n },\n }),\n }\n}\n\nexport const listbox = { init, update, connect }\n"]}
|
|
1
|
+
{"version":3,"file":"listbox.js","sourceRoot":"","sources":["../../src/components/listbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,GACrB,MAAM,uBAAuB,CAAA;AAqD9B,MAAM,UAAU,IAAI,CAAC,OAAoB,EAAE;IACzC,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;QACvB,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,aAAa,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KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACrF,YAAY,EAAE,SAAS;gBACvB,WAAW,EAAE,MAAM;gBACnB,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;gBAC3B,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzE,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;aACtF;SACF,CAAC;KACH,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA","sourcesContent":["import { tagSend } from '@llui/dom'\nimport type { Send, Signal } from '@llui/dom'\nimport {\n typeaheadAccumulate,\n typeaheadMatchByItems,\n isTypeaheadKey,\n TYPEAHEAD_TIMEOUT_MS,\n} from '../utils/typeahead.js'\n\n/**\n * Listbox — a list of selectable options. Supports single and multiple\n * selection, keyboard navigation (arrows, Home, End), typeahead, and\n * disabled items. Renders as `role=\"listbox\"` with `role=\"option\"` items.\n */\n\nexport type SelectionMode = 'single' | 'multiple'\n\nexport interface ListboxState {\n value: string[]\n items: string[]\n disabledItems: string[]\n disabled: boolean\n selectionMode: SelectionMode\n highlightedIndex: number | null\n typeahead: string\n typeaheadExpiresAt: number\n}\n\nexport type ListboxMsg =\n /** @intent(\"Pick the option with the given value (toggles in multi-select)\") */\n | { type: 'select'; value: string }\n /** @intent(\"Replace the selected values with the provided list\") */\n | { type: 'setValue'; value: string[] }\n /** @intent(\"Clear all selected values\") */\n | { type: 'clear' }\n /** @humanOnly */\n | { type: 'highlight'; index: number | null }\n /** @humanOnly */\n | { type: 'highlightNext' }\n /** @humanOnly */\n | { type: 'highlightPrev' }\n /** @humanOnly */\n | { type: 'highlightFirst' }\n /** @humanOnly */\n | { type: 'highlightLast' }\n /** @intent(\"Pick the currently-highlighted option\") */\n | { type: 'selectHighlighted' }\n /** @humanOnly */\n | { type: 'setItems'; items: string[]; disabled?: string[] }\n /** @humanOnly */\n | { type: 'typeahead'; char: string; now: number }\n\nexport interface ListboxInit {\n value?: string[]\n items?: string[]\n disabledItems?: string[]\n disabled?: boolean\n selectionMode?: SelectionMode\n}\n\nexport function init(opts: ListboxInit = {}): ListboxState {\n return {\n value: opts.value ?? [],\n items: opts.items ?? [],\n disabledItems: opts.disabledItems ?? [],\n disabled: opts.disabled ?? false,\n selectionMode: opts.selectionMode ?? 'single',\n highlightedIndex: null,\n typeahead: '',\n typeaheadExpiresAt: 0,\n }\n}\n\nfunction nextEnabledIndex(\n items: string[],\n disabled: string[],\n from: number | null,\n delta: 1 | -1,\n): number | null {\n if (items.length === 0) return null\n const start = from === null ? (delta === 1 ? -1 : items.length) : from\n const n = items.length\n for (let i = 1; i <= n; i++) {\n const idx = (start + delta * i + n * n) % n\n if (!disabled.includes(items[idx]!)) return idx\n }\n return null\n}\n\nfunction firstEnabledIndex(items: string[], disabled: string[]): number | null {\n for (let i = 0; i < items.length; i++) {\n if (!disabled.includes(items[i]!)) return i\n }\n return null\n}\n\nfunction lastEnabledIndex(items: string[], disabled: string[]): number | null {\n for (let i = items.length - 1; i >= 0; i--) {\n if (!disabled.includes(items[i]!)) return i\n }\n return null\n}\n\nfunction applySelection(state: ListboxState, value: string): string[] {\n if (state.disabledItems.includes(value)) return state.value\n if (state.selectionMode === 'single') return [value]\n // multiple\n const isActive = state.value.includes(value)\n return isActive ? state.value.filter((v) => v !== value) : [...state.value, value]\n}\n\nexport function update(state: ListboxState, msg: ListboxMsg): [ListboxState, never[]] {\n if (state.disabled) return [state, []]\n switch (msg.type) {\n case 'select':\n return [{ ...state, value: applySelection(state, msg.value) }, []]\n case 'setValue':\n return [{ ...state, value: msg.value }, []]\n case 'clear':\n return [{ ...state, value: [] }, []]\n case 'highlight':\n return [{ ...state, highlightedIndex: msg.index }, []]\n case 'highlightNext': {\n const to = nextEnabledIndex(state.items, state.disabledItems, state.highlightedIndex, 1)\n return [{ ...state, highlightedIndex: to }, []]\n }\n case 'highlightPrev': {\n const to = nextEnabledIndex(state.items, state.disabledItems, state.highlightedIndex, -1)\n return [{ ...state, highlightedIndex: to }, []]\n }\n case 'highlightFirst':\n return [\n { ...state, highlightedIndex: firstEnabledIndex(state.items, state.disabledItems) },\n [],\n ]\n case 'highlightLast':\n return [\n { ...state, highlightedIndex: lastEnabledIndex(state.items, state.disabledItems) },\n [],\n ]\n case 'selectHighlighted': {\n if (state.highlightedIndex === null) return [state, []]\n const v = state.items[state.highlightedIndex]\n if (v === undefined) return [state, []]\n return [{ ...state, value: applySelection(state, v) }, []]\n }\n case 'setItems': {\n const disabled = msg.disabled ?? state.disabledItems\n // Preserve only values still in the items list and not disabled\n const value = state.value.filter((v) => msg.items.includes(v) && !disabled.includes(v))\n return [{ ...state, items: msg.items, disabledItems: disabled, value }, []]\n }\n case 'typeahead': {\n const acc = typeaheadAccumulate(state.typeahead, msg.char, msg.now, state.typeaheadExpiresAt)\n const match = typeaheadMatchByItems(\n state.items,\n state.disabledItems,\n acc,\n state.highlightedIndex,\n )\n return [\n {\n ...state,\n typeahead: acc,\n typeaheadExpiresAt: msg.now + TYPEAHEAD_TIMEOUT_MS,\n highlightedIndex: match ?? state.highlightedIndex,\n },\n [],\n ]\n }\n }\n}\n\nexport interface ListboxItemParts {\n root: {\n role: 'option'\n id: string\n 'aria-selected': Signal<boolean>\n 'aria-disabled': Signal<'true' | undefined>\n 'data-state': Signal<'selected' | undefined>\n 'data-highlighted': Signal<'' | undefined>\n 'data-disabled': Signal<'' | undefined>\n 'data-scope': 'listbox'\n 'data-part': 'item'\n 'data-value': string\n 'data-index': string\n onClick: (e: MouseEvent) => void\n onPointerMove: (e: PointerEvent) => void\n }\n}\n\nexport interface ListboxParts {\n root: {\n role: 'listbox'\n 'aria-owns': Signal<string | undefined>\n 'aria-multiselectable': Signal<'true' | undefined>\n 'aria-disabled': Signal<'true' | undefined>\n 'aria-activedescendant': Signal<string | undefined>\n tabIndex: Signal<number>\n id: string\n 'data-scope': 'listbox'\n 'data-part': 'root'\n 'data-disabled': Signal<'' | undefined>\n onKeyDown: (e: KeyboardEvent) => void\n }\n item: (value: string, index: number) => ListboxItemParts\n}\n\nexport interface ConnectOptions {\n id: string\n}\n\nexport function connect(\n state: Signal<ListboxState>,\n send: Send<ListboxMsg>,\n opts: ConnectOptions,\n): ListboxParts {\n const rootId = `${opts.id}:root`\n const itemId = (index: number): string => `${opts.id}:item:${index}`\n\n return {\n root: {\n role: 'listbox',\n 'aria-owns': state.map((s) => {\n const items = s.items\n if (items.length === 0) return undefined\n return items.map((_, i) => itemId(i)).join(' ')\n }),\n 'aria-multiselectable': state.map((s) =>\n s.selectionMode === 'multiple' ? 'true' : undefined,\n ),\n 'aria-disabled': state.map((s) => (s.disabled ? 'true' : undefined)),\n 'aria-activedescendant': state.map((s) => {\n const idx = s.highlightedIndex\n return idx === null ? undefined : itemId(idx)\n }),\n tabIndex: state.map((s) => (s.disabled ? -1 : 0)),\n id: rootId,\n 'data-scope': 'listbox',\n 'data-part': 'root',\n 'data-disabled': state.map((s) => (s.disabled ? '' : undefined)),\n onKeyDown: tagSend(\n send,\n [\n 'highlightNext',\n 'highlightPrev',\n 'highlightFirst',\n 'highlightLast',\n 'selectHighlighted',\n 'typeahead',\n ],\n (e) => {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault()\n send({ type: 'highlightNext' })\n return\n case 'ArrowUp':\n e.preventDefault()\n send({ type: 'highlightPrev' })\n return\n case 'Home':\n e.preventDefault()\n send({ type: 'highlightFirst' })\n return\n case 'End':\n e.preventDefault()\n send({ type: 'highlightLast' })\n return\n case 'Enter':\n case ' ':\n e.preventDefault()\n send({ type: 'selectHighlighted' })\n return\n default:\n if (isTypeaheadKey(e)) {\n send({ type: 'typeahead', char: e.key, now: Date.now() })\n }\n }\n },\n ),\n },\n item: (value: string, index: number): ListboxItemParts => ({\n root: {\n role: 'option',\n id: itemId(index),\n 'aria-selected': state.map((s) => s.value.includes(value)),\n 'aria-disabled': state.map((s) => (s.disabledItems.includes(value) ? 'true' : undefined)),\n 'data-state': state.map((s) => (s.value.includes(value) ? 'selected' : undefined)),\n 'data-highlighted': state.map((s) => (s.highlightedIndex === index ? '' : undefined)),\n 'data-disabled': state.map((s) => (s.disabledItems.includes(value) ? '' : undefined)),\n 'data-scope': 'listbox',\n 'data-part': 'item',\n 'data-value': value,\n 'data-index': String(index),\n onClick: tagSend(send, ['select'], () => send({ type: 'select', value })),\n onPointerMove: tagSend(send, ['highlight'], () => send({ type: 'highlight', index })),\n },\n }),\n }\n}\n\nexport const listbox = { init, update, connect }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Send } from '@llui/dom';
|
|
1
|
+
import type { Send, Signal } from '@llui/dom';
|
|
2
2
|
/**
|
|
3
3
|
* Marquee — continuously-scrolling content. The state machine tracks
|
|
4
4
|
* play/pause + direction + speed; the scrolling itself is driven by CSS
|
|
@@ -69,15 +69,15 @@ export declare function update(state: MarqueeState, msg: MarqueeMsg): [MarqueeSt
|
|
|
69
69
|
export declare function cssAnimationDirection(direction: MarqueeDirection): 'normal' | 'reverse';
|
|
70
70
|
/** Returns 'horizontal' or 'vertical' based on direction. */
|
|
71
71
|
export declare function axis(direction: MarqueeDirection): 'horizontal' | 'vertical';
|
|
72
|
-
export interface MarqueeParts
|
|
72
|
+
export interface MarqueeParts {
|
|
73
73
|
root: {
|
|
74
74
|
'data-scope': 'marquee';
|
|
75
75
|
'data-part': 'root';
|
|
76
|
-
'data-running':
|
|
77
|
-
'data-direction':
|
|
78
|
-
'data-axis':
|
|
79
|
-
'data-disabled':
|
|
80
|
-
style:
|
|
76
|
+
'data-running': Signal<'' | undefined>;
|
|
77
|
+
'data-direction': Signal<MarqueeDirection>;
|
|
78
|
+
'data-axis': Signal<'horizontal' | 'vertical'>;
|
|
79
|
+
'data-disabled': Signal<'' | undefined>;
|
|
80
|
+
style: Signal<string>;
|
|
81
81
|
onMouseEnter: (e: MouseEvent) => void;
|
|
82
82
|
onMouseLeave: (e: MouseEvent) => void;
|
|
83
83
|
};
|
|
@@ -86,7 +86,7 @@ export interface MarqueeParts<S> {
|
|
|
86
86
|
'data-part': 'content';
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
export declare function connect
|
|
89
|
+
export declare function connect(state: Signal<MarqueeState>, send: Send<MarqueeMsg>): MarqueeParts;
|
|
90
90
|
export declare const marquee: {
|
|
91
91
|
init: typeof init;
|
|
92
92
|
update: typeof update;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["../../src/components/marquee.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["../../src/components/marquee.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE7C;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAA;AAE/D,MAAM,WAAW,YAAY;IAC3B;;sCAEkC;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,gBAAgB,CAAA;IAC3B,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,UAAU;AACpB,8CAA8C;AAC5C;IAAE,IAA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AAE,GAAG,SAAS,CAAC,CAAA;QACtC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAA;QAC1C,WAAW,EAAE,MAAM,CAAC,YAAY,GAAG,UAAU,CAAC,CAAA;QAC9C,eAAe,EAAE,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC,CAAA;QACvC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QACrB,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;QACrC,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;KACtC,CAAA;IACD,OAAO,EAAE;QACP,YAAY,EAAE,SAAS,CAAA;QACvB,WAAW,EAAE,SAAS,CAAA;KACvB,CAAA;CACF;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,YAAY,CAyBzF;AAED,eAAO,MAAM,OAAO;;;;;;;CAAoE,CAAA"}
|
|
@@ -45,21 +45,18 @@ export function cssAnimationDirection(direction) {
|
|
|
45
45
|
export function axis(direction) {
|
|
46
46
|
return direction === 'up' || direction === 'down' ? 'vertical' : 'horizontal';
|
|
47
47
|
}
|
|
48
|
-
export function connect(
|
|
48
|
+
export function connect(state, send) {
|
|
49
49
|
return {
|
|
50
50
|
root: {
|
|
51
51
|
'data-scope': 'marquee',
|
|
52
52
|
'data-part': 'root',
|
|
53
|
-
'data-running': (s) => (isRunning(
|
|
54
|
-
'data-direction': (s) =>
|
|
55
|
-
'data-axis': (s) => axis(
|
|
56
|
-
'data-disabled': (s) => (
|
|
57
|
-
style: (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
`--marquee-direction:${cssAnimationDirection(st.direction)};` +
|
|
61
|
-
`--marquee-playstate:${isRunning(st) ? 'running' : 'paused'};`);
|
|
62
|
-
},
|
|
53
|
+
'data-running': state.map((s) => (isRunning(s) ? '' : undefined)),
|
|
54
|
+
'data-direction': state.map((s) => s.direction),
|
|
55
|
+
'data-axis': state.map((s) => axis(s.direction)),
|
|
56
|
+
'data-disabled': state.map((s) => (s.disabled ? '' : undefined)),
|
|
57
|
+
style: state.map((st) => `--marquee-duration:${st.durationSec}s;` +
|
|
58
|
+
`--marquee-direction:${cssAnimationDirection(st.direction)};` +
|
|
59
|
+
`--marquee-playstate:${isRunning(st) ? 'running' : 'paused'};`),
|
|
63
60
|
// Always fire hover messages; the reducer no-ops unless
|
|
64
61
|
// state.pauseOnHover is true.
|
|
65
62
|
onMouseEnter: tagSend(send, ['hoverPause'], () => send({ type: 'hoverPause' })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.js","sourceRoot":"","sources":["../../src/components/marquee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsDnC,MAAM,UAAU,IAAI,CAAC,OAAoB,EAAE;IACzC,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI;QAC7B,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,MAAM;QACnC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;QACnC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;QACxC,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;KACjC,CAAA;AACH,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAClD,IAAI,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IACrD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAmB,EAAE,GAAe;IACzD,IAAI,KAAK,CAAC,QAAQ;QAAE,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type { Send, Signal } from '@llui/dom'\n\n/**\n * Marquee — continuously-scrolling content. The state machine tracks\n * play/pause + direction + speed; the scrolling itself is driven by CSS\n * animations or JS requestAnimationFrame (the consumer owns that).\n *\n * Expose the active state via CSS custom properties the consumer reads\n * in their stylesheet:\n * --marquee-duration: {N}s\n * --marquee-direction: 'normal' | 'reverse'\n * --marquee-playstate: 'running' | 'paused'\n */\n\nexport type MarqueeDirection = 'left' | 'right' | 'up' | 'down'\n\nexport interface MarqueeState {\n /** User-intended running state (what play/pause/toggle set). The actual\n * effective state is derived via `isRunning()` — it combines this with\n * `hovered` + `pauseOnHover`. */\n running: boolean\n direction: MarqueeDirection\n /** Duration of one full loop in seconds. Larger = slower. */\n durationSec: number\n pauseOnHover: boolean\n hovered: boolean\n disabled: boolean\n}\n\nexport type MarqueeMsg =\n /** @intent(\"Resume the marquee scrolling\") */\n | { type: 'play' }\n /** @intent(\"Pause the marquee scrolling\") */\n | { type: 'pause' }\n /** @intent(\"Toggle the marquee between playing and paused\") */\n | { type: 'toggle' }\n /** @humanOnly */\n | { type: 'hoverPause' }\n /** @humanOnly */\n | { type: 'hoverResume' }\n /** @intent(\"Change the scroll direction (left/right/up/down)\") */\n | { type: 'setDirection'; direction: MarqueeDirection }\n /** @intent(\"Change the loop duration in seconds (larger = slower)\") */\n | { type: 'setDuration'; durationSec: number }\n\nexport interface MarqueeInit {\n running?: boolean\n direction?: MarqueeDirection\n durationSec?: number\n pauseOnHover?: boolean\n disabled?: boolean\n}\n\nexport function init(opts: MarqueeInit = {}): MarqueeState {\n return {\n running: opts.running ?? true,\n direction: opts.direction ?? 'left',\n durationSec: opts.durationSec ?? 20,\n pauseOnHover: opts.pauseOnHover ?? false,\n hovered: false,\n disabled: opts.disabled ?? false,\n }\n}\n\n/** Derived: whether the marquee is currently animating. */\nexport function isRunning(state: MarqueeState): boolean {\n if (!state.running || state.disabled) return false\n if (state.pauseOnHover && state.hovered) return false\n return true\n}\n\nexport function update(state: MarqueeState, msg: MarqueeMsg): [MarqueeState, never[]] {\n if (state.disabled) return [state, []]\n switch (msg.type) {\n case 'play':\n return [{ ...state, running: true }, []]\n case 'pause':\n return [{ ...state, running: false }, []]\n case 'toggle':\n return [{ ...state, running: !state.running }, []]\n case 'hoverPause':\n return [{ ...state, hovered: true }, []]\n case 'hoverResume':\n return [{ ...state, hovered: false }, []]\n case 'setDirection':\n return [{ ...state, direction: msg.direction }, []]\n case 'setDuration':\n return [{ ...state, durationSec: Math.max(0, msg.durationSec) }, []]\n }\n}\n\n/** Returns 'normal' (left/up) or 'reverse' (right/down) for CSS animation-direction. */\nexport function cssAnimationDirection(direction: MarqueeDirection): 'normal' | 'reverse' {\n return direction === 'right' || direction === 'down' ? 'reverse' : 'normal'\n}\n\n/** Returns 'horizontal' or 'vertical' based on direction. */\nexport function axis(direction: MarqueeDirection): 'horizontal' | 'vertical' {\n return direction === 'up' || direction === 'down' ? 'vertical' : 'horizontal'\n}\n\nexport interface MarqueeParts {\n root: {\n 'data-scope': 'marquee'\n 'data-part': 'root'\n 'data-running': Signal<'' | undefined>\n 'data-direction': Signal<MarqueeDirection>\n 'data-axis': Signal<'horizontal' | 'vertical'>\n 'data-disabled': Signal<'' | undefined>\n style: Signal<string>\n onMouseEnter: (e: MouseEvent) => void\n onMouseLeave: (e: MouseEvent) => void\n }\n content: {\n 'data-scope': 'marquee'\n 'data-part': 'content'\n }\n}\n\nexport function connect(state: Signal<MarqueeState>, send: Send<MarqueeMsg>): MarqueeParts {\n return {\n root: {\n 'data-scope': 'marquee',\n 'data-part': 'root',\n 'data-running': state.map((s) => (isRunning(s) ? '' : undefined)),\n 'data-direction': state.map((s) => s.direction),\n 'data-axis': state.map((s) => axis(s.direction)),\n 'data-disabled': state.map((s) => (s.disabled ? '' : undefined)),\n style: state.map(\n (st) =>\n `--marquee-duration:${st.durationSec}s;` +\n `--marquee-direction:${cssAnimationDirection(st.direction)};` +\n `--marquee-playstate:${isRunning(st) ? 'running' : 'paused'};`,\n ),\n // Always fire hover messages; the reducer no-ops unless\n // state.pauseOnHover is true.\n onMouseEnter: tagSend(send, ['hoverPause'], () => send({ type: 'hoverPause' })),\n onMouseLeave: tagSend(send, ['hoverResume'], () => send({ type: 'hoverResume' })),\n },\n content: {\n 'data-scope': 'marquee',\n 'data-part': 'content',\n },\n }\n}\n\nexport const marquee = { init, update, connect, isRunning, cssAnimationDirection, axis }\n"]}
|