fulldev-ui 0.26.0 → 0.27.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/CHANGELOG.md +12 -0
- package/liquid/assets/data-slot-command.js +1 -1
- package/liquid/assets/data-slot-toast.js +1 -1
- package/liquid/assets/ui-carousel.css +32 -0
- package/liquid/assets/ui-carousel.js +29 -1
- package/liquid/assets/ui-controls.js +112 -0
- package/liquid/assets/ui-licenses.json +1 -1
- package/liquid/assets/ui-manifest.json +12 -10
- package/liquid/assets/ui-rating.css +5 -2
- package/liquid/contracts.json +14 -1
- package/liquid/examples/carousel.liquid +46 -0
- package/liquid/examples/dependencies.json +3 -1
- package/liquid/examples/number-field.liquid +67 -0
- package/liquid/examples/rating.liquid +11 -8
- package/liquid/examples/swatch.liquid +25 -0
- package/liquid/registry.json +39 -1
- package/liquid/snippets/ui-input-group.liquid +47 -8
- package/liquid/snippets/ui-input.liquid +3 -1
- package/liquid/snippets/ui-number-field.liquid +26 -0
- package/liquid/snippets/ui-swatch.liquid +19 -0
- package/liquid/snippets/ui.liquid +2 -0
- package/package.json +25 -25
- package/public/r/liquid/carousel.json +1 -1
- package/public/r/liquid/components.json +5 -3
- package/public/r/liquid/init.json +1 -1
- package/public/r/liquid/input-group.json +1 -1
- package/public/r/liquid/input.json +1 -1
- package/public/r/liquid/number-field.json +23 -0
- package/public/r/liquid/rating.json +1 -1
- package/public/r/liquid/registry.json +41 -1
- package/public/r/liquid/runtime.json +4 -4
- package/public/r/liquid/swatch.json +19 -0
- package/public/r/react/styles/base-luma/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-luma/components.json +3 -0
- package/public/r/react/styles/base-luma/number-field.json +26 -0
- package/public/r/react/styles/base-luma/registry.json +68 -0
- package/public/r/react/styles/base-luma/swatch.json +21 -0
- package/public/r/react/styles/base-lyra/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-lyra/components.json +3 -0
- package/public/r/react/styles/base-lyra/number-field.json +26 -0
- package/public/r/react/styles/base-lyra/registry.json +68 -0
- package/public/r/react/styles/base-lyra/swatch.json +21 -0
- package/public/r/react/styles/base-maia/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-maia/components.json +3 -0
- package/public/r/react/styles/base-maia/number-field.json +26 -0
- package/public/r/react/styles/base-maia/registry.json +68 -0
- package/public/r/react/styles/base-maia/swatch.json +21 -0
- package/public/r/react/styles/base-mira/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-mira/components.json +3 -0
- package/public/r/react/styles/base-mira/number-field.json +26 -0
- package/public/r/react/styles/base-mira/registry.json +68 -0
- package/public/r/react/styles/base-mira/swatch.json +21 -0
- package/public/r/react/styles/base-nova/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-nova/components.json +3 -0
- package/public/r/react/styles/base-nova/number-field.json +26 -0
- package/public/r/react/styles/base-nova/registry.json +68 -0
- package/public/r/react/styles/base-nova/swatch.json +21 -0
- package/public/r/react/styles/base-rhea/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-rhea/components.json +3 -0
- package/public/r/react/styles/base-rhea/number-field.json +26 -0
- package/public/r/react/styles/base-rhea/registry.json +68 -0
- package/public/r/react/styles/base-rhea/swatch.json +21 -0
- package/public/r/react/styles/base-sera/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-sera/components.json +3 -0
- package/public/r/react/styles/base-sera/number-field.json +26 -0
- package/public/r/react/styles/base-sera/registry.json +68 -0
- package/public/r/react/styles/base-sera/swatch.json +21 -0
- package/public/r/react/styles/base-vega/carousel-indicator.json +24 -0
- package/public/r/react/styles/base-vega/components.json +3 -0
- package/public/r/react/styles/base-vega/number-field.json +26 -0
- package/public/r/react/styles/base-vega/registry.json +68 -0
- package/public/r/react/styles/base-vega/swatch.json +21 -0
- package/public/r/styles/base-luma/accordion.json +1 -1
- package/public/r/styles/base-luma/alert-dialog.json +1 -1
- package/public/r/styles/base-luma/carousel.json +7 -2
- package/public/r/styles/base-luma/collapsible.json +1 -1
- package/public/r/styles/base-luma/combobox.json +2 -2
- package/public/r/styles/base-luma/command.json +2 -2
- package/public/r/styles/base-luma/components.json +2 -0
- package/public/r/styles/base-luma/dialog.json +1 -1
- package/public/r/styles/base-luma/drawer.json +1 -1
- package/public/r/styles/base-luma/dropdown-menu.json +1 -1
- package/public/r/styles/base-luma/hover-card.json +2 -2
- package/public/r/styles/base-luma/navigation-menu.json +1 -1
- package/public/r/styles/base-luma/number-field.json +44 -0
- package/public/r/styles/base-luma/popover.json +1 -1
- package/public/r/styles/base-luma/radio-group.json +1 -1
- package/public/r/styles/base-luma/registry.json +90 -26
- package/public/r/styles/base-luma/resizable.json +1 -1
- package/public/r/styles/base-luma/select.json +1 -1
- package/public/r/styles/base-luma/sheet.json +1 -1
- package/public/r/styles/base-luma/sidebar.json +1 -1
- package/public/r/styles/base-luma/slider.json +1 -1
- package/public/r/styles/base-luma/swatch.json +23 -0
- package/public/r/styles/base-luma/switch.json +1 -1
- package/public/r/styles/base-luma/tabs.json +1 -1
- package/public/r/styles/base-luma/toast.json +1 -1
- package/public/r/styles/base-luma/toggle-group.json +1 -1
- package/public/r/styles/base-luma/toggle.json +1 -1
- package/public/r/styles/base-luma/tooltip.json +1 -1
- package/public/r/styles/base-lyra/accordion.json +1 -1
- package/public/r/styles/base-lyra/alert-dialog.json +1 -1
- package/public/r/styles/base-lyra/carousel.json +7 -2
- package/public/r/styles/base-lyra/collapsible.json +1 -1
- package/public/r/styles/base-lyra/combobox.json +2 -2
- package/public/r/styles/base-lyra/command.json +2 -2
- package/public/r/styles/base-lyra/components.json +2 -0
- package/public/r/styles/base-lyra/dialog.json +1 -1
- package/public/r/styles/base-lyra/drawer.json +1 -1
- package/public/r/styles/base-lyra/dropdown-menu.json +1 -1
- package/public/r/styles/base-lyra/hover-card.json +2 -2
- package/public/r/styles/base-lyra/navigation-menu.json +1 -1
- package/public/r/styles/base-lyra/number-field.json +44 -0
- package/public/r/styles/base-lyra/popover.json +1 -1
- package/public/r/styles/base-lyra/radio-group.json +1 -1
- package/public/r/styles/base-lyra/registry.json +90 -26
- package/public/r/styles/base-lyra/resizable.json +1 -1
- package/public/r/styles/base-lyra/select.json +1 -1
- package/public/r/styles/base-lyra/sheet.json +1 -1
- package/public/r/styles/base-lyra/sidebar.json +1 -1
- package/public/r/styles/base-lyra/slider.json +1 -1
- package/public/r/styles/base-lyra/swatch.json +23 -0
- package/public/r/styles/base-lyra/switch.json +1 -1
- package/public/r/styles/base-lyra/tabs.json +1 -1
- package/public/r/styles/base-lyra/toast.json +1 -1
- package/public/r/styles/base-lyra/toggle-group.json +1 -1
- package/public/r/styles/base-lyra/toggle.json +1 -1
- package/public/r/styles/base-lyra/tooltip.json +1 -1
- package/public/r/styles/base-maia/accordion.json +1 -1
- package/public/r/styles/base-maia/alert-dialog.json +1 -1
- package/public/r/styles/base-maia/carousel.json +7 -2
- package/public/r/styles/base-maia/collapsible.json +1 -1
- package/public/r/styles/base-maia/combobox.json +2 -2
- package/public/r/styles/base-maia/command.json +2 -2
- package/public/r/styles/base-maia/components.json +2 -0
- package/public/r/styles/base-maia/dialog.json +1 -1
- package/public/r/styles/base-maia/drawer.json +1 -1
- package/public/r/styles/base-maia/dropdown-menu.json +1 -1
- package/public/r/styles/base-maia/hover-card.json +2 -2
- package/public/r/styles/base-maia/navigation-menu.json +1 -1
- package/public/r/styles/base-maia/number-field.json +44 -0
- package/public/r/styles/base-maia/popover.json +1 -1
- package/public/r/styles/base-maia/radio-group.json +1 -1
- package/public/r/styles/base-maia/registry.json +90 -26
- package/public/r/styles/base-maia/resizable.json +1 -1
- package/public/r/styles/base-maia/select.json +1 -1
- package/public/r/styles/base-maia/sheet.json +1 -1
- package/public/r/styles/base-maia/sidebar.json +1 -1
- package/public/r/styles/base-maia/slider.json +1 -1
- package/public/r/styles/base-maia/swatch.json +23 -0
- package/public/r/styles/base-maia/switch.json +1 -1
- package/public/r/styles/base-maia/tabs.json +1 -1
- package/public/r/styles/base-maia/toast.json +1 -1
- package/public/r/styles/base-maia/toggle-group.json +1 -1
- package/public/r/styles/base-maia/toggle.json +1 -1
- package/public/r/styles/base-maia/tooltip.json +1 -1
- package/public/r/styles/base-mira/accordion.json +1 -1
- package/public/r/styles/base-mira/alert-dialog.json +1 -1
- package/public/r/styles/base-mira/carousel.json +7 -2
- package/public/r/styles/base-mira/collapsible.json +1 -1
- package/public/r/styles/base-mira/combobox.json +2 -2
- package/public/r/styles/base-mira/command.json +2 -2
- package/public/r/styles/base-mira/components.json +2 -0
- package/public/r/styles/base-mira/dialog.json +1 -1
- package/public/r/styles/base-mira/drawer.json +1 -1
- package/public/r/styles/base-mira/dropdown-menu.json +1 -1
- package/public/r/styles/base-mira/hover-card.json +2 -2
- package/public/r/styles/base-mira/navigation-menu.json +1 -1
- package/public/r/styles/base-mira/number-field.json +44 -0
- package/public/r/styles/base-mira/popover.json +1 -1
- package/public/r/styles/base-mira/radio-group.json +1 -1
- package/public/r/styles/base-mira/registry.json +90 -26
- package/public/r/styles/base-mira/resizable.json +1 -1
- package/public/r/styles/base-mira/select.json +1 -1
- package/public/r/styles/base-mira/sheet.json +1 -1
- package/public/r/styles/base-mira/sidebar.json +1 -1
- package/public/r/styles/base-mira/slider.json +1 -1
- package/public/r/styles/base-mira/swatch.json +23 -0
- package/public/r/styles/base-mira/switch.json +1 -1
- package/public/r/styles/base-mira/tabs.json +1 -1
- package/public/r/styles/base-mira/toast.json +1 -1
- package/public/r/styles/base-mira/toggle-group.json +1 -1
- package/public/r/styles/base-mira/toggle.json +1 -1
- package/public/r/styles/base-mira/tooltip.json +1 -1
- package/public/r/styles/base-nova/accordion.json +1 -1
- package/public/r/styles/base-nova/alert-dialog.json +1 -1
- package/public/r/styles/base-nova/carousel.json +7 -2
- package/public/r/styles/base-nova/collapsible.json +1 -1
- package/public/r/styles/base-nova/combobox.json +2 -2
- package/public/r/styles/base-nova/command.json +2 -2
- package/public/r/styles/base-nova/components.json +2 -0
- package/public/r/styles/base-nova/dialog.json +1 -1
- package/public/r/styles/base-nova/drawer.json +1 -1
- package/public/r/styles/base-nova/dropdown-menu.json +1 -1
- package/public/r/styles/base-nova/hover-card.json +2 -2
- package/public/r/styles/base-nova/navigation-menu.json +1 -1
- package/public/r/styles/base-nova/number-field.json +44 -0
- package/public/r/styles/base-nova/popover.json +1 -1
- package/public/r/styles/base-nova/radio-group.json +1 -1
- package/public/r/styles/base-nova/registry.json +90 -26
- package/public/r/styles/base-nova/resizable.json +1 -1
- package/public/r/styles/base-nova/select.json +1 -1
- package/public/r/styles/base-nova/sheet.json +1 -1
- package/public/r/styles/base-nova/sidebar.json +1 -1
- package/public/r/styles/base-nova/slider.json +1 -1
- package/public/r/styles/base-nova/swatch.json +23 -0
- package/public/r/styles/base-nova/switch.json +1 -1
- package/public/r/styles/base-nova/tabs.json +1 -1
- package/public/r/styles/base-nova/toast.json +1 -1
- package/public/r/styles/base-nova/toggle-group.json +1 -1
- package/public/r/styles/base-nova/toggle.json +1 -1
- package/public/r/styles/base-nova/tooltip.json +1 -1
- package/public/r/styles/base-rhea/accordion.json +1 -1
- package/public/r/styles/base-rhea/alert-dialog.json +1 -1
- package/public/r/styles/base-rhea/carousel.json +7 -2
- package/public/r/styles/base-rhea/collapsible.json +1 -1
- package/public/r/styles/base-rhea/combobox.json +2 -2
- package/public/r/styles/base-rhea/command.json +2 -2
- package/public/r/styles/base-rhea/components.json +2 -0
- package/public/r/styles/base-rhea/dialog.json +1 -1
- package/public/r/styles/base-rhea/drawer.json +1 -1
- package/public/r/styles/base-rhea/dropdown-menu.json +1 -1
- package/public/r/styles/base-rhea/hover-card.json +2 -2
- package/public/r/styles/base-rhea/navigation-menu.json +1 -1
- package/public/r/styles/base-rhea/number-field.json +44 -0
- package/public/r/styles/base-rhea/popover.json +1 -1
- package/public/r/styles/base-rhea/radio-group.json +1 -1
- package/public/r/styles/base-rhea/registry.json +90 -26
- package/public/r/styles/base-rhea/resizable.json +1 -1
- package/public/r/styles/base-rhea/select.json +1 -1
- package/public/r/styles/base-rhea/sheet.json +1 -1
- package/public/r/styles/base-rhea/sidebar.json +1 -1
- package/public/r/styles/base-rhea/slider.json +1 -1
- package/public/r/styles/base-rhea/swatch.json +23 -0
- package/public/r/styles/base-rhea/switch.json +1 -1
- package/public/r/styles/base-rhea/tabs.json +1 -1
- package/public/r/styles/base-rhea/toast.json +1 -1
- package/public/r/styles/base-rhea/toggle-group.json +1 -1
- package/public/r/styles/base-rhea/toggle.json +1 -1
- package/public/r/styles/base-rhea/tooltip.json +1 -1
- package/public/r/styles/base-sera/accordion.json +1 -1
- package/public/r/styles/base-sera/alert-dialog.json +1 -1
- package/public/r/styles/base-sera/carousel.json +7 -2
- package/public/r/styles/base-sera/collapsible.json +1 -1
- package/public/r/styles/base-sera/combobox.json +2 -2
- package/public/r/styles/base-sera/command.json +2 -2
- package/public/r/styles/base-sera/components.json +2 -0
- package/public/r/styles/base-sera/dialog.json +1 -1
- package/public/r/styles/base-sera/drawer.json +1 -1
- package/public/r/styles/base-sera/dropdown-menu.json +1 -1
- package/public/r/styles/base-sera/hover-card.json +2 -2
- package/public/r/styles/base-sera/navigation-menu.json +1 -1
- package/public/r/styles/base-sera/number-field.json +44 -0
- package/public/r/styles/base-sera/popover.json +1 -1
- package/public/r/styles/base-sera/radio-group.json +1 -1
- package/public/r/styles/base-sera/registry.json +90 -26
- package/public/r/styles/base-sera/resizable.json +1 -1
- package/public/r/styles/base-sera/select.json +1 -1
- package/public/r/styles/base-sera/sheet.json +1 -1
- package/public/r/styles/base-sera/sidebar.json +1 -1
- package/public/r/styles/base-sera/slider.json +1 -1
- package/public/r/styles/base-sera/swatch.json +23 -0
- package/public/r/styles/base-sera/switch.json +1 -1
- package/public/r/styles/base-sera/tabs.json +1 -1
- package/public/r/styles/base-sera/toast.json +1 -1
- package/public/r/styles/base-sera/toggle-group.json +1 -1
- package/public/r/styles/base-sera/toggle.json +1 -1
- package/public/r/styles/base-sera/tooltip.json +1 -1
- package/public/r/styles/base-vega/accordion.json +1 -1
- package/public/r/styles/base-vega/alert-dialog.json +1 -1
- package/public/r/styles/base-vega/carousel.json +7 -2
- package/public/r/styles/base-vega/collapsible.json +1 -1
- package/public/r/styles/base-vega/combobox.json +2 -2
- package/public/r/styles/base-vega/command.json +2 -2
- package/public/r/styles/base-vega/components.json +2 -0
- package/public/r/styles/base-vega/dialog.json +1 -1
- package/public/r/styles/base-vega/drawer.json +1 -1
- package/public/r/styles/base-vega/dropdown-menu.json +1 -1
- package/public/r/styles/base-vega/hover-card.json +2 -2
- package/public/r/styles/base-vega/navigation-menu.json +1 -1
- package/public/r/styles/base-vega/number-field.json +44 -0
- package/public/r/styles/base-vega/popover.json +1 -1
- package/public/r/styles/base-vega/radio-group.json +1 -1
- package/public/r/styles/base-vega/registry.json +90 -26
- package/public/r/styles/base-vega/resizable.json +1 -1
- package/public/r/styles/base-vega/select.json +1 -1
- package/public/r/styles/base-vega/sheet.json +1 -1
- package/public/r/styles/base-vega/sidebar.json +1 -1
- package/public/r/styles/base-vega/slider.json +1 -1
- package/public/r/styles/base-vega/swatch.json +23 -0
- package/public/r/styles/base-vega/switch.json +1 -1
- package/public/r/styles/base-vega/tabs.json +1 -1
- package/public/r/styles/base-vega/toast.json +1 -1
- package/public/r/styles/base-vega/toggle-group.json +1 -1
- package/public/r/styles/base-vega/toggle.json +1 -1
- package/public/r/styles/base-vega/tooltip.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Fulldev UI
|
|
2
2
|
|
|
3
|
+
## 0.27.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#346](https://github.com/fulldotdev/ui/pull/346) [`e3b5a89`](https://github.com/fulldotdev/ui/commit/e3b5a89984888310484b84124e68702753dea4d1) Thanks [@silveltman](https://github.com/silveltman)! - In Liquid, a carousel with `data-slides='single'` exposes only its shown slide to the keyboard and screen readers, as a product gallery needs. Before, a gallery whose width had a fraction of a pixel also exposed the next slide at load. Without the attribute, every slide in view stays exposed, as in a row of cards. A Liquid rating can now show part of a star: a `rating__fill` with a width, such as 50%, clips its star instead of shrinking it.
|
|
8
|
+
|
|
9
|
+
## 0.27.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#343](https://github.com/fulldotdev/ui/pull/343) [`d61fe62`](https://github.com/fulldotdev/ui/commit/d61fe6270bdd673d1733dcdb0e2a4deb91a61b7e) Thanks [@silveltman](https://github.com/silveltman)! - Add three storefront parts in Astro, React and native Liquid: `NumberField`, a number input with decrement and increment buttons for quantities; `Swatch`, a color or image beside an option or filter value; and `CarouselIndicator`, a thumbnail that shows its slide, for a product gallery. In Astro and Liquid the number field is a native `<input type="number">` in an input group, as data-slot leaves number fields to the browser, and its buttons fire `input` and `change`; in React it is Base UI's NumberField. In Liquid an indicator can link to its slide's id, so it also works without JavaScript. In React, `CarouselIndicator` goes inside the official shadcn/ui carousel. In Liquid, a native select keeps its text clear of the arrow, and an input group addon before the input gets its padding at the start, so a start icon no longer touches the border; `data-align='inline-start'` or `'inline-end'` names the side, as in Astro. Data-slot packages move to 1.1.3.
|
|
14
|
+
|
|
3
15
|
## 0.26.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clearRootBinding as e,emit as t,ensureId as n,ensureItemVisibleInContainer as r,getDataBool as i,getDataString as a,getOwnedElements as o,getPart as s,getRoots as c,hasRootBinding as l,on as u,onRoot as d,reuseRootBinding as ee,setAria as f,setRootBinding as te}from"@data-slot/core";const p=.1,m=.999,h=/[\\/_+.#"@\[\(\{&]/,g=/[\\/_+.#"@\[\(\{&]/g,_=/[\s-]/,v=/[\s-]/g;function y(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?1:.99;let s=`${i},${a}`,c=o[s];if(c!==void 0)return c;let l=r.charAt(a),u=n.indexOf(l,i),d=0;for(;u>=0;){let s=y(e,t,n,r,u+1,a+1,o);if(s>d){if(u===i)s*=1;else if(h.test(e.charAt(u-1))){s*=.8;let t=e.slice(i,u-1).match(g);t&&i>0&&(s*=m**+t.length)}else if(_.test(e.charAt(u-1))){s*=.9;let t=e.slice(i,u-1).match(v);t&&i>0&&(s*=m**+t.length)}else s*=.17,i>0&&(s*=m**+(u-i));e.charAt(u)!==t.charAt(a)&&(s*=.9999)}if(s<p&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a)){let i=y(e,t,n,r,u+1,a+2,o);i*p>s&&(s=i*p)}s>d&&(d=s),u=n.indexOf(l,u+1)}return o[s]=d,d}function b(e){return e.toLowerCase().replace(v,` `)}function ne(e,t,n=[]){let r=n.length>0?`${e} ${n.join(` `)}`:e;return y(r,t,b(r),b(t),0,0,{})}const x=Symbol(`data-slot.command.authored-value`),S=Symbol(`data-slot.command.inferred-value`),C=e=>e==null?null:e.trim(),re=e=>e?e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean):[],ie=(e,t)=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.getAttribute(`data-slot`)===t),ae=e=>{let t=e=>e.nodeType===Node.TEXT_NODE?e.textContent??``:!(e instanceof HTMLElement)||e.getAttribute(`data-slot`)===`command-shortcut`?``:Array.from(e.childNodes,t).join(``);return t(e).replace(/\s+/g,` `).trim()},oe=e=>e.hasAttribute(`disabled`)||e.hasAttribute(`data-disabled`)||e.getAttribute(`aria-disabled`)===`true`,se=(e,t)=>{let n=e,r=e.hasAttribute(`data-value`);if(n[x]===void 0&&(n[x]=r),r?n[x]||(n[x]=C(e.getAttribute(`data-value`))!==n[S]):n[x]=!1,n[x])return{authored:!0,value:C(e.getAttribute(`data-value`))};let i=t();return n[S]=i,i===null?e.removeAttribute(`data-value`):e.setAttribute(`data-value`,i),{authored:!1,value:i}},w=`@data-slot/command`,T=`[data-slot="command-item"]`,E=`[data-slot="command-group"]`,ce=`[data-slot="command-separator"]`,le=[`input:not([type="hidden"])`,`textarea`,`select`,`button`,`a[href]`,`summary`,`audio[controls]`,`video[controls]`,`[contenteditable=""]`,`[contenteditable="true"]`,`[contenteditable="plaintext-only"]`,`[tabindex]:not([tabindex="-1"])`].join(`, `),ue=(e,t,n)=>t.trim()?ne(e,t,n??[]):1,de=(e,t)=>{let n=e;for(;n&&n.parentElement&&n.parentElement!==t;)n=n.parentElement;return n?.parentElement===t?n:null},D=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement);function O(c,l={}){let p=ee(c,w,`[@data-slot/command] createCommand() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(p)return p;let m=c,h=s(c,`command-input`),g=s(c,`command-list`);if(!h||!g)throw Error(`Command requires command-input and command-list slots`);let _=o(c,g,`[data-slot="command-empty"]`)[0]??null,v=l.label??a(m,`label`)??`Command Menu`,y=l.shouldFilter??i(m,`shouldFilter`)??!0,b=l.loop??i(m,`loop`)??!1,ne=l.disablePointerSelection??i(m,`disablePointerSelection`)??!1,x=l.vimBindings??i(m,`vimBindings`)??!0,S=l.filter??ue,O=l.onValueChange,fe=l.onSearchChange,pe=l.onSelect,k=C(l.defaultValue??a(m,`defaultValue`)),A=l.defaultSearch??a(m,`defaultSearch`)??``,j=[],M=[],N=[],P=new Map,F=new Map,I=0,L=[],R=null,z=null,B=!1,V=!1,me=!1,H=[],U=new Map,W=!1,he=n(h,`command-input`),ge=n(g,`command-list`);m.hasAttribute(`tabindex`)||(m.tabIndex=-1,me=!0),h.setAttribute(`role`,`combobox`),h.setAttribute(`aria-autocomplete`,`list`),h.setAttribute(`aria-expanded`,`true`),h.setAttribute(`aria-controls`,ge),h.setAttribute(`autocomplete`,`off`),h.setAttribute(`autocorrect`,`off`),h.spellcheck=!1,g.setAttribute(`role`,`listbox`),g.tabIndex=-1;let _e=document.querySelector(`label[for="${CSS.escape(he)}"]`);if(_e){let e=n(_e,`command-label`),t=h.getAttribute(`aria-labelledby`);h.setAttribute(`aria-labelledby`,t?`${t} ${e}`:e),g.setAttribute(`aria-labelledby`,e)}else !h.hasAttribute(`aria-label`)&&!h.hasAttribute(`aria-labelledby`)&&(h.setAttribute(`aria-label`,v),g.setAttribute(`aria-label`,`Suggestions`));let ve=()=>{document.activeElement!==h&&h.focus({preventScroll:!0})},ye=e=>{if(!(e instanceof HTMLElement)||!m.contains(e))return null;let t=e.closest(le);return t instanceof HTMLElement&&m.contains(t)?t:null},be=e=>{R?.disconnect();try{return e()}finally{He()}},xe=()=>{g.style.setProperty(`--command-list-height`,`${g.scrollHeight.toFixed(1)}px`)},Se=(e,t)=>{let n=e.filter(e=>t.includes(e));for(let e of t){if(n.includes(e))continue;let r=t.indexOf(e),i=!1;for(let a=r-1;a>=0;--a){let r=t[a];if(!r)continue;let o=n.indexOf(r);if(o!==-1){n.splice(o+1,0,e),i=!0;break}}if(!i){for(let a=r+1;a<t.length;a+=1){let r=t[a];if(!r)continue;let o=n.indexOf(r);if(o!==-1){n.splice(o,0,e),i=!0;break}}i||n.push(e)}}return n},Ce=()=>{H=D(g),U=new Map(M.map(e=>[e.el,D(e.el)]))},we=()=>{H=Se(H,D(g)),U=new Map(M.map(e=>[e.el,Se(U.get(e.el)??[],D(e.el))]))},G=(e,t)=>{let n=new Set(t.filter(t=>t.parentElement===e)),r=e.firstElementChild;for(let t of[...n,...D(e).filter(e=>!n.has(e))])t===r?r=r.nextElementSibling:e.insertBefore(t,r)},Te=e=>new Map(e.map((e,t)=>[e,t])),Ee=()=>{for(let e of M)G(e.el,U.get(e.el)??[]);G(g,H)},K=()=>k===null?null:j.find(e=>e.value===k&&!e.el.hidden&&!(e.group?.el.hidden??!1))?.el??null,De=()=>{for(let e of j){let t=e.value===k&&k!==null;e.el.hasAttribute(`data-selected`)!==t&&(f(e.el,`selected`,t),t?e.el.setAttribute(`data-selected`,`true`):e.el.removeAttribute(`data-selected`))}let e=K();e?(h.setAttribute(`aria-activedescendant`,e.id),g.setAttribute(`aria-activedescendant`,e.id)):(h.removeAttribute(`aria-activedescendant`),g.removeAttribute(`aria-activedescendant`))},Oe=()=>{k===null?m.removeAttribute(`data-value`):m.setAttribute(`data-value`,k),A?m.setAttribute(`data-search`,A):m.removeAttribute(`data-search`)},ke=()=>[...g.querySelectorAll(T)].map(e=>P.get(e)??null).filter(e=>e!==null&&!e.el.hidden&&!(e.group?.el.hidden??!1)),q=()=>ke().filter(e=>!e.disabled),Ae=(e,n,r)=>{!r||e===n||(t(m,`command:change`,{value:n}),O?.(n))},je=()=>{let e=K();e&&r(e,g)},J=(e,t={})=>{let n=C(e),r=k,i=t.emit??!0,a=t.ensureVisible??!1;return k=n,De(),Oe(),a&&je(),(document.activeElement===h||document.activeElement===m)&&ve(),Ae(r,k,i),r!==k},Me=()=>{j=[],M=[],P=new Map,F=new Map;for(let e of o(m,g,E)){let t=ie(e,`command-group-heading`)[0]??null,r={el:e,heading:t,value:se(e,()=>C(t?.textContent)??n(e,`command-group`)).value??n(e,`command-group`),forceMount:i(e,`forceMount`)??!1,maxRank:0};if(F.set(e,r),M.push(r),e.setAttribute(`role`,`group`),t){let r=n(t,`command-group-heading`);e.setAttribute(`aria-labelledby`,r)}else e.removeAttribute(`aria-labelledby`)}for(let e of o(m,g,T)){let t=e.closest(E),r=t instanceof HTMLElement&&t.closest(`[data-slot="command"]`)===m?F.get(t)??null:null,a={el:e,value:se(e,()=>C(e.getAttribute(`data-label`))??C(ae(e))).value,keywords:re(e.getAttribute(`data-keywords`)??void 0),disabled:oe(e),forceMount:i(e,`forceMount`)??!1,rank:0,group:r};P.set(e,a),j.push(a),n(e,`command-item`),e.setAttribute(`role`,`option`),f(e,`selected`,!1),f(e,`disabled`,a.disabled||null),e.removeAttribute(`data-selected`)}N=o(m,g,ce);for(let e of N)e.setAttribute(`role`,`separator`)},Ne=()=>{let e=A.length>0,t=y&&e;I=0;for(let e of M)e.maxRank=0;for(let e of j)e.rank=t&&e.value!==null?S(e.value,A,e.keywords):1,e.rank>0&&(I+=1),e.el.hidden=!(e.forceMount||e.group?.forceMount||e.rank>0),e.group&&e.rank>e.group.maxRank&&(e.group.maxRank=e.rank);for(let e of M)e.el.hidden=t&&!e.forceMount&&e.maxRank<=0;for(let t of N)t.hidden=e&&!(i(t,`alwaysRender`)??!1);_&&(_.hidden=I>0)},Pe=()=>{if(!y||!A)return;let e=H.filter(e=>e.parentElement===g),t=Te(e),n=new Map,r=new Map;for(let e of j){if(e.group!==null)continue;let t=de(e.el,g);t&&(n.set(t,Math.max(n.get(t)??0,e.rank)),e.el.hidden||r.set(t,Math.max(r.get(t)??0,e.rank)))}let i=new Set([...n.keys(),...M.map(e=>e.el)]),a=[...Array.from(r,([e,t])=>({el:e,rank:t})),...M.filter(e=>!e.el.hidden).map(e=>({el:e.el,rank:e.maxRank}))].sort((e,n)=>n.rank===e.rank?(t.get(e.el)??2**53-1)-(t.get(n.el)??2**53-1):n.rank-e.rank),o=new Set(a.map(e=>e.el)),s=D(g).filter(e=>i.has(e)&&!o.has(e)),c=[...a.map(e=>e.el),...s],l=0;G(g,e.map(e=>i.has(e)?c[l++]??e:e));for(let e of M){let t=U.get(e.el)?.filter(t=>t.parentElement===e.el)??[],n=Te(t),r=new Set,i=new Map;for(let t of j){if(t.group!==e)continue;let n=de(t.el,e.el);n&&(r.add(n),t.el.hidden||i.set(n,Math.max(i.get(n)??0,t.rank)))}let a=Array.from(i,([e,t])=>({el:e,rank:t})).sort((e,t)=>t.rank===e.rank?(n.get(e.el)??2**53-1)-(n.get(t.el)??2**53-1):t.rank-e.rank),o=new Set(a.map(e=>e.el)),s=D(e.el).filter(e=>r.has(e)&&!o.has(e)),c=[...a.map(e=>e.el),...s],l=0,u=t.map(e=>r.has(e)?c[l++]??e:e);G(e.el,u)}},Fe=()=>{be(()=>{y&&A?(Ne(),Pe(),W=!0):(W&&Ee(),Ne(),W=!1),De(),Oe()}),z||xe()},Y=()=>{if(be(Me),W?we():Ce(),Fe(),!(typeof ResizeObserver>`u`)){z??=new ResizeObserver(xe),z.disconnect();for(let e of[g,...o(m,g,`${T}, ${E}, ${ce}, [data-slot="command-empty"]`)])z.observe(e)}},Ie=(e=!0,t=!1)=>{J(q()[0]?.value??null,{emit:e,ensureVisible:t})},X=(e,n=!0,r=!0)=>{A!==e&&(A=e,h.value=e,Fe(),r&&Ie(n,!0),n&&(t(m,`command:search-change`,{search:A}),fe?.(A)))},Le=e=>{e.value===null||e.disabled||(J(e.value,{emit:!0}),t(m,`command:select`,{value:e.value}),pe?.(e.value))},Re=e=>{let t=P.get(e)??null;return t||(Y(),t=P.get(e)??null,t)},Z=e=>{let t=q()[e];t&&J(t.value,{emit:!0,ensureVisible:!0})},Q=e=>{let t=q();if(t.length===0)return;let n=t.findIndex(e=>e.value===k),r=t[n+e];b&&(r=n+e<0?t[t.length-1]:n+e===t.length?t[0]:t[n+e]),r&&J(r.value,{emit:!0,ensureVisible:!0})},ze=e=>{let t=K()?.closest(E);for(;t;){let n=e>0?t.nextElementSibling:t.previousElementSibling,r=null;for(;n;){if(n instanceof HTMLElement&&n.getAttribute(`data-slot`)===`command-group`&&!n.hidden){r=n;break}n=e>0?n.nextElementSibling:n.previousElementSibling}if(!r)break;let i=[...r.querySelectorAll(T)].map(e=>P.get(e)??null).find(e=>e!==null&&!e.disabled&&!e.el.hidden);if(i){J(i.value,{emit:!0,ensureVisible:!0});return}t=r}Q(e)},Be=e=>{if(e.defaultPrevented)return;let t=ye(e.target);if(t&&t!==h)return;let n=e.key.toLowerCase();if(e.isComposing||e.keyCode===229)return;let r=()=>{e.preventDefault(),e.metaKey?Z(q().length-1):e.altKey?ze(1):Q(1)},i=()=>{e.preventDefault(),e.metaKey?Z(0):e.altKey?ze(-1):Q(-1)};switch(n){case`arrowdown`:r();break;case`arrowup`:i();break;case`home`:e.preventDefault(),Z(0);break;case`end`:e.preventDefault(),Z(q().length-1);break;case`enter`:{let t=K(),n=t?P.get(t):null;if(!n||n.value===null)return;e.preventDefault(),Le(n);break}case`j`:case`n`:x&&e.ctrlKey&&r();break;case`k`:case`p`:x&&e.ctrlKey&&i();break}},Ve=()=>{B||V||(B=!0,queueMicrotask(()=>{if(B=!1,V)return;let e=K();Y();let t=e?P.get(e)??null:null;if(t&&t.value!==null&&!t.disabled&&!t.el.hidden&&!(t.group?.el.hidden??!1)){J(t.value,{emit:!0});return}if(k!==null){let e=q().find(e=>e.value===k)??null;if(e){J(e.value,{emit:!0});return}}J(q()[0]?.value??null,{emit:!0})}))},He=()=>{R&&R.observe(g,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`data-slot`,`data-value`,`data-label`,`data-keywords`,`data-disabled`,`disabled`,`aria-disabled`,`data-force-mount`,`data-always-render`]})};typeof MutationObserver<`u`&&(R=new MutationObserver(()=>{Ve()}),He()),h.value=A,Y(),(A||k===null)&&Ie(!1),L.push(u(h,`input`,()=>{X(h.value,!0,!0)})),L.push(u(m,`keydown`,e=>{Be(e)})),L.push(u(g,`pointermove`,e=>{if(ne)return;let t=e.target,n=t instanceof HTMLElement?t.closest(T):null;if(!(n instanceof HTMLElement))return;let r=Re(n);!r||r.disabled||n.hidden||r.group?.el.hidden||J(r.value,{emit:!0})})),L.push(u(g,`click`,e=>{let t=e.target,n=ye(t),r=t instanceof HTMLElement?t.closest(T):null;if(n&&n!==r||!(r instanceof HTMLElement))return;let i=Re(r);!i||i.disabled||i.value===null||r.hidden||i.group?.el.hidden||Le(i)})),L.push(d(m,`command:set`,e=>{let t=e.detail;t&&(t.search!==void 0&&X(String(t.search),!0,t.value===void 0),t.value!==void 0&&J(t.value,{emit:!0,ensureVisible:!0}))}));let $={get value(){return k},get search(){return A},select(e){J(e,{emit:!0,ensureVisible:!0})},setSearch(e){X(e,!0,!0)},destroy(){V=!0,R?.disconnect(),z?.disconnect(),L.forEach(e=>e()),L=[],me&&m.removeAttribute(`tabindex`),e(m,w,$)}};return te(m,w,$),$}function fe(e=document){let t=[];for(let n of c(e,`command`))l(n,w)||t.push(O(n));return t}export{fe as create,O as createCommand};
|
|
1
|
+
import{clearRootBinding as e,emit as t,ensureId as n,ensureItemVisibleInContainer as r,getDataBool as i,getDataString as a,getOwnedElements as o,getPart as s,getRoots as c,hasRootBinding as l,on as u,onRoot as d,reuseRootBinding as ee,setAria as f,setRootBinding as te}from"@data-slot/core";const p=.1,m=.999,h=/[\\/_+.#"@\[\(\{&]/,g=/[\\/_+.#"@\[\(\{&]/g,_=/[\s-]/,v=/[\s-]/g;function y(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?1:.99;let s=`${i},${a}`,c=o[s];if(c!==void 0)return c;let l=r.charAt(a),u=n.indexOf(l,i),d=0;for(;u>=0;){let s=y(e,t,n,r,u+1,a+1,o);if(s>d){if(u===i)s*=1;else if(h.test(e.charAt(u-1))){s*=.8;let t=e.slice(i,u-1).match(g);t&&i>0&&(s*=m**+t.length)}else if(_.test(e.charAt(u-1))){s*=.9;let t=e.slice(i,u-1).match(v);t&&i>0&&(s*=m**+t.length)}else s*=.17,i>0&&(s*=m**+(u-i));e.charAt(u)!==t.charAt(a)&&(s*=.9999)}if(s<p&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a)){let i=y(e,t,n,r,u+1,a+2,o);i*p>s&&(s=i*p)}s>d&&(d=s),u=n.indexOf(l,u+1)}return o[s]=d,d}function b(e){return e.toLowerCase().replace(v,` `)}function ne(e,t,n=[]){let r=n.length>0?`${e} ${n.join(` `)}`:e;return y(r,t,b(r),b(t),0,0,{})}const x=Symbol(`data-slot.command.authored-value`),S=Symbol(`data-slot.command.inferred-value`),C=e=>e==null?null:e.trim(),re=e=>e?e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean):[],ie=(e,t)=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.getAttribute(`data-slot`)===t),ae=e=>{let t=e=>e.nodeType===Node.TEXT_NODE?e.textContent??``:!(e instanceof HTMLElement)||e.getAttribute(`data-slot`)===`command-shortcut`?``:Array.from(e.childNodes,t).join(``);return t(e).replace(/\s+/g,` `).trim()},oe=e=>e.hasAttribute(`disabled`)||e.hasAttribute(`data-disabled`)||e.getAttribute(`aria-disabled`)===`true`,se=(e,t)=>{let n=e,r=e.hasAttribute(`data-value`);if(n[x]===void 0&&(n[x]=r),r?n[x]||(n[x]=C(e.getAttribute(`data-value`))!==n[S]):n[x]=!1,n[x])return{authored:!0,value:C(e.getAttribute(`data-value`))};let i=t();return n[S]=i,i===null?e.removeAttribute(`data-value`):e.setAttribute(`data-value`,i),{authored:!1,value:i}},w=`@data-slot/command`,T=`[data-slot="command-item"]`,E=`[data-slot="command-group"]`,ce=`[data-slot="command-separator"]`,le=[`input:not([type="hidden"])`,`textarea`,`select`,`button`,`a[href]`,`summary`,`audio[controls]`,`video[controls]`,`[contenteditable=""]`,`[contenteditable="true"]`,`[contenteditable="plaintext-only"]`,`[tabindex]:not([tabindex="-1"])`].join(`, `),ue=(e,t,n)=>t.trim()?ne(e,t,n??[]):1,de=(e,t)=>{let n=e;for(;n&&n.parentElement&&n.parentElement!==t;)n=n.parentElement;return n?.parentElement===t?n:null},D=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement);function O(c,l={}){let p=ee(c,w,`[@data-slot/command] createCommand() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(p)return p;let m=c,h=s(c,`command-input`),g=s(c,`command-list`);if(!h||!g)throw Error(`Command requires command-input and command-list slots`);let _=o(c,g,`[data-slot="command-empty"]`)[0]??null,v=l.label??a(m,`label`)??`Command Menu`,y=l.shouldFilter??i(m,`shouldFilter`)??!0,b=l.loop??i(m,`loop`)??!1,ne=l.disablePointerSelection??i(m,`disablePointerSelection`)??!1,x=l.vimBindings??i(m,`vimBindings`)??!0,S=l.filter??ue,O=l.onValueChange,fe=l.onSearchChange,pe=l.onSelect,k=C(l.defaultValue??a(m,`defaultValue`)),A=l.defaultSearch??a(m,`defaultSearch`)??``,j=[],M=[],N=[],P=new Map,F=new Map,I=0,L=[],R=null,z=null,B=!1,V=!1,me=!1,H=[],U=new Map,W=!1,he=n(h,`command-input`),ge=n(g,`command-list`);m.hasAttribute(`tabindex`)||(m.tabIndex=-1,me=!0),h.setAttribute(`role`,`combobox`),h.setAttribute(`aria-autocomplete`,`list`),h.setAttribute(`aria-expanded`,`true`),h.setAttribute(`aria-controls`,ge),h.setAttribute(`autocomplete`,`off`),h.setAttribute(`autocorrect`,`off`),h.spellcheck=!1,g.setAttribute(`role`,`listbox`),g.tabIndex=-1;let _e=document.querySelector(`label[for="${CSS.escape(he)}"]`);if(_e){let e=n(_e,`command-label`),t=h.getAttribute(`aria-labelledby`);h.setAttribute(`aria-labelledby`,t?`${t} ${e}`:e),g.setAttribute(`aria-labelledby`,e)}else !h.hasAttribute(`aria-label`)&&!h.hasAttribute(`aria-labelledby`)&&(h.setAttribute(`aria-label`,v),g.setAttribute(`aria-label`,`Suggestions`));let ve=()=>{document.activeElement!==h&&h.focus({preventScroll:!0})},ye=e=>{if(!(e instanceof HTMLElement)||!m.contains(e))return null;let t=e.closest(le);return t instanceof HTMLElement&&m.contains(t)?t:null},be=e=>{R?.disconnect();try{return e()}finally{He()}},xe=()=>{g.style.setProperty(`--command-list-height`,`${g.scrollHeight.toFixed(1)}px`)},Se=(e,t)=>{let n=e.filter(e=>t.includes(e));for(let e of t){if(n.includes(e))continue;let r=t.indexOf(e),i=!1;for(let a=r-1;a>=0;--a){let r=t[a];if(!r)continue;let o=n.indexOf(r);if(o!==-1){n.splice(o+1,0,e),i=!0;break}}if(!i){for(let a=r+1;a<t.length;a+=1){let r=t[a];if(!r)continue;let o=n.indexOf(r);if(o!==-1){n.splice(o,0,e),i=!0;break}}i||n.push(e)}}return n},Ce=()=>{H=D(g),U=new Map(M.map(e=>[e.el,D(e.el)]))},we=()=>{H=Se(H,D(g)),U=new Map(M.map(e=>[e.el,Se(U.get(e.el)??[],D(e.el))]))},G=(e,t)=>{let n=new Set(t.filter(t=>t.parentElement===e)),r=e.firstElementChild;for(let t of[...n,...D(e).filter(e=>!n.has(e))])t===r?r=r.nextElementSibling:e.insertBefore(t,r)},Te=e=>new Map(e.map((e,t)=>[e,t])),Ee=()=>{for(let e of M)G(e.el,U.get(e.el)??[]);G(g,H)},K=()=>k===null?null:j.find(e=>e.value===k&&!e.el.hidden&&!(e.group?.el.hidden??!1))?.el??null,De=()=>{for(let e of j){let t=e.value===k&&k!==null;e.el.hasAttribute(`data-selected`)!==t&&(f(e.el,`selected`,t),t?e.el.setAttribute(`data-selected`,`true`):e.el.removeAttribute(`data-selected`))}let e=K();e?(h.setAttribute(`aria-activedescendant`,e.id),g.setAttribute(`aria-activedescendant`,e.id)):(h.removeAttribute(`aria-activedescendant`),g.removeAttribute(`aria-activedescendant`))},Oe=()=>{k===null?m.removeAttribute(`data-value`):m.setAttribute(`data-value`,k),A?m.setAttribute(`data-search`,A):m.removeAttribute(`data-search`)},ke=()=>[...g.querySelectorAll(T)].map(e=>P.get(e)??null).filter(e=>e!==null&&!e.el.hidden&&!(e.group?.el.hidden??!1)),q=()=>ke().filter(e=>!e.disabled),Ae=(e,n,r)=>{!r||e===n||(t(m,`command:change`,{value:n}),O?.(n))},je=()=>{let e=K();e&&r(e,g)},J=(e,t={})=>{let n=C(e),r=k,i=t.emit??!0,a=t.ensureVisible??!1;return k=n,De(),Oe(),a&&je(),(document.activeElement===h||document.activeElement===m)&&ve(),Ae(r,k,i),r!==k},Me=()=>{j=[],M=[],P=new Map,F=new Map;for(let e of o(m,g,E)){let t=ie(e,`command-group-heading`)[0]??null,r={el:e,heading:t,value:se(e,()=>C(t?.textContent)??n(e,`command-group`)).value??n(e,`command-group`),forceMount:i(e,`forceMount`)??!1,maxRank:0};if(F.set(e,r),M.push(r),e.setAttribute(`role`,`group`),t){let r=n(t,`command-group-heading`);e.setAttribute(`aria-labelledby`,r)}else e.removeAttribute(`aria-labelledby`)}for(let e of o(m,g,T)){let t=e.closest(E),r=t instanceof HTMLElement&&t.closest(`[data-slot="command"]`)===m?F.get(t)??null:null,a={el:e,value:se(e,()=>C(e.getAttribute(`data-label`))??C(ae(e))).value,keywords:re(e.getAttribute(`data-keywords`)??void 0),disabled:oe(e),forceMount:i(e,`forceMount`)??!1,rank:0,group:r};P.set(e,a),j.push(a),n(e,`command-item`),e.setAttribute(`role`,`option`),f(e,`selected`,!1),f(e,`disabled`,a.disabled||null),e.removeAttribute(`data-selected`)}N=o(m,g,ce);for(let e of N)e.setAttribute(`role`,`separator`)},Ne=()=>{let e=A.length>0,t=y&&e;I=0;for(let e of M)e.maxRank=0;for(let e of j)e.rank=t&&e.value!==null?S(e.value,A,e.keywords):1,e.rank>0&&(I+=1),e.el.hidden=!(e.forceMount||e.group?.forceMount||e.rank>0),e.group&&e.rank>e.group.maxRank&&(e.group.maxRank=e.rank);for(let e of M)e.el.hidden=t&&!e.forceMount&&e.maxRank<=0;for(let t of N)t.hidden=e&&!(i(t,`alwaysRender`)??!1);_&&(_.hidden=I>0)},Pe=()=>{if(!y||!A)return;let e=H.filter(e=>e.parentElement===g),t=Te(e),n=new Map,r=new Map;for(let e of j){if(e.group!==null)continue;let t=de(e.el,g);t&&(n.set(t,Math.max(n.get(t)??0,e.rank)),e.el.hidden||r.set(t,Math.max(r.get(t)??0,e.rank)))}let i=new Set([...n.keys(),...M.map(e=>e.el)]),a=[...Array.from(r,([e,t])=>({el:e,rank:t})),...M.filter(e=>!e.el.hidden).map(e=>({el:e.el,rank:e.maxRank}))].sort((e,n)=>n.rank===e.rank?(t.get(e.el)??2**53-1)-(t.get(n.el)??2**53-1):n.rank-e.rank),o=new Set(a.map(e=>e.el)),s=D(g).filter(e=>i.has(e)&&!o.has(e)),c=[...a.map(e=>e.el),...s],l=0;G(g,e.map(e=>i.has(e)?c[l++]??e:e));for(let e of M){let t=U.get(e.el)?.filter(t=>t.parentElement===e.el)??[],n=Te(t),r=new Set,i=new Map;for(let t of j){if(t.group!==e)continue;let n=de(t.el,e.el);n&&(r.add(n),t.el.hidden||i.set(n,Math.max(i.get(n)??0,t.rank)))}let a=Array.from(i,([e,t])=>({el:e,rank:t})).sort((e,t)=>t.rank===e.rank?(n.get(e.el)??2**53-1)-(n.get(t.el)??2**53-1):t.rank-e.rank),o=new Set(a.map(e=>e.el)),s=D(e.el).filter(e=>r.has(e)&&!o.has(e)),c=[...a.map(e=>e.el),...s],l=0,u=t.map(e=>r.has(e)?c[l++]??e:e);G(e.el,u)}},Fe=()=>{be(()=>{y&&A?(Ne(),Pe(),W=!0):(W&&Ee(),Ne(),W=!1),De(),Oe()}),typeof ResizeObserver>`u`&&xe()},Y=()=>{if(be(Me),W?we():Ce(),Fe(),!(typeof ResizeObserver>`u`)){z??=new ResizeObserver(xe),z.disconnect();for(let e of[g,...o(m,g,`${T}, ${E}, ${ce}, [data-slot="command-empty"]`)])z.observe(e)}},Ie=(e=!0,t=!1)=>{J(q()[0]?.value??null,{emit:e,ensureVisible:t})},X=(e,n=!0,r=!0)=>{A!==e&&(A=e,h.value=e,Fe(),r&&Ie(n,!0),n&&(t(m,`command:search-change`,{search:A}),fe?.(A)))},Le=e=>{e.value===null||e.disabled||(J(e.value,{emit:!0}),t(m,`command:select`,{value:e.value}),pe?.(e.value))},Re=e=>{let t=P.get(e)??null;return t||(Y(),t=P.get(e)??null,t)},Z=e=>{let t=q()[e];t&&J(t.value,{emit:!0,ensureVisible:!0})},Q=e=>{let t=q();if(t.length===0)return;let n=t.findIndex(e=>e.value===k),r=t[n+e];b&&(r=n+e<0?t[t.length-1]:n+e===t.length?t[0]:t[n+e]),r&&J(r.value,{emit:!0,ensureVisible:!0})},ze=e=>{let t=K()?.closest(E);for(;t;){let n=e>0?t.nextElementSibling:t.previousElementSibling,r=null;for(;n;){if(n instanceof HTMLElement&&n.getAttribute(`data-slot`)===`command-group`&&!n.hidden){r=n;break}n=e>0?n.nextElementSibling:n.previousElementSibling}if(!r)break;let i=[...r.querySelectorAll(T)].map(e=>P.get(e)??null).find(e=>e!==null&&!e.disabled&&!e.el.hidden);if(i){J(i.value,{emit:!0,ensureVisible:!0});return}t=r}Q(e)},Be=e=>{if(e.defaultPrevented)return;let t=ye(e.target);if(t&&t!==h)return;let n=e.key.toLowerCase();if(e.isComposing||e.keyCode===229)return;let r=()=>{e.preventDefault(),e.metaKey?Z(q().length-1):e.altKey?ze(1):Q(1)},i=()=>{e.preventDefault(),e.metaKey?Z(0):e.altKey?ze(-1):Q(-1)};switch(n){case`arrowdown`:r();break;case`arrowup`:i();break;case`home`:e.preventDefault(),Z(0);break;case`end`:e.preventDefault(),Z(q().length-1);break;case`enter`:{let t=K(),n=t?P.get(t):null;if(!n||n.value===null)return;e.preventDefault(),Le(n);break}case`j`:case`n`:x&&e.ctrlKey&&r();break;case`k`:case`p`:x&&e.ctrlKey&&i();break}},Ve=()=>{B||V||(B=!0,queueMicrotask(()=>{if(B=!1,V)return;let e=K();Y();let t=e?P.get(e)??null:null;if(t&&t.value!==null&&!t.disabled&&!t.el.hidden&&!(t.group?.el.hidden??!1)){J(t.value,{emit:!0});return}if(k!==null){let e=q().find(e=>e.value===k)??null;if(e){J(e.value,{emit:!0});return}}J(q()[0]?.value??null,{emit:!0})}))},He=()=>{R&&R.observe(g,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`data-slot`,`data-value`,`data-label`,`data-keywords`,`data-disabled`,`disabled`,`aria-disabled`,`data-force-mount`,`data-always-render`]})};typeof MutationObserver<`u`&&(R=new MutationObserver(()=>{Ve()}),He()),h.value=A,Y(),(A||k===null)&&Ie(!1),L.push(u(h,`input`,()=>{X(h.value,!0,!0)})),L.push(u(m,`keydown`,e=>{Be(e)})),L.push(u(g,`pointermove`,e=>{if(ne)return;let t=e.target,n=t instanceof HTMLElement?t.closest(T):null;if(!(n instanceof HTMLElement))return;let r=Re(n);!r||r.disabled||n.hidden||r.group?.el.hidden||J(r.value,{emit:!0})})),L.push(u(g,`click`,e=>{let t=e.target,n=ye(t),r=t instanceof HTMLElement?t.closest(T):null;if(n&&n!==r||!(r instanceof HTMLElement))return;let i=Re(r);!i||i.disabled||i.value===null||r.hidden||i.group?.el.hidden||Le(i)})),L.push(d(m,`command:set`,e=>{let t=e.detail;t&&(t.search!==void 0&&X(String(t.search),!0,t.value===void 0),t.value!==void 0&&J(t.value,{emit:!0,ensureVisible:!0}))}));let $={get value(){return k},get search(){return A},select(e){J(e,{emit:!0,ensureVisible:!0})},setSearch(e){X(e,!0,!0)},destroy(){V=!0,R?.disconnect(),z?.disconnect(),L.forEach(e=>e()),L=[],me&&m.removeAttribute(`tabindex`),e(m,w,$)}};return te(m,w,$),$}function fe(e=document){let t=[];for(let n of c(e,`command`))l(n,w)||t.push(O(n));return t}export{fe as create,O as createCommand};
|
|
@@ -5,4 +5,4 @@ import{clearRootBinding as e,createPortalLifecycle as t,createPresenceLifecycle
|
|
|
5
5
|
<button data-slot="toast-action" type="button"></button>
|
|
6
6
|
<button data-slot="toast-close" type="button" aria-label="Close">×</button>
|
|
7
7
|
</li>
|
|
8
|
-
`,t},N=(e,t)=>{e.setAttribute(`data-state`,t),t===`open`?(e.setAttribute(`data-open`,``),e.removeAttribute(`data-closed`)):(e.setAttribute(`data-closed`,``),e.removeAttribute(`data-open`))},P=(e,t)=>{t===`error`||t===`warning`?(e.setAttribute(`role`,`alert`),e.setAttribute(`aria-live`,`assertive`)):(e.setAttribute(`role`,`status`),e.setAttribute(`aria-live`,`polite`)),e.setAttribute(`aria-atomic`,`true`)};function fe(e,t){let{viewport:r}=t,a=(A(t.template)&&j(t.template)?t.template:M(r.ownerDocument)).content.cloneNode(!0),o=a.querySelector(`[data-slot="toast-item"]`),s=new WeakMap,c=i(),l=e,u=!1,d=t.paused,f=null,p=l.duration,m=0,h=(e,t)=>{let n=e.querySelector(`[data-slot="toast-title"]`),r=e.querySelector(`[data-slot="toast-description"]`),i=e.querySelector(`[data-slot="toast-action"]`),a=e.querySelector(`[data-slot="toast-close"]`);if(n&&(n.textContent=t.title,n.hidden=!1),r&&(t.description&&t.description.trim()!==``?(r.textContent=t.description,r.hidden=!1):(r.textContent=``,r.hidden=!0)),i&&(t.action?.label&&t.action.label.trim()!==``?(i.textContent=t.action.label,i.hidden=!1):(i.textContent=``,i.hidden=!0)),e.setAttribute(`data-type`,t.type),t.dismissible?e.removeAttribute(`data-dismissible`):e.setAttribute(`data-dismissible`,`false`),t.testId&&t.testId.trim()!==``?e.setAttribute(`data-testid`,t.testId):e.removeAttribute(`data-testid`),a){if(s.has(a)||s.set(a,a.getAttribute(`aria-label`)),t.closeButtonAriaLabel&&t.closeButtonAriaLabel.trim()!==``)a.setAttribute(`aria-label`,t.closeButtonAriaLabel);else{let e=s.get(a);e&&e.trim()!==``?a.setAttribute(`aria-label`,e):a.setAttribute(`aria-label`,`Close`)}a.getAttribute(`aria-label`)||a.setAttribute(`aria-label`,`Close`)}P(e,t.type)},g=()=>{c.cancelTimeout(f),f=null},_=()=>{if(!(!y.active||d||l.duration<=0||f!==null)){if(p<=0){t.onTimeout(y);return}m=Date.now(),f=c.trackTimeout(()=>{f=null,t.onTimeout(y)},p)}},v=n({element:o,win:r.ownerDocument.defaultView??window,onExitComplete:()=>{c.isDestroyed||t.onExitComplete(y)}});c.onDestroy(()=>{v.cleanup(),o.remove()});let y={get id(){return l.id},element:o,get toast(){return l},get active(){return!u&&!c.isDestroyed},get exiting(){return u},mount(){r.appendChild(a),c.trackRaf(()=>{c.trackRaf(()=>{y.active&&o.setAttribute(`data-mounted`,`true`)})}),_()},update(e){y.active&&(l=ae(l,e),h(o,l),e.duration!==void 0&&(g(),p=l.duration,_()))},setPaused(e){d===e||!y.active||(d=e,d?(f!==null&&(p=Math.max(0,p-(Date.now()-m))),g()):_())},dismiss(){y.active&&(u=!0,g(),o.setAttribute(`data-removed`,`true`),o.style.zIndex=`0`,o.style.pointerEvents=`none`,N(o,`closed`),v.exit())},destroy(){c.destroy()}};o.setAttribute(`data-id`,l.id),h(o,l);for(let e of[`mounted`,`removed`,`front`,`visible`,`swiping`,`swipe-out`])o.setAttribute(`data-${e}`,`false`);o.setAttribute(`data-expanded`,String(t.expanded));for(let e of[`amount-x`,`amount-y`,`end-x`,`end-y`])o.style.setProperty(`--toast-swipe-${e}`,`0px`);return N(o,`open`),y}const F=`data-toast-prev-tabindex`,I=`__none__`,pe=e=>{let t=getComputedStyle(e).getPropertyValue(`--toast-gap`).trim();if(!t)return 8;let n=Number.parseFloat(t);return Number.isFinite(n)?n:8},L=e=>{let t=getComputedStyle(e).getPropertyValue(`--toast-collapsed-peek`).trim();if(!t)return 14;let n=Number.parseFloat(t);return Number.isFinite(n)?Math.max(0,n):14},R=e=>{let t=e.cloneNode(!0);t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`inert`,``),t.style.width=getComputedStyle(e).width,t.style.height=`auto`,t.style.maxHeight=`none`,t.style.position=`absolute`,t.style.inset=`0 auto auto 0`,t.style.visibility=`hidden`,t.style.pointerEvents=`none`,t.style.transform=`none`,t.style.transition=`none`,t.style.animation=`none`,e.parentElement.append(t);try{return t.offsetHeight||t.getBoundingClientRect().height||e.offsetHeight||e.getBoundingClientRect().height}finally{t.remove()}},me=e=>{let t=u(e);return m(e)&&t.unshift(e),t.filter(e=>e.getAttribute(`aria-hidden`)!==`true`)},z=e=>{let t=[...e.querySelectorAll(`[${F}]`)];return e.hasAttribute(F)&&t.unshift(e),t},B=(e,t)=>{if(t){e.removeAttribute(`aria-hidden`),e.removeAttribute(`inert`);for(let t of z(e)){let e=t.getAttribute(F);t.removeAttribute(F),!e||e===I?t.removeAttribute(`tabindex`):t.setAttribute(`tabindex`,e)}return}for(let t of me(e)){if(!t.hasAttribute(F)){let e=t.getAttribute(`tabindex`);t.setAttribute(F,e===null?I:e)}t.setAttribute(`tabindex`,`-1`)}e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``)};function he({viewport:e,limit:t,stackDirection:n,getItems:r,onLayout:i}){let a=e.ownerDocument,o=new Set,s=new WeakMap,c=!1;e.style.setProperty(`--toast-lift`,String(n));let l=t=>{t?e.setAttribute(`data-expanded`,``):e.removeAttribute(`data-expanded`);let n=t?e.style.getPropertyValue(`--toast-expanded-stack-size`):e.style.getPropertyValue(`--toast-collapsed-stack-size`);e.style.setProperty(`--toast-stack-size`,n.trim()===``?`0px`:n);for(let e of o)e.setAttribute(`data-expanded`,String(t))},u=()=>{if(c)return;let n=r(),o=pe(e),l=L(e),u=n.length,d=0,f=0,p=0,m=0;for(let e=0;e<n.length;e+=1){let r=n[e];if(!r)continue;let i=e<t,c=r.getAttribute(`data-visible`)!==`false`,h=R(r)||(s.get(r)??0);h>0&&s.set(r,h),e===0&&(m=h);let g=e*l;if(r.style.setProperty(`--toast-index`,String(e)),r.style.setProperty(`--toast-initial-height`,`${h}px`),r.style.setProperty(`--toast-offset`,`${d}px`),r.style.setProperty(`--toast-collapsed-offset-y`,`${g}px`),r.setAttribute(`data-front`,String(e===0)),r.setAttribute(`data-visible`,String(i)),r.setAttribute(`data-removed`,`false`),r.style.zIndex=String(u-e+1),r.style.pointerEvents=i?``:`none`,!i&&c){let e=a.activeElement;e instanceof HTMLElement&&r.contains(e)&&e.blur()}B(r,i),d+=h+o,i&&(p+=1,f+=h+o)}let h=p>0?Math.max(0,f-o):0,g=p>0?Math.max(0,m+l*(p-1)):0;e.style.setProperty(`--toast-count`,String(u)),e.style.setProperty(`--toast-front-height`,`${m}px`),e.style.setProperty(`--toast-expanded-stack-size`,`${h}px`),e.style.setProperty(`--toast-collapsed-stack-size`,`${g}px`),i()},d=typeof ResizeObserver<`u`?new ResizeObserver(u):null;return{update:u,setExpanded:l,observe(e){o.add(e),d?.observe(e)},unobserve(e){o.delete(e),d?.unobserve(e)},destroy(){c=!0,d?.disconnect(),o.clear(),e.removeAttribute(`data-expanded`)}}}const V=e=>{e.element.setAttribute(`data-swiping`,`false`),e.element.setAttribute(`data-swipe-out`,`false`);for(let t of[`amount-x`,`amount-y`,`end-x`,`end-y`])e.element.style.removeProperty(`--toast-swipe-${t}`)};function ge({viewport:e,position:t,getEntry:n,dismiss:i}){let a={x:t.endsWith(`left`)?-1:t.endsWith(`right`)?1:0,y:t.startsWith(`top`)?-1:1},o=a.x===0?[`y`]:[`x`,`y`],s=(e,t)=>e*t<0?e*.2:e,c=e=>e.active&&e.toast.dismissible;return r({element:e,axes:o,lockThreshold:12,capture:e=>e.element,start(e,t){if(t.closest(`[data-slot="toast-action"], [data-slot="toast-close"]`))return null;let r=n(t);return r&&c(r)?r:null},active:c,move(e,{axis:t,deltaX:n,deltaY:r}){let i=t===`x`?s(n,a.x):0,o=t===`y`?s(r,a.y):0;e.element.setAttribute(`data-swiping`,`true`),e.element.style.setProperty(`--toast-swipe-amount-x`,`${i}px`),e.element.style.setProperty(`--toast-swipe-amount-y`,`${o}px`)},release(e,{axis:t,deltaX:n,deltaY:r}){let o=t===`x`?n:r;if(o*a[t]<40){V(e);return}let s=t===`x`?e.element.offsetWidth:e.element.offsetHeight,c=a[t]*Math.max(Math.abs(o),s+16);e.element.setAttribute(`data-swiping`,`false`),e.element.setAttribute(`data-swipe-out`,`true`),e.element.style.setProperty(`--toast-swipe-end-x`,`${t===`x`?c:0}px`),e.element.style.setProperty(`--toast-swipe-end-y`,`${t===`y`?c:0}px`),i(e)},reset:V})}const H=new Set([`hover`,`focus`]);function _e({hasExitingEntries:e,setExpanded:t,setPaused:n}){let r=new Set,i=!1,a=!1,o=()=>[...r].some(e=>H.has(e)),s=()=>{i&&(o()||!e())&&(i=!1),t(o()||i);let s=r.size>0;s!==a&&(a=s,n(a))};return{get expanded(){return o()||i},get paused(){return a},set(t,n){n?r.add(t):r.delete(t)&&H.has(t)&&!o()&&e()&&(i=!0),s()},sync:s}}const U=`@data-slot/toast`;function W(n,r={}){let u=g(n,U,`[@data-slot/toast] createToast() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(u)return u;let f=d(n,`toast-viewport`);if(!f)throw Error(`Toast requires a toast-viewport slot`);let p=n.ownerDocument??document,m=d(n,`toast-template`),y=ne(r.limit??l(n,`limit`)),b=re(r.duration??l(n,`duration`),5e3),x=r.position??c(n,`position`,v)??`bottom-right`,C=r.pauseOnHover??s(n,`pauseOnHover`)??!0,w=r.pauseOnFocus??s(n,`pauseOnFocus`)??!0,T=r.portal??s(n,`portal`)??!1,E=r.onShow,ee=r.onDismiss,te=r.onAction,D=x.startsWith(`top`)?1:-1;n.setAttribute(`data-position`,x),f.setAttribute(`data-position`,x),f.hasAttribute(`role`)||f.setAttribute(`role`,`region`),f.hasAttribute(`aria-label`)||f.setAttribute(`aria-label`,`Notifications`);let O=t({content:f,root:n,enabled:T});T&&O.mount();let A=new Map,j=i(),M=[],N=0,P=null,F=()=>[...A.values()].filter(e=>e.active),I=e=>A.get(e.id)===e,pe=()=>[...A.values()].some(e=>e.exiting),L=he({viewport:f,limit:y,stackDirection:D,getItems:()=>F().reverse().map(e=>e.element),onLayout:()=>R.set(`focus`,w&&B())}),R=_e({hasExitingEntries:pe,setExpanded:e=>L.setExpanded(e),setPaused:e=>{for(let t of F())t.setPaused(e)}});p.visibilityState===`hidden`&&R.set(`document`,!0);let z=e=>{if(!(e instanceof Node)||!f.contains(e))return!1;if(!(e instanceof Element))return!0;let t=e.closest(`[data-slot="toast-item"]`);return!t||!f.contains(t)?!0:t.getAttribute(`data-visible`)===`true`&&t.getAttribute(`data-state`)===`open`},B=()=>z(p.activeElement),V=()=>{for(let e of F().reverse()){if(e.element.getAttribute(`data-visible`)!==`true`)continue;let t=me(e.element)[0];if(t)return o(t),!0}return!1},H=()=>P&&P.isConnected?(o(P),!0):!1,W=e=>{let t=p.activeElement;!(t instanceof HTMLElement)||!f.contains(t)||e&&!e.contains(t)||V()||H()||t.blur()},G=e=>{a(n,`toast:change`,{id:e,action:`dismiss`}),ee?.(e)},K=e=>{I(e)&&(Q.cancel(e),L.unobserve(e.element),e.destroy(),A.delete(e.id),L.update())},q=(e,t=!0)=>{!I(e)||!e.active||(Q.cancel(e),e.dismiss(),L.update(),t&&W(e.element),G(e.id))},ve=e=>{let t=A.get(e);t&&q(t)},J=()=>{let e=``;do N+=1,e=`toast-${N}`;while(A.has(e));return e},Y=(e,t)=>{let r=S(e)?e:J(),i=ae(ie(r,b),t),o=A.get(r),s=o?.active;o&&K(o),s&&G(r);let c=fe(i,{viewport:f,template:m,expanded:R.expanded,paused:R.paused,onTimeout:q,onExitComplete:K});if(j.isDestroyed)return c.destroy(),c;let l=A.get(r);return l&&K(l),A.set(r,c),c.mount(),L.observe(c.element),L.update(),I(c)&&c.active&&(a(n,`toast:change`,{id:r,action:`show`}),E?.(r)),c},ye=e=>j.isDestroyed?e.id??J():Y(e.id,e).id,X=(e,t)=>{!I(e)||!e.active||(e.update(t),e.toast.dismissible||Q.cancel(e),L.update())},be=(e,t)=>{let n=A.get(e);n&&X(n,t)},xe=(e,t)=>{let n=k(le(t.loading),{title:`Loading...`,type:`loading`,duration:0,description:t.description}),r=j.isDestroyed?void 0:Y(void 0,n),i=r?.id??J(),a=Promise.resolve().then(()=>typeof e==`function`?e():e).then(e=>{let n=k(ue(t.success,e),{title:`Success`,type:`success`,duration:b,description:t.description});return r&&X(r,n),e}).catch(e=>{let n=k(ue(t.error,e),{title:de(e),type:`error`,duration:b,description:t.description});throw r&&X(r,n),e});return a.catch(()=>{}),{id:i,unwrap:()=>a}},Se=()=>{let e=p.activeElement instanceof HTMLElement&&f.contains(p.activeElement);for(let e of F())q(e,!1);e&&W()},Ce=()=>{let e=!1;return{get defaultPrevented(){return e},preventDefault:()=>{e=!0}}},we=e=>{let t=A.get(e);if(!t||t.exiting)return;let r=t.toast.action?.value,i=Ce();t.toast.action?.onClick?.(i),a(n,`toast:action`,{id:e,value:r}),te?.(e,r),i.defaultPrevented||q(t)},Z=e=>{if(!(e instanceof Element))return;let t=e.closest(`[data-slot="toast-item"]`);if(!t||!f.contains(t))return;let n=A.get(t.getAttribute(`data-id`)??``);return n?.element===t?n:void 0},Q=ge({viewport:f,position:x,getEntry:Z,dismiss:e=>q(e)});M.push(h(f,`click`,e=>{let t=e.target;if(!t)return;let n=t.closest(`[data-slot="toast-close"]`);if(n){let e=Z(n);e&&q(e);return}let r=t.closest(`[data-slot="toast-action"]`);if(r){let e=Z(r);e&&we(e.id)}}));let Te=e=>z(e)||B();M.push(h(f,`pointerenter`,()=>{C&&R.set(`hover`,!0)}),h(f,`pointerleave`,()=>{C&&R.set(`hover`,!1)}),h(f,`focusin`,e=>{if(!w)return;let{relatedTarget:t,target:n}=e;t instanceof HTMLElement&&!f.contains(t)&&(P=t),R.set(`focus`,Te(n))}),h(f,`focusout`,e=>{w&&R.set(`focus`,Te(e.relatedTarget))}));let Ee=p.defaultView??window;M.push(h(Ee,`blur`,()=>R.set(`window`,!0)),h(Ee,`focus`,()=>R.set(`window`,!1)),h(p,`visibilitychange`,()=>R.set(`document`,p.visibilityState===`hidden`))),M.push(h(n,`toast:show`,e=>{let t=oe(e.detail);!t||j.isDestroyed||Y(t.id,t.patch)}),h(n,`toast:update`,e=>{let t=se(e.detail);t&&be(t.id,t.patch)}),h(n,`toast:dismiss`,e=>{let t=ce(e.detail);t&&ve(t)}),h(n,`toast:clear`,()=>{Se()})),j.onDestroy(()=>{M.forEach(e=>e()),Q.destroy(),L.destroy();for(let e of A.values())e.destroy();A.clear(),P=null,O.cleanup(),e(n,U,$)}),L.update();let $={show:ye,update:be,promise:xe,dismiss:ve,dismissAll:Se,get count(){return F().length},destroy:()=>{j.destroy()}};return _(n,U,$),$}function G(e=document){let t=[];for(let n of f(e,`toast`))p(n,U)||t.push(W(n));return t}export{G as create,W as createToast};
|
|
8
|
+
`,t},N=(e,t)=>{e.setAttribute(`data-state`,t),t===`open`?(e.setAttribute(`data-open`,``),e.removeAttribute(`data-closed`)):(e.setAttribute(`data-closed`,``),e.removeAttribute(`data-open`))},P=(e,t)=>{t===`error`||t===`warning`?(e.setAttribute(`role`,`alert`),e.setAttribute(`aria-live`,`assertive`)):(e.setAttribute(`role`,`status`),e.setAttribute(`aria-live`,`polite`)),e.setAttribute(`aria-atomic`,`true`)};function fe(e,t){let{viewport:r}=t,a=(A(t.template)&&j(t.template)?t.template:M(r.ownerDocument)).content.cloneNode(!0),o=a.querySelector(`[data-slot="toast-item"]`),s=new WeakMap,c=i(),l=e,u=!1,d=t.paused,f=null,p=l.duration,m=0,h=(e,t)=>{let n=e.querySelector(`[data-slot="toast-title"]`),r=e.querySelector(`[data-slot="toast-description"]`),i=e.querySelector(`[data-slot="toast-action"]`),a=e.querySelector(`[data-slot="toast-close"]`);if(n&&(n.textContent=t.title,n.hidden=!1),r&&(t.description&&t.description.trim()!==``?(r.textContent=t.description,r.hidden=!1):(r.textContent=``,r.hidden=!0)),i&&(t.action?.label&&t.action.label.trim()!==``?(i.textContent=t.action.label,i.hidden=!1):(i.textContent=``,i.hidden=!0)),e.setAttribute(`data-type`,t.type),t.dismissible?e.removeAttribute(`data-dismissible`):e.setAttribute(`data-dismissible`,`false`),t.testId&&t.testId.trim()!==``?e.setAttribute(`data-testid`,t.testId):e.removeAttribute(`data-testid`),a){if(s.has(a)||s.set(a,a.getAttribute(`aria-label`)),t.closeButtonAriaLabel&&t.closeButtonAriaLabel.trim()!==``)a.setAttribute(`aria-label`,t.closeButtonAriaLabel);else{let e=s.get(a);e&&e.trim()!==``?a.setAttribute(`aria-label`,e):a.setAttribute(`aria-label`,`Close`)}a.getAttribute(`aria-label`)||a.setAttribute(`aria-label`,`Close`)}P(e,t.type)},g=()=>{c.cancelTimeout(f),f=null},_=()=>{if(!(!y.active||d||l.duration<=0||f!==null)){if(p<=0){t.onTimeout(y);return}m=Date.now(),f=c.trackTimeout(()=>{f=null,t.onTimeout(y)},p)}},v=n({element:o,win:r.ownerDocument.defaultView??window,onExitComplete:()=>{c.isDestroyed||t.onExitComplete(y)}});c.onDestroy(()=>{v.cleanup(),o.remove()});let y={get id(){return l.id},element:o,get toast(){return l},get active(){return!u&&!c.isDestroyed},get exiting(){return u},mount(){r.appendChild(a),c.trackRaf(()=>{c.trackRaf(()=>{y.active&&o.setAttribute(`data-mounted`,`true`)})}),_()},update(e){y.active&&(l=ae(l,e),h(o,l),e.duration!==void 0&&(g(),p=l.duration,_()))},setPaused(e){d===e||!y.active||(d=e,d?(f!==null&&(p=Math.max(0,p-(Date.now()-m))),g()):_())},dismiss(){y.active&&(u=!0,g(),o.setAttribute(`data-removed`,`true`),o.style.zIndex=`0`,o.style.pointerEvents=`none`,N(o,`closed`),v.exit())},destroy(){c.destroy()}};o.setAttribute(`data-id`,l.id),h(o,l);for(let e of[`mounted`,`removed`,`front`,`visible`,`swiping`,`swipe-out`])o.setAttribute(`data-${e}`,`false`);o.setAttribute(`data-expanded`,String(t.expanded));for(let e of[`amount-x`,`amount-y`,`end-x`,`end-y`])o.style.setProperty(`--toast-swipe-${e}`,`0px`);return N(o,`open`),y}const F=`data-toast-prev-tabindex`,I=`__none__`,pe=e=>{let t=getComputedStyle(e).getPropertyValue(`--toast-gap`).trim();if(!t)return 8;let n=Number.parseFloat(t);return Number.isFinite(n)?n:8},L=e=>{let t=getComputedStyle(e).getPropertyValue(`--toast-collapsed-peek`).trim();if(!t)return 14;let n=Number.parseFloat(t);return Number.isFinite(n)?Math.max(0,n):14},R=e=>{let t=e.cloneNode(!0);t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`inert`,``),t.style.width=getComputedStyle(e).width,t.style.height=`auto`,t.style.maxHeight=`none`,t.style.position=`absolute`,t.style.inset=`0 auto auto 0`,t.style.visibility=`hidden`,t.style.pointerEvents=`none`,t.style.transform=`none`,t.style.transition=`none`,t.style.animation=`none`,e.parentElement.append(t);try{return t.offsetHeight||t.getBoundingClientRect().height||e.offsetHeight||e.getBoundingClientRect().height}finally{t.remove()}},me=e=>{let t=u(e);return m(e)&&t.unshift(e),t.filter(e=>e.getAttribute(`aria-hidden`)!==`true`)},z=e=>{let t=[...e.querySelectorAll(`[${F}]`)];return e.hasAttribute(F)&&t.unshift(e),t},B=(e,t)=>{if(t){e.removeAttribute(`aria-hidden`),e.removeAttribute(`inert`);for(let t of z(e)){let e=t.getAttribute(F);t.removeAttribute(F),!e||e===I?t.removeAttribute(`tabindex`):t.setAttribute(`tabindex`,e)}return}for(let t of me(e)){if(!t.hasAttribute(F)){let e=t.getAttribute(`tabindex`);t.setAttribute(F,e===null?I:e)}t.setAttribute(`tabindex`,`-1`)}e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``)};function he({viewport:e,limit:t,stackDirection:n,getItems:r,onLayout:i}){let a=e.ownerDocument,o=new Set,s=new WeakMap,c=!1;e.style.setProperty(`--toast-lift`,String(n));let l=t=>{t?e.setAttribute(`data-expanded`,``):e.removeAttribute(`data-expanded`);let n=t?e.style.getPropertyValue(`--toast-expanded-stack-size`):e.style.getPropertyValue(`--toast-collapsed-stack-size`);e.style.setProperty(`--toast-stack-size`,n.trim()===``?`0px`:n);for(let e of o)e.setAttribute(`data-expanded`,String(t))},u=()=>{if(c)return;let n=r(),o=n.length,l=o>0?pe(e):0,u=o>0?L(e):0,d=0,f=0,p=0,m=0;for(let e=0;e<n.length;e+=1){let r=n[e];if(!r)continue;let i=e<t,c=r.getAttribute(`data-visible`)!==`false`,h=R(r)||(s.get(r)??0);h>0&&s.set(r,h),e===0&&(m=h);let g=e*u;if(r.style.setProperty(`--toast-index`,String(e)),r.style.setProperty(`--toast-initial-height`,`${h}px`),r.style.setProperty(`--toast-offset`,`${d}px`),r.style.setProperty(`--toast-collapsed-offset-y`,`${g}px`),r.setAttribute(`data-front`,String(e===0)),r.setAttribute(`data-visible`,String(i)),r.setAttribute(`data-removed`,`false`),r.style.zIndex=String(o-e+1),r.style.pointerEvents=i?``:`none`,!i&&c){let e=a.activeElement;e instanceof HTMLElement&&r.contains(e)&&e.blur()}B(r,i),d+=h+l,i&&(p+=1,f+=h+l)}let h=p>0?Math.max(0,f-l):0,g=p>0?Math.max(0,m+u*(p-1)):0;e.style.setProperty(`--toast-count`,String(o)),e.style.setProperty(`--toast-front-height`,`${m}px`),e.style.setProperty(`--toast-expanded-stack-size`,`${h}px`),e.style.setProperty(`--toast-collapsed-stack-size`,`${g}px`),i()},d=typeof ResizeObserver<`u`?new ResizeObserver(u):null;return{update:u,setExpanded:l,observe(e){o.add(e),d?.observe(e)},unobserve(e){o.delete(e),d?.unobserve(e)},destroy(){c=!0,d?.disconnect(),o.clear(),e.removeAttribute(`data-expanded`)}}}const V=e=>{e.element.setAttribute(`data-swiping`,`false`),e.element.setAttribute(`data-swipe-out`,`false`);for(let t of[`amount-x`,`amount-y`,`end-x`,`end-y`])e.element.style.removeProperty(`--toast-swipe-${t}`)};function ge({viewport:e,position:t,getEntry:n,dismiss:i}){let a={x:t.endsWith(`left`)?-1:t.endsWith(`right`)?1:0,y:t.startsWith(`top`)?-1:1},o=a.x===0?[`y`]:[`x`,`y`],s=(e,t)=>e*t<0?e*.2:e,c=e=>e.active&&e.toast.dismissible;return r({element:e,axes:o,lockThreshold:12,capture:e=>e.element,start(e,t){if(t.closest(`[data-slot="toast-action"], [data-slot="toast-close"]`))return null;let r=n(t);return r&&c(r)?r:null},active:c,move(e,{axis:t,deltaX:n,deltaY:r}){let i=t===`x`?s(n,a.x):0,o=t===`y`?s(r,a.y):0;e.element.setAttribute(`data-swiping`,`true`),e.element.style.setProperty(`--toast-swipe-amount-x`,`${i}px`),e.element.style.setProperty(`--toast-swipe-amount-y`,`${o}px`)},release(e,{axis:t,deltaX:n,deltaY:r}){let o=t===`x`?n:r;if(o*a[t]<40){V(e);return}let s=t===`x`?e.element.offsetWidth:e.element.offsetHeight,c=a[t]*Math.max(Math.abs(o),s+16);e.element.setAttribute(`data-swiping`,`false`),e.element.setAttribute(`data-swipe-out`,`true`),e.element.style.setProperty(`--toast-swipe-end-x`,`${t===`x`?c:0}px`),e.element.style.setProperty(`--toast-swipe-end-y`,`${t===`y`?c:0}px`),i(e)},reset:V})}const H=new Set([`hover`,`focus`]);function _e({hasExitingEntries:e,setExpanded:t,setPaused:n}){let r=new Set,i=!1,a=!1,o=()=>[...r].some(e=>H.has(e)),s=()=>{i&&(o()||!e())&&(i=!1),t(o()||i);let s=r.size>0;s!==a&&(a=s,n(a))};return{get expanded(){return o()||i},get paused(){return a},set(t,n){n?r.add(t):r.delete(t)&&H.has(t)&&!o()&&e()&&(i=!0),s()},sync:s}}const U=`@data-slot/toast`;function W(n,r={}){let u=g(n,U,`[@data-slot/toast] createToast() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(u)return u;let f=d(n,`toast-viewport`);if(!f)throw Error(`Toast requires a toast-viewport slot`);let p=n.ownerDocument??document,m=d(n,`toast-template`),y=ne(r.limit??l(n,`limit`)),b=re(r.duration??l(n,`duration`),5e3),x=r.position??c(n,`position`,v)??`bottom-right`,C=r.pauseOnHover??s(n,`pauseOnHover`)??!0,w=r.pauseOnFocus??s(n,`pauseOnFocus`)??!0,T=r.portal??s(n,`portal`)??!1,E=r.onShow,ee=r.onDismiss,te=r.onAction,D=x.startsWith(`top`)?1:-1;n.setAttribute(`data-position`,x),f.setAttribute(`data-position`,x),f.hasAttribute(`role`)||f.setAttribute(`role`,`region`),f.hasAttribute(`aria-label`)||f.setAttribute(`aria-label`,`Notifications`);let O=t({content:f,root:n,enabled:T});T&&O.mount();let A=new Map,j=i(),M=[],N=0,P=null,F=()=>[...A.values()].filter(e=>e.active),I=e=>A.get(e.id)===e,pe=()=>[...A.values()].some(e=>e.exiting),L=he({viewport:f,limit:y,stackDirection:D,getItems:()=>F().reverse().map(e=>e.element),onLayout:()=>R.set(`focus`,w&&B())}),R=_e({hasExitingEntries:pe,setExpanded:e=>L.setExpanded(e),setPaused:e=>{for(let t of F())t.setPaused(e)}});p.visibilityState===`hidden`&&R.set(`document`,!0);let z=e=>{if(!(e instanceof Node)||!f.contains(e))return!1;if(!(e instanceof Element))return!0;let t=e.closest(`[data-slot="toast-item"]`);return!t||!f.contains(t)?!0:t.getAttribute(`data-visible`)===`true`&&t.getAttribute(`data-state`)===`open`},B=()=>z(p.activeElement),V=()=>{for(let e of F().reverse()){if(e.element.getAttribute(`data-visible`)!==`true`)continue;let t=me(e.element)[0];if(t)return o(t),!0}return!1},H=()=>P&&P.isConnected?(o(P),!0):!1,W=e=>{let t=p.activeElement;!(t instanceof HTMLElement)||!f.contains(t)||e&&!e.contains(t)||V()||H()||t.blur()},G=e=>{a(n,`toast:change`,{id:e,action:`dismiss`}),ee?.(e)},K=e=>{I(e)&&(Q.cancel(e),L.unobserve(e.element),e.destroy(),A.delete(e.id),L.update())},q=(e,t=!0)=>{!I(e)||!e.active||(Q.cancel(e),e.dismiss(),L.update(),t&&W(e.element),G(e.id))},ve=e=>{let t=A.get(e);t&&q(t)},J=()=>{let e=``;do N+=1,e=`toast-${N}`;while(A.has(e));return e},Y=(e,t)=>{let r=S(e)?e:J(),i=ae(ie(r,b),t),o=A.get(r),s=o?.active;o&&K(o),s&&G(r);let c=fe(i,{viewport:f,template:m,expanded:R.expanded,paused:R.paused,onTimeout:q,onExitComplete:K});if(j.isDestroyed)return c.destroy(),c;let l=A.get(r);return l&&K(l),A.set(r,c),c.mount(),L.observe(c.element),L.update(),I(c)&&c.active&&(a(n,`toast:change`,{id:r,action:`show`}),E?.(r)),c},ye=e=>j.isDestroyed?e.id??J():Y(e.id,e).id,X=(e,t)=>{!I(e)||!e.active||(e.update(t),e.toast.dismissible||Q.cancel(e),L.update())},be=(e,t)=>{let n=A.get(e);n&&X(n,t)},xe=(e,t)=>{let n=k(le(t.loading),{title:`Loading...`,type:`loading`,duration:0,description:t.description}),r=j.isDestroyed?void 0:Y(void 0,n),i=r?.id??J(),a=Promise.resolve().then(()=>typeof e==`function`?e():e).then(e=>{let n=k(ue(t.success,e),{title:`Success`,type:`success`,duration:b,description:t.description});return r&&X(r,n),e}).catch(e=>{let n=k(ue(t.error,e),{title:de(e),type:`error`,duration:b,description:t.description});throw r&&X(r,n),e});return a.catch(()=>{}),{id:i,unwrap:()=>a}},Se=()=>{let e=p.activeElement instanceof HTMLElement&&f.contains(p.activeElement);for(let e of F())q(e,!1);e&&W()},Ce=()=>{let e=!1;return{get defaultPrevented(){return e},preventDefault:()=>{e=!0}}},we=e=>{let t=A.get(e);if(!t||t.exiting)return;let r=t.toast.action?.value,i=Ce();t.toast.action?.onClick?.(i),a(n,`toast:action`,{id:e,value:r}),te?.(e,r),i.defaultPrevented||q(t)},Z=e=>{if(!(e instanceof Element))return;let t=e.closest(`[data-slot="toast-item"]`);if(!t||!f.contains(t))return;let n=A.get(t.getAttribute(`data-id`)??``);return n?.element===t?n:void 0},Q=ge({viewport:f,position:x,getEntry:Z,dismiss:e=>q(e)});M.push(h(f,`click`,e=>{let t=e.target;if(!t)return;let n=t.closest(`[data-slot="toast-close"]`);if(n){let e=Z(n);e&&q(e);return}let r=t.closest(`[data-slot="toast-action"]`);if(r){let e=Z(r);e&&we(e.id)}}));let Te=e=>z(e)||B();M.push(h(f,`pointerenter`,()=>{C&&R.set(`hover`,!0)}),h(f,`pointerleave`,()=>{C&&R.set(`hover`,!1)}),h(f,`focusin`,e=>{if(!w)return;let{relatedTarget:t,target:n}=e;t instanceof HTMLElement&&!f.contains(t)&&(P=t),R.set(`focus`,Te(n))}),h(f,`focusout`,e=>{w&&R.set(`focus`,Te(e.relatedTarget))}));let Ee=p.defaultView??window;M.push(h(Ee,`blur`,()=>R.set(`window`,!0)),h(Ee,`focus`,()=>R.set(`window`,!1)),h(p,`visibilitychange`,()=>R.set(`document`,p.visibilityState===`hidden`))),M.push(h(n,`toast:show`,e=>{let t=oe(e.detail);!t||j.isDestroyed||Y(t.id,t.patch)}),h(n,`toast:update`,e=>{let t=se(e.detail);t&&be(t.id,t.patch)}),h(n,`toast:dismiss`,e=>{let t=ce(e.detail);t&&ve(t)}),h(n,`toast:clear`,()=>{Se()})),j.onDestroy(()=>{M.forEach(e=>e()),Q.destroy(),L.destroy();for(let e of A.values())e.destroy();A.clear(),P=null,O.cleanup(),e(n,U,$)}),L.update();let $={show:ye,update:be,promise:xe,dismiss:ve,dismissAll:Se,get count(){return F().length},destroy:()=>{j.destroy()}};return _(n,U,$),$}function G(e=document){let t=[];for(let n of f(e,`toast`))p(n,U)||t.push(W(n));return t}export{G as create,W as createToast};
|
|
@@ -30,6 +30,38 @@
|
|
|
30
30
|
padding-left: var(--gutter);
|
|
31
31
|
scroll-snap-align: start;
|
|
32
32
|
}
|
|
33
|
+
/* A thumbnail that shows its slide, as data-slot's carousel-indicator with a zero-based data-index.
|
|
34
|
+
A link to the slide's id also works without JavaScript. The controller marks the current one. */
|
|
35
|
+
[data-slot='carousel-indicator'] {
|
|
36
|
+
position: relative;
|
|
37
|
+
display: block;
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
padding: 0;
|
|
41
|
+
border: 0;
|
|
42
|
+
border-radius: var(--radius-md);
|
|
43
|
+
background: var(--muted);
|
|
44
|
+
color: inherit;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
outline: 2px solid transparent;
|
|
47
|
+
outline-offset: 2px;
|
|
48
|
+
transition:
|
|
49
|
+
outline-color 150ms,
|
|
50
|
+
box-shadow 150ms;
|
|
51
|
+
}
|
|
52
|
+
[data-slot='carousel-indicator']:focus-visible {
|
|
53
|
+
outline-color: transparent;
|
|
54
|
+
box-shadow: var(--focus-ring);
|
|
55
|
+
}
|
|
56
|
+
[data-slot='carousel-indicator'][aria-current='true']:not(:focus-visible) {
|
|
57
|
+
outline-color: var(--foreground);
|
|
58
|
+
}
|
|
59
|
+
[data-slot='carousel-indicator'] > :is(img, svg) {
|
|
60
|
+
display: block;
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: 100%;
|
|
63
|
+
object-fit: cover;
|
|
64
|
+
}
|
|
33
65
|
.carousel__controls {
|
|
34
66
|
display: flex;
|
|
35
67
|
gap: 8px;
|
|
@@ -30,7 +30,34 @@ export function initializeCarousel(root) {
|
|
|
30
30
|
queueMicrotask(translate);
|
|
31
31
|
});
|
|
32
32
|
observer.observe(content, { childList: true });
|
|
33
|
-
|
|
33
|
+
// A thumbnail can link to its slide's id, which works without JavaScript. Once the controller runs,
|
|
34
|
+
// a plain click only scrolls the carousel, so the page does not jump to the slide.
|
|
35
|
+
const onClick = (event) => {
|
|
36
|
+
const link = event.target instanceof Element ? event.target.closest('a[data-slot="carousel-indicator"]') : null;
|
|
37
|
+
if (!link || link.closest('[data-slot="carousel"]') !== root) return;
|
|
38
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
};
|
|
41
|
+
// A link to a slide or to something in it, such as a thumbnail followed before this module loaded,
|
|
42
|
+
// keeps that slide.
|
|
43
|
+
let hash = location.hash.slice(1);
|
|
44
|
+
try {
|
|
45
|
+
hash = decodeURIComponent(hash);
|
|
46
|
+
} catch {
|
|
47
|
+
// Keep a malformed hash as it is.
|
|
48
|
+
}
|
|
49
|
+
const target = hash ? document.getElementById(hash) : null;
|
|
50
|
+
const linked = target ? items().findIndex((item) => item.contains(target)) : -1;
|
|
51
|
+
// A row of cards exposes every card that is in view. A gallery that shows one slide at a time sets
|
|
52
|
+
// data-slides='single', so only the shown slide is exposed, also when a fractional width leaves a
|
|
53
|
+
// sliver of the next one in view.
|
|
54
|
+
const carousel = createCarousel(root, {
|
|
55
|
+
slides: root.dataset.slides === 'single' ? 'single' : 'multiple',
|
|
56
|
+
drag: true,
|
|
57
|
+
loop: false,
|
|
58
|
+
...(linked >= 0 ? { defaultIndex: linked } : {}),
|
|
59
|
+
});
|
|
60
|
+
root.addEventListener('click', onClick);
|
|
34
61
|
translate();
|
|
35
62
|
for (const button of root.querySelectorAll('[data-slot="carousel-previous"], [data-slot="carousel-next"]'))
|
|
36
63
|
button.hidden = false;
|
|
@@ -38,6 +65,7 @@ export function initializeCarousel(root) {
|
|
|
38
65
|
carousel.destroy = () => {
|
|
39
66
|
destroyed = true;
|
|
40
67
|
observer.disconnect();
|
|
68
|
+
root.removeEventListener('click', onClick);
|
|
41
69
|
destroy();
|
|
42
70
|
};
|
|
43
71
|
return carousel;
|
|
@@ -164,6 +164,116 @@ function initializeToaster({ createToast }, root) {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
// A number field's buttons step its native input, as its arrow keys do, and fire the input and change
|
|
168
|
+
// events that typing fires, so a form or cart script sees one kind of change. As in Base UI, the
|
|
169
|
+
// runtime disables them when a step would not change the value: at a bound, or while the input is
|
|
170
|
+
// disabled or read-only. They follow new attributes, such as a variant's bounds, and markup a cart
|
|
171
|
+
// refresh replaces; a script that sets the value property fires input or change. Disable the input
|
|
172
|
+
// to disable the field. Without JavaScript the input still works on its own.
|
|
173
|
+
function initializeNumberField(_, root) {
|
|
174
|
+
const events = new AbortController();
|
|
175
|
+
const options = { signal: events.signal };
|
|
176
|
+
const buttons = () =>
|
|
177
|
+
root.querySelectorAll('[data-slot="number-field-decrement"], [data-slot="number-field-increment"]');
|
|
178
|
+
// Steps a detached copy, so min, max and step apply as the browser applies them.
|
|
179
|
+
const canStep = (input, decrement) => {
|
|
180
|
+
if (input.disabled || input.readOnly) return false;
|
|
181
|
+
const probe = input.cloneNode();
|
|
182
|
+
probe.value = input.value;
|
|
183
|
+
try {
|
|
184
|
+
if (decrement) probe.stepDown();
|
|
185
|
+
else probe.stepUp();
|
|
186
|
+
} catch {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
return probe.value !== input.value;
|
|
190
|
+
};
|
|
191
|
+
// data-disabled marks a disabled field, as in Astro and React.
|
|
192
|
+
const sync = () => {
|
|
193
|
+
const input = root.querySelector('input');
|
|
194
|
+
if (!input) return;
|
|
195
|
+
if (input.disabled) root.setAttribute('data-disabled', 'true');
|
|
196
|
+
else root.removeAttribute('data-disabled');
|
|
197
|
+
for (const button of buttons()) {
|
|
198
|
+
// A step button never submits its form, also when the markup leaves out type='button'.
|
|
199
|
+
if (button.type !== 'button') button.type = 'button';
|
|
200
|
+
const disabled = !canStep(input, button.dataset.slot === 'number-field-decrement');
|
|
201
|
+
if (button.disabled !== disabled) button.disabled = disabled;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
root.addEventListener(
|
|
205
|
+
'click',
|
|
206
|
+
(event) => {
|
|
207
|
+
const button =
|
|
208
|
+
event.target instanceof Element
|
|
209
|
+
? event.target.closest('[data-slot="number-field-decrement"], [data-slot="number-field-increment"]')
|
|
210
|
+
: null;
|
|
211
|
+
const input = root.querySelector('input');
|
|
212
|
+
if (!button || button.closest('[data-slot="number-field"]') !== root || button.disabled) return;
|
|
213
|
+
if (!input || input.disabled || input.readOnly) return;
|
|
214
|
+
const value = input.value;
|
|
215
|
+
try {
|
|
216
|
+
if (button.dataset.slot === 'number-field-decrement') input.stepDown();
|
|
217
|
+
else input.stepUp();
|
|
218
|
+
} catch {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (input.value !== value) {
|
|
222
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
223
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
224
|
+
}
|
|
225
|
+
sync();
|
|
226
|
+
},
|
|
227
|
+
options,
|
|
228
|
+
);
|
|
229
|
+
// Pressing a button keeps the focus on this field's input, so its typed value is not committed by a
|
|
230
|
+
// blur, and a cart that refreshes on change, before the click steps it. Another field still blurs.
|
|
231
|
+
root.addEventListener(
|
|
232
|
+
'mousedown',
|
|
233
|
+
(event) => {
|
|
234
|
+
if (
|
|
235
|
+
event.target instanceof Element &&
|
|
236
|
+
event.target.closest('[data-slot="number-field-decrement"], [data-slot="number-field-increment"]') &&
|
|
237
|
+
root.querySelector('input') === document.activeElement
|
|
238
|
+
)
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
},
|
|
241
|
+
options,
|
|
242
|
+
);
|
|
243
|
+
// A pointer or focus that reaches the field first also syncs it, for a value a script set without an event.
|
|
244
|
+
for (const type of ['input', 'change', 'pointerover', 'focusin']) root.addEventListener(type, sync, options);
|
|
245
|
+
// A form reset restores the input after the event, also for an input in a form elsewhere.
|
|
246
|
+
document.addEventListener(
|
|
247
|
+
'reset',
|
|
248
|
+
(event) => {
|
|
249
|
+
if (root.querySelector('input')?.form === event.target)
|
|
250
|
+
setTimeout(() => {
|
|
251
|
+
if (!events.signal.aborted) sync();
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
options,
|
|
255
|
+
);
|
|
256
|
+
const observer = new MutationObserver((mutations) => {
|
|
257
|
+
if (mutations.some((mutation) => mutation.type === 'childList' || mutation.target instanceof HTMLInputElement))
|
|
258
|
+
sync();
|
|
259
|
+
});
|
|
260
|
+
observer.observe(root, {
|
|
261
|
+
childList: true,
|
|
262
|
+
subtree: true,
|
|
263
|
+
attributes: true,
|
|
264
|
+
attributeFilter: ['min', 'max', 'step', 'value', 'disabled', 'readonly'],
|
|
265
|
+
});
|
|
266
|
+
sync();
|
|
267
|
+
return {
|
|
268
|
+
destroy() {
|
|
269
|
+
events.abort();
|
|
270
|
+
observer.disconnect();
|
|
271
|
+
for (const button of buttons()) button.disabled = false;
|
|
272
|
+
root.removeAttribute('data-disabled');
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
167
277
|
// Each entry loads its data-slot package, then starts one root with it and returns a controller
|
|
168
278
|
// with destroy(). theme.js starts the root only if it is still current once the package has
|
|
169
279
|
// loaded. Select, tooltip and hover card keep their closed content connected (eager), so nested
|
|
@@ -192,4 +302,6 @@ export const controls = {
|
|
|
192
302
|
'alert-dialog': [() => import('@data-slot/alert-dialog'), initializeAlertDialog],
|
|
193
303
|
drawer: [() => import('@data-slot/drawer'), ({ createDrawer }, root) => createDrawer(root)],
|
|
194
304
|
toast: [() => import('@data-slot/toast'), initializeToaster],
|
|
305
|
+
// data-slot leaves a number field to the native input, so this entry loads no package.
|
|
306
|
+
'number-field': [async () => ({}), initializeNumberField],
|
|
195
307
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"text": "MIT License\n\nCopyright (c) 2023 shadcn\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
|
-
"name": "data-slot 1.1.
|
|
11
|
+
"name": "data-slot 1.1.3",
|
|
12
12
|
"text": "MIT License\n\nCopyright (c) 2026 Bejamas\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
|
|
13
13
|
}
|
|
14
14
|
]
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"assets/ui-tokens.css": "55a8f2810ab4a1498ca3dd2f6e7dc89009c60e2402ddfcb95783b6eba996c374",
|
|
5
5
|
"snippets/ui-base.liquid": "bc55195b5b6c82e63deeeed1255fd19b434c47866815f82b95b9202421256d34",
|
|
6
6
|
"snippets/ui-init.liquid": "98f56067cf51e4cb2cd3e10ede7c00304c73ce57fe5b5a0270c0d8a9e448f7af",
|
|
7
|
-
"assets/ui-licenses.json": "
|
|
8
|
-
"assets/ui-carousel.js": "
|
|
9
|
-
"assets/ui-controls.js": "
|
|
7
|
+
"assets/ui-licenses.json": "874a6f264f1503b2e577aee651e7285fd6ac808f56cadf8c7d58914bf2396f49",
|
|
8
|
+
"assets/ui-carousel.js": "34bb85998bff45a319b99a6f0e5e86ccb44295a95d3aff1a38b5aca2e7ef5caf",
|
|
9
|
+
"assets/ui-controls.js": "69abd94c22f5c8307f0d86d9f8be3b6724adb82778fc7021aafd33ba3b4c3789",
|
|
10
10
|
"assets/ui-lifecycle.js": "78c975473620171c01b1289bf5cdce56a5626c847437fa5168fb91a4300260d6",
|
|
11
11
|
"assets/ui-start.js": "738d7e171b5d7993bfd0a169e4382b2db08340f52a87059b94d27e1fe3606500",
|
|
12
12
|
"assets/data-slot-core.js": "d2879cc3a2f05a7867763b937bad3bd4a369f54670989ce535367cb690fb66e6",
|
|
13
13
|
"assets/data-slot-dialog.js": "a5201f452700d04145b5156cc46880d2b5bdf7521b03ff9521c3f7693ee1b5d5",
|
|
14
|
-
"assets/data-slot-command.js": "
|
|
14
|
+
"assets/data-slot-command.js": "299d99c1a5f7b646692575e5d48e3f7b9209d76119508116c1a216dc80d33d13",
|
|
15
15
|
"assets/data-slot-navigation-menu.js": "f9b42a9bceca8e1103718d43aa5f0d141ab63d38278cb121e790a2c80e827b68",
|
|
16
16
|
"assets/data-slot-accordion.js": "fe6b0ac2c87a2e31582e5e88c509e0b508f41d0065d0a420407999ad210e6a27",
|
|
17
17
|
"assets/data-slot-tabs.js": "1f187134bba755cfda9d35cf9f16174c1a183862d32d100f270f4177033058c7",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"assets/data-slot-select.js": "13d1a3fbe90f4b3b830d987b6a28267897faa3589bf00e64edca4938acbf406b",
|
|
28
28
|
"assets/data-slot-slider.js": "0d10131aa95450aa1269234103ead8d805d6abdf9e0683510f4fcf58ab0f1efa",
|
|
29
29
|
"assets/data-slot-switch.js": "0d5b09a89429880f61aeb540be5f87383ba5c6beb261ad468e9a6cf18e45b6a0",
|
|
30
|
-
"assets/data-slot-toast.js": "
|
|
30
|
+
"assets/data-slot-toast.js": "817744d32eebe3bfc50df068715e0b572350ca53fe5ad0e04ec8646800e1caf0",
|
|
31
31
|
"assets/data-slot-toggle.js": "7a651d578cb83be842c8e59fe1a2cd124594b1fd6c942faf0a33cf9e57326947",
|
|
32
32
|
"assets/data-slot-toggle-group.js": "c1f2fc9712974e63e4e44c97ab2a1ec8bc3c3cb73c1afb4578b085fed11977f1",
|
|
33
33
|
"assets/data-slot-tooltip.js": "5a9e51a54669153620eb3512e74487eac12ababe3331aff7dfed6c717b8b93c0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"snippets/ui-logo.liquid": "5d6de7be3f7aab9e05c9533afef39ea0e9dce1b4ee12a13bf7b82780c973b126",
|
|
50
50
|
"snippets/ui-kbd.liquid": "024f34ed2932d183671f7fa44ff724a70ec17b766cf7e0d3f565f46f33ab2cf2",
|
|
51
51
|
"snippets/ui-rating.liquid": "aa57adc5a5508b368da78023b242694e6ce924b6e9e5407c141a5030a414bf1d",
|
|
52
|
-
"assets/ui-rating.css": "
|
|
52
|
+
"assets/ui-rating.css": "f7edd1728c13ec0cc351e09cebd7fc13abb4aca7cbe4e45122b41a1f9e6b377c",
|
|
53
53
|
"snippets/ui-tooltip.liquid": "d2863a0da3090c73dda10d8615b84fc50fab64373a466fbf4e4e743cfb083c96",
|
|
54
54
|
"snippets/ui-avatar.liquid": "9bfb5d5f535857cc45f31afbc91c855e94972bab07ad3b4fe2dc0d241106385d",
|
|
55
55
|
"snippets/ui-empty.liquid": "0e7fb5b68d50abcf7213304034762b4dd535c791dd6f4dc517100145e04b0cde",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"snippets/ui-accordion.liquid": "4b58c83ae13e14e03a3129a2dccbd02eeafa90c1e48edbbf9af2dc412bf3aabf",
|
|
70
70
|
"assets/ui-accordion.css": "430924440bd0f1d49ceb72baffc77404c9411c31c24b940d75861daba2649e83",
|
|
71
71
|
"snippets/ui-slider.liquid": "f2de1fb9099de77bf291455447bc86b2578781e7cf0efdf12117fb4575e0b0e6",
|
|
72
|
-
"snippets/ui-input.liquid": "
|
|
73
|
-
"snippets/ui-input-group.liquid": "
|
|
72
|
+
"snippets/ui-input.liquid": "5f4b2adf298e84ef5845fb123b0753dd76294731da657fe395313ad7fe3f01a9",
|
|
73
|
+
"snippets/ui-input-group.liquid": "4c34c71677ae07b4d0e73fd10d79e96c308e65bb4d02401e4f39cc8c80b89305",
|
|
74
74
|
"snippets/ui-triggers.liquid": "ba9c7b802fb0a2aba0e9cc145a9dd44134964afb53e5363cf9e0ae138b906cc9",
|
|
75
75
|
"snippets/ui-toggle-group.liquid": "2d61e0b9bc746e05834157f5a75d23123f02bc2df737412e4f6099844afc4f49",
|
|
76
76
|
"snippets/ui-dialog.liquid": "779bbcd609a69ed29a984df1f26f9ed80fd24d71c4ee3ead5f4daa055b28e9fb",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"snippets/ui-popup.liquid": "840f938aa2a331e4e7d55c659f25e841dcfb1bf5c5cadace6263243352ff8359",
|
|
94
94
|
"snippets/ui-sheet.liquid": "0de705bed685bf78fa3af4517c947b38d62a1aa56bf29356c0a201b64db17614",
|
|
95
95
|
"snippets/ui-carousel.liquid": "59dc0c06b2a9f2f779ca22b3ff4b005071d4909aba052d6f8f0a1aa19e84c2ce",
|
|
96
|
-
"assets/ui-carousel.css": "
|
|
96
|
+
"assets/ui-carousel.css": "b642a66b5cfa1daa12780c8a99cae70a69d218866a57d2c9f69952b6e2a66032",
|
|
97
97
|
"snippets/ui-attachment.liquid": "6881df7cdb1b27462d8cce7c17c0b4ed4dd860d62535e1daa81378a57bb69ddf",
|
|
98
98
|
"snippets/ui-marquee.liquid": "47d5df8f1ff46a2cd48a132986c2ba199c9e19b485e62fc3e0d19091d4baaab1",
|
|
99
99
|
"assets/ui-marquee.css": "ef13b83f3dbcd6685fcee3dba14238386d0f34bc2266a5326c0b6f2d40a23fce",
|
|
@@ -105,6 +105,8 @@
|
|
|
105
105
|
"snippets/ui-dropdown-menu.liquid": "25b31e09e3e7bfee9a397ca4de6e310754844c55e71639eadba917b0f4e6d2e5",
|
|
106
106
|
"snippets/ui-popover.liquid": "44ff93d72eaad409f56f8a84ce25715e2c3633f2ac49ba7a414767c6dbe2ee47",
|
|
107
107
|
"snippets/ui-hover-card.liquid": "ba4133d352fa14296743138c99f3694015bafe953751b8e42155f047c4beb9f0",
|
|
108
|
-
"snippets/ui.liquid": "
|
|
108
|
+
"snippets/ui-number-field.liquid": "544bbc038d11fe0f3d7ddd4c1af7b6c76f2a726f1aa63cd94fc44ee7e79b2fbf",
|
|
109
|
+
"snippets/ui-swatch.liquid": "9a39fc70974416ba933e90d799e6a805ba1f490c7b48d9a7e25d50caae596e7d",
|
|
110
|
+
"snippets/ui.liquid": "569e78bf6f84cdc7b1f7b5ba2681e1e52c6f5d02c4fe4ade16e580bffb963ae0"
|
|
109
111
|
}
|
|
110
112
|
}
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
height: calc(var(--spacing) * 4);
|
|
12
12
|
color: color-mix(in oklch, var(--muted-foreground) 25%, transparent);
|
|
13
13
|
}
|
|
14
|
+
/* A star keeps its size inside a fill, so a fill with a width, such as 50%, shows part of it. */
|
|
14
15
|
.rating__star svg {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
flex: none;
|
|
17
|
+
width: calc(var(--spacing) * 4);
|
|
18
|
+
max-width: none;
|
|
19
|
+
height: calc(var(--spacing) * 4);
|
|
17
20
|
}
|
|
18
21
|
.rating__fill {
|
|
19
22
|
position: absolute;
|
package/liquid/contracts.json
CHANGED
|
@@ -43,6 +43,9 @@
|
|
|
43
43
|
"navigation-menu-indicator",
|
|
44
44
|
"navigation-menu-item",
|
|
45
45
|
"navigation-menu-trigger",
|
|
46
|
+
"number-field",
|
|
47
|
+
"number-field-decrement",
|
|
48
|
+
"number-field-increment",
|
|
46
49
|
"radio-group-indicator",
|
|
47
50
|
"select-group",
|
|
48
51
|
"select-item",
|
|
@@ -242,7 +245,8 @@
|
|
|
242
245
|
],
|
|
243
246
|
"input-group": [
|
|
244
247
|
"input-group",
|
|
245
|
-
"input-group-addon"
|
|
248
|
+
"input-group-addon",
|
|
249
|
+
"number-field"
|
|
246
250
|
],
|
|
247
251
|
"triggers": [
|
|
248
252
|
"alert-dialog",
|
|
@@ -390,6 +394,7 @@
|
|
|
390
394
|
"carousel": [
|
|
391
395
|
"carousel",
|
|
392
396
|
"carousel-content",
|
|
397
|
+
"carousel-indicator",
|
|
393
398
|
"carousel-item"
|
|
394
399
|
],
|
|
395
400
|
"attachment": [
|
|
@@ -424,5 +429,13 @@
|
|
|
424
429
|
"button-group",
|
|
425
430
|
"button-group-separator",
|
|
426
431
|
"button-group-text"
|
|
432
|
+
],
|
|
433
|
+
"number-field": [
|
|
434
|
+
"number-field",
|
|
435
|
+
"number-field-decrement",
|
|
436
|
+
"number-field-increment"
|
|
437
|
+
],
|
|
438
|
+
"swatch": [
|
|
439
|
+
"swatch"
|
|
427
440
|
]
|
|
428
441
|
}
|
|
@@ -10,3 +10,49 @@
|
|
|
10
10
|
<button data-slot='carousel-previous' data-button data-variant='outline' type='button' hidden>Previous</button
|
|
11
11
|
><button data-slot='carousel-next' data-button data-variant='outline' type='button' hidden>Next</button>
|
|
12
12
|
</section>
|
|
13
|
+
|
|
14
|
+
<section data-slot='carousel' data-slides='single' aria-label='Product images' style='margin-top:48px'>
|
|
15
|
+
<div data-slot='carousel-content'>
|
|
16
|
+
<div data-slot='carousel-item' id='gallery-image-1'>
|
|
17
|
+
<div data-slot='aspect-ratio' data-variant='framed' style='--ratio:4/3;background:var(--muted)'>
|
|
18
|
+
<span style='position:absolute;inset:0;display:grid;place-items:center'>Image 1</span>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<div data-slot='carousel-item' id='gallery-image-2'>
|
|
22
|
+
<div data-slot='aspect-ratio' data-variant='framed' style='--ratio:4/3;background:var(--secondary)'>
|
|
23
|
+
<span style='position:absolute;inset:0;display:grid;place-items:center'>Image 2</span>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div data-slot='carousel-item' id='gallery-image-3'>
|
|
27
|
+
<div data-slot='aspect-ratio' data-variant='framed' style='--ratio:4/3;background:var(--accent)'>
|
|
28
|
+
<span style='position:absolute;inset:0;display:grid;place-items:center'>Image 3</span>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div style='display:flex;gap:8px'>
|
|
33
|
+
<a
|
|
34
|
+
data-slot='carousel-indicator'
|
|
35
|
+
data-index='0'
|
|
36
|
+
href='#gallery-image-1'
|
|
37
|
+
aria-label='Show image 1'
|
|
38
|
+
style='display:grid;place-items:center;width:64px;aspect-ratio:1;background:var(--muted)'
|
|
39
|
+
>1</a
|
|
40
|
+
>
|
|
41
|
+
<a
|
|
42
|
+
data-slot='carousel-indicator'
|
|
43
|
+
data-index='1'
|
|
44
|
+
href='#gallery-image-2'
|
|
45
|
+
aria-label='Show image 2'
|
|
46
|
+
style='display:grid;place-items:center;width:64px;aspect-ratio:1;background:var(--secondary)'
|
|
47
|
+
>2</a
|
|
48
|
+
>
|
|
49
|
+
<a
|
|
50
|
+
data-slot='carousel-indicator'
|
|
51
|
+
data-index='2'
|
|
52
|
+
href='#gallery-image-3'
|
|
53
|
+
aria-label='Show image 3'
|
|
54
|
+
style='display:grid;place-items:center;width:64px;aspect-ratio:1;background:var(--accent)'
|
|
55
|
+
>3</a
|
|
56
|
+
>
|
|
57
|
+
</div>
|
|
58
|
+
</section>
|
|
@@ -56,5 +56,7 @@
|
|
|
56
56
|
"hover-card": ["hover-card", "typography", "button"],
|
|
57
57
|
"marquee": ["marquee"],
|
|
58
58
|
"section": ["section"],
|
|
59
|
-
"button-group": ["button-group"]
|
|
59
|
+
"button-group": ["button-group"],
|
|
60
|
+
"number-field": ["number-field", "field"],
|
|
61
|
+
"swatch": ["swatch", "toggle", "field"]
|
|
60
62
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<div data-slot='field'>
|
|
2
|
+
<label data-slot='field-label' for='quantity'>Quantity</label>
|
|
3
|
+
<div data-slot='number-field' role='group'>
|
|
4
|
+
<div data-slot='input-group-addon'>
|
|
5
|
+
<button
|
|
6
|
+
type='button'
|
|
7
|
+
data-slot='number-field-decrement'
|
|
8
|
+
tabindex='-1'
|
|
9
|
+
data-button
|
|
10
|
+
data-variant='ghost'
|
|
11
|
+
data-size='icon-xs'
|
|
12
|
+
aria-label='Decrease quantity'
|
|
13
|
+
>
|
|
14
|
+
<svg
|
|
15
|
+
class='icon'
|
|
16
|
+
data-slot='icon'
|
|
17
|
+
viewBox='0 0 24 24'
|
|
18
|
+
fill='none'
|
|
19
|
+
stroke='currentColor'
|
|
20
|
+
stroke-width='2'
|
|
21
|
+
stroke-linecap='round'
|
|
22
|
+
stroke-linejoin='round'
|
|
23
|
+
aria-hidden='true'
|
|
24
|
+
focusable='false'
|
|
25
|
+
>
|
|
26
|
+
<path d='M5 12h14'/>
|
|
27
|
+
</svg>
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
<input
|
|
31
|
+
data-slot='input'
|
|
32
|
+
id='quantity'
|
|
33
|
+
type='number'
|
|
34
|
+
inputmode='numeric'
|
|
35
|
+
name='quantity'
|
|
36
|
+
value='1'
|
|
37
|
+
min='1'
|
|
38
|
+
step='1'
|
|
39
|
+
>
|
|
40
|
+
<div data-slot='input-group-addon' data-align='inline-end'>
|
|
41
|
+
<button
|
|
42
|
+
type='button'
|
|
43
|
+
data-slot='number-field-increment'
|
|
44
|
+
tabindex='-1'
|
|
45
|
+
data-button
|
|
46
|
+
data-variant='ghost'
|
|
47
|
+
data-size='icon-xs'
|
|
48
|
+
aria-label='Increase quantity'
|
|
49
|
+
>
|
|
50
|
+
<svg
|
|
51
|
+
class='icon'
|
|
52
|
+
data-slot='icon'
|
|
53
|
+
viewBox='0 0 24 24'
|
|
54
|
+
fill='none'
|
|
55
|
+
stroke='currentColor'
|
|
56
|
+
stroke-width='2'
|
|
57
|
+
stroke-linecap='round'
|
|
58
|
+
stroke-linejoin='round'
|
|
59
|
+
aria-hidden='true'
|
|
60
|
+
focusable='false'
|
|
61
|
+
>
|
|
62
|
+
<path d='M5 12h14'/><path d='M12 5v14'/>
|
|
63
|
+
</svg>
|
|
64
|
+
</button>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|