@box-kite/react 2.2.15 → 2.2.17
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/.claude/rules/box-kite-rules.md +1 -1
- package/.claude/skills/box-kite/SKILL.md +1 -1
- package/.claude/skills/box-kite/references/styling.md +1 -1
- package/.cursor/rules/box-kite.mdc +1 -1
- package/AGENTS.md +1 -1
- package/BOX_AI_CONTEXT.md +16 -0
- package/BOX_KITE_AI_CONTEXT.md +16 -0
- package/behavior.cjs +1 -1
- package/behavior.mjs +16 -16
- package/catalog.cjs +1 -1
- package/catalog.mjs +1 -1
- package/client.cjs +1 -1
- package/client.mjs +10 -10
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +95 -91
- package/components/calendar.cjs +1 -1
- package/components/calendar.mjs +212 -210
- package/components/chart.cjs +1 -1
- package/components/chart.d.ts +8 -3
- package/components/chart.mjs +70 -65
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +187 -186
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.d.ts +1 -44
- package/components/dashboard.mjs +202 -201
- package/components/dataGrid/components/dataGridListLayout.d.ts +1 -1
- package/components/dataGrid/contracts/dataGridContract.d.ts +1 -1
- package/components/dataGrid/models/gridModel.d.ts +1 -1
- package/components/dataGrid.cjs +2 -2
- package/components/dataGrid.mjs +10 -10
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +96 -96
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +286 -285
- package/components/dialog.cjs +1 -1
- package/components/dialog.d.ts +2 -64
- package/components/dialog.mjs +131 -126
- package/components/form.cjs +1 -1
- package/components/form.d.ts +4 -3
- package/components/form.mjs +25 -22
- package/components/menu.cjs +1 -1
- package/components/menu.d.ts +2 -73
- package/components/menu.mjs +220 -215
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +44 -43
- package/components/popover.cjs +1 -1
- package/components/popover.d.ts +1 -41
- package/components/popover.mjs +56 -51
- package/components/presence.cjs +1 -1
- package/components/presence.mjs +1 -1
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +59 -55
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.d.ts +1 -55
- package/components/slider.mjs +92 -90
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +149 -148
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +100 -100
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +135 -132
- package/components/toaster.cjs +1 -1
- package/components/toaster.d.ts +1 -37
- package/components/toaster.mjs +130 -128
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.d.ts +1 -34
- package/components/tooltip.mjs +73 -69
- package/components/virtualList.cjs +1 -1
- package/components/virtualList.mjs +88 -87
- package/docs/props.md +2 -2
- package/interactionListening.cjs +1 -1
- package/interactionListening.mjs +3 -3
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/motion.cjs +1 -1
- package/motion.mjs +30 -20
- package/package.json +41 -40
- package/placement.cjs +1 -1
- package/placement.mjs +1 -1
- package/platform.cjs +1 -1
- package/platform.mjs +17 -14
- package/react/animation/useHeldContent.d.ts +6 -0
- package/react/animation/usePresence.d.ts +4 -0
- package/react/componentsContext.d.ts +1 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/utils/chart/chartUtils.d.ts +3 -2
- package/utils/dashboard/dashboardUtils.d.ts +1 -1
- package/utils/dom/domUtils.d.ts +6 -0
- package/create/src/agents.d.ts +0 -22
- package/create/src/agents.test.d.ts +0 -1
- package/create/src/index.d.ts +0 -1
- package/create/src/options.d.ts +0 -31
- package/create/src/options.test.d.ts +0 -1
- package/create/src/packageManager.d.ts +0 -5
- package/create/src/project.d.ts +0 -27
- package/create/src/project.test.d.ts +0 -1
- package/create/templates/ts/designs/azure.d.ts +0 -5
- package/create/templates/ts/designs/ember.d.ts +0 -5
- package/create/templates/ts/designs/mono.d.ts +0 -5
- package/create/templates/ts/src/App.d.ts +0 -2
- package/create/templates/ts/src/design.d.ts +0 -5
- package/create/templates/ts/src/main.d.ts +0 -0
- package/mcp/src/data.d.ts +0 -90
- package/mcp/src/data.test.d.ts +0 -1
- package/mcp/src/engine.d.ts +0 -23
- package/mcp/src/index.d.ts +0 -1
- package/mcp/src/search.d.ts +0 -38
- package/mcp/src/search.test.d.ts +0 -1
- package/mcp/src/server.d.ts +0 -18
- package/mcp/src/server.test.d.ts +0 -1
- package/mcp/src/styles.d.ts +0 -27
- package/mcp/src/styles.test.d.ts +0 -1
- package/mcp/src/tools.d.ts +0 -18
- package/mcp/src/vocabulary.d.ts +0 -41
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +0 -24
- package/registry/blocks/dashboard-shell/dashboard-stats.d.ts +0 -13
- package/registry/blocks/data-grid/invoice-rows.d.ts +0 -15
- package/registry/blocks/data-grid/invoices-grid.d.ts +0 -1
- package/registry/blocks/settings-form/settings-form.d.ts +0 -17
- package/registry/designs/store/address-form.d.ts +0 -11
- package/registry/designs/store/cart-items.d.ts +0 -10
- package/registry/designs/store/cart-page.d.ts +0 -4
- package/registry/designs/store/checkout-page.d.ts +0 -7
- package/registry/designs/store/credit-card-form.d.ts +0 -10
- package/registry/designs/store/form-field.d.ts +0 -19
- package/registry/designs/store/order-summary.d.ts +0 -18
- package/registry/designs/store/product-art.d.ts +0 -26
- package/registry/designs/store/product-card.d.ts +0 -11
- package/registry/designs/store/product-gallery.d.ts +0 -11
- package/registry/designs/store/product-grid.d.ts +0 -10
- package/registry/designs/store/product-page.d.ts +0 -5
- package/registry/designs/store/quantity-stepper.d.ts +0 -13
- package/registry/designs/store/shipping-method.d.ts +0 -14
- package/registry/designs/store/store-data.d.ts +0 -53
- package/registry/designs/store/store-design.d.ts +0 -63
- package/registry/designs/store/store-shell.d.ts +0 -12
- package/registry/designs/store/storefront-page.d.ts +0 -4
- package/registry/designs/store/variant-picker.d.ts +0 -15
- package/supabase/functions/collect/index.d.ts +0 -30
- package/supabase/functions/collect/index.test.d.ts +0 -1
package/components/slider.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../reporting.cjs");let a=require("react"),o=require("react/jsx-runtime");var s;(function(e){function t(e){let t=String(Math.abs(e));if(t.includes(`e`))return 12;let n=t.indexOf(`.`);return n===-1?0:t.length-n-1}e.decimals=t;function n(e,t){return Number(e.toFixed(Math.min(t,15)))}function r(e,t,n){return Math.min(Math.max(e,t),n)}e.clamp=r;function i(e,i){let{min:a,max:o,step:s}=i,c=r(e,a,o);return s>0?r(n(a+Math.round((c-a)/s)*s,t(s)+t(a)),a,o):c}e.snap=i;function a(e,t,n){return n<=t?0:(r(e,t,n)-t)*(100/(n-t))}e.percent=a;function o(e,t,n){return`${Math.round(a(e,t,n)*100)/100}%`}e.percentage=o;function s(e){return typeof e==`number`?[e]:[...e]}e.thumbs=s;function c(e,t){return typeof e==`number`?t[0]:[...t]}e.shaped=c;function l(e,t,n,a){let o=t>0?e[t-1]:a.min,s=t<e.length-1?e[t+1]:a.max,c=[...e];return c[t]=r(i(n,a),o,s),c}e.move=l;function u(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}e.same=u;function d(e,t){let n=0,r=1/0;return e.forEach((e,i)=>{let a=Math.abs(e-t);a<=r&&(n=i,r=a)}),n}e.nearest=d;function f(e,t,n,r,i){let a=r===`vertical`?e.height===0?0:(e.bottom-n)/e.height:e.width===0?0:i?(e.right-t)/e.width:(t-e.left)/e.width;return Math.min(Math.max(a,0),1)}e.valueAt=f;function p(e,t=!1){if(e===`Home`)return{kind:`edge`,delta:-1};if(e===`End`)return{kind:`edge`,delta:1};if(e===`PageUp`)return{kind:`page`,delta:1};if(e===`PageDown`)return{kind:`page`,delta:-1};if(e===`ArrowUp`)return{kind:`step`,delta:1};if(e===`ArrowDown`)return{kind:`step`,delta:-1};if(e===`ArrowRight`)return{kind:`step`,delta:t?-1:1};if(e===`ArrowLeft`)return{kind:`step`,delta:t?1:-1}}e.moveFor=p;function m(e,t,n,r){if(t.kind===`edge`)return t.delta>0?n.max:n.min;let i=t.kind===`page`?r:n.step;return e+t.delta*i}e.moved=m})(s||={});var c=s,l=`data-index`;function u(e,t,n){return{min:e,max:t,step:n}}function d(e,t){return t?{insetBlockEnd:e}:{insetInlineStart:e}}function f(e,t,n){let r=e.length>1?Math.min(...e):t.min,i=Math.max(...e),a=c.percent(r,t.min,t.max),o=`${Math.round((c.percent(i,t.min,t.max)-a)*100)/100}%`;return n?{insetBlockEnd:`${Math.round(a*100)/100}%`,blockSize:o}:{insetInlineStart:`${Math.round(a*100)/100}%`,inlineSize:o}}function p(e,s){let{value:p,defaultValue:m,onValueChange:h,onValueCommit:g,min:_=0,max:v=100,step:y=1,largeStep:b=y*10,orientation:x=`horizontal`,disabled:S=!1,label:C,labelledBy:w,thumbLabels:T,format:E,name:D,props:O,...k}=e,A=(0,a.useRef)(null),j=(0,a.useCallback)(e=>{A.current=e,t.l(s,e)},[s]),M=(0,a.useRef)(null),N=(0,a.useRef)(null),P=(0,a.useRef)(!1),[F,I]=(0,a.useState)(!1),[L,R]=r.i({value:p,defaultValue:m??_,onChange:h}),z=u(_,v,y),B=x===`vertical`,V=c.thumbs(L),H=r.o(L),U=i.r(g,`slider`,`valueCommit`),W=r.a((e,t)=>{R(t=>c.same(c.thumbs(t),e)?t:c.shaped(t,e),t)}),G=e=>{let n=M.current;if(!n)return;let r=c.valueAt(n.getBoundingClientRect(),e.clientX,e.clientY,x,t.m(n));return _+r*(v-_)},K=e=>A.current?.querySelectorAll(`[role="slider"]`)[e],q=r.a(e=>{if(S||e.button!==0||e.defaultPrevented)return;let t=G(e);if(t===void 0)return;let n=c.thumbs(H.current),r=c.nearest(n,t);N.current=r,e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),K(r)?.focus(),W(c.move(n,r,t,z),{reason:`pointer`,event:e})}),J=r.a(e=>{let t=N.current;if(t===null)return;let n=G(e);n!==void 0&&(I(!0),W(c.move(c.thumbs(H.current),t,n,z),{reason:`pointer`,event:e}))}),Y=r.a(e=>{N.current!==null&&(N.current=null,I(!1),e.currentTarget.releasePointerCapture?.(e.pointerId),U(H.current,{reason:`pointer`,event:e}))}),X=r.a(e=>{if(S||e.defaultPrevented)return;let n=e.target?.closest(`[role="slider"]`),r=Number(n?.getAttribute(l)??-1);if(!n||r<0)return;let i=c.moveFor(e.key,t.m(n));if(!i)return;e.preventDefault(),P.current=!0,I(!0);let a=c.thumbs(H.current);W(c.move(a,r,c.moved(a[r],i,z,b),z),{reason:`keyboard`,event:e})}),Z=r.a(e=>{P.current&&(P.current=!1,I(!1),U(H.current,{reason:`keyboard`,event:e}))}),Q=V.length>1;return(0,o.jsxs)(n.default,{ref:j,component:`slider`,...k,variant:[k.variant,{vertical:B,disabled:S}],props:{role:Q?`group`:void 0,"aria-label":Q?C:void 0,"aria-labelledby":Q?w:void 0,...O,onPointerDown:q,onPointerMove:J,onPointerUp:Y,onPointerCancel:Y,onKeyDown:X,onKeyUp:Z},children:[(0,o.jsx)(n.default,{ref:M,component:`slider.track`,variant:{vertical:B},children:(0,o.jsx)(n.default,{component:`slider.fill`,variant:{vertical:B,tracking:F},style:f(V,z,B)})}),V.map((e,t)=>(0,o.jsx)(n.default,{component:`slider.thumb`,variant:{vertical:B,disabled:S,tracking:F},style:d(c.percentage(e,_,v),B),props:{role:`slider`,tabIndex:S?-1:0,"aria-valuemin":_,"aria-valuemax":v,"aria-valuenow":e,"aria-valuetext":E?.(e),"aria-orientation":x,"aria-label":T?.[t]??(Q?void 0:C),"aria-labelledby":T?.[t]||Q?void 0:w,"aria-disabled":S||void 0,[l]:t}},t)),D!==void 0&&V.map((e,t)=>(0,o.jsx)(`input`,{type:`hidden`,name:D,value:e,readOnly:!0},t))]})}var m=e.f(p,`Slider`);exports.default=m;
|
package/components/slider.d.ts
CHANGED
|
@@ -40,59 +40,5 @@ export interface SliderProps<TKey extends keyof ComponentsAndVariants = 'slider'
|
|
|
40
40
|
/** What the value submits under. One hidden input per thumb, so a range posts two values of that name. */
|
|
41
41
|
name?: string;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
* A value chosen by dragging a thumb along a track.
|
|
45
|
-
* Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/slider/ and .../slider-multithumb/
|
|
46
|
-
*
|
|
47
|
-
* ```tsx
|
|
48
|
-
* <Slider label="Volume" defaultValue={40} onValueChange={(value) => setVolume(value)} />
|
|
49
|
-
* <Slider label="Price" defaultValue={[20, 80]} thumbLabels={['Lowest', 'Highest']} />
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* **A number in is a number out.** `defaultValue={40}` makes a one-thumb slider whose `onValueChange`
|
|
53
|
-
* hands back a `number`; `defaultValue={[20, 80]}` makes a range whose handler takes a `number[]`. The
|
|
54
|
-
* number of thumbs is the value's own shape, so there is no second prop saying which kind this is.
|
|
55
|
-
*
|
|
56
|
-
* **This is not `<input type="range">`, and that is the one place the platform loses.** A range input
|
|
57
|
-
* cannot hold two thumbs, and its track and thumb are vendor pseudo-elements (`::-webkit-slider-thumb`)
|
|
58
|
-
* that no typed prop can reach — so a styled one is a rewrite of the parts, at which point the native
|
|
59
|
-
* element is only the keyboard. `name` still submits: a hidden input per thumb, so a form posts the
|
|
60
|
-
* value whether or not JavaScript ran the drag.
|
|
61
|
-
*
|
|
62
|
-
* **The position is an inline style, deliberately.** Everything a slider paints is a shared class except
|
|
63
|
-
* where its thumbs are — that is a per-frame value, and a class for it would be a rule per frame of a
|
|
64
|
-
* drag, never freed. It is the exception `useAnchorPosition`'s anchor name and the travelling tab
|
|
65
|
-
* indicator already take, and the reason a `ProgressRing` can round its fraction into a class where this
|
|
66
|
-
* cannot: nobody drags a ring.
|
|
67
|
-
*
|
|
68
|
-
* **It mirrors for free.** The fill and the thumbs are placed with `inset-inline-start`, so a
|
|
69
|
-
* right-to-left page draws the minimum on the right with no second stylesheet. The half that is not free
|
|
70
|
-
* is the keyboard, which is why the sideways arrows swap and Up and Down never do.
|
|
71
|
-
*
|
|
72
|
-
* **A press travels; a nudge does not.** A press on the track is the one move the eye has to follow, so
|
|
73
|
-
* the thumb animates the whole way. Every other move — a drag, an arrow key, a held arrow — is the
|
|
74
|
-
* `tracking` variant instead: 60ms `ease-out` on both the thumb and the fill, which must both carry it
|
|
75
|
-
* or they come apart (#144). Short rather than *off*, because off is exact and steps — a 1-in-100 slider
|
|
76
|
-
* moves 3.2px at a time on a 320px track. **Eased out rather than linear or eased**: a repeat restarts
|
|
77
|
-
* the transition every 33ms, so only its first half is ever seen, and on this curve that half is the
|
|
78
|
-
* straight part — it glides while the key is held and still decelerates on the last transition, the one
|
|
79
|
-
* allowed to finish. Measured against linear, which rode **1.4 steps** behind the value and stopped at
|
|
80
|
-
* full speed, this rides 0.9 behind and lands at 0.6 of cruising (#146).
|
|
81
|
-
*
|
|
82
|
-
* @pattern https://www.w3.org/WAI/ARIA/apg/patterns/slider/
|
|
83
|
-
* @a11y Each thumb is a `role="slider"` carrying `aria-valuemin`, `aria-valuemax`, `aria-valuenow` and
|
|
84
|
-
* `aria-orientation`; `format` writes `aria-valuetext` for a value a bare number does not read as.
|
|
85
|
-
* @a11y A thumb has to be named, so `label` names the one on a single slider — and on a range it names
|
|
86
|
-
* the `role="group"` around the thumbs, where `thumbLabels` names them one at a time.
|
|
87
|
-
* @a11y `disabled` is `aria-disabled` rather than the attribute: a slider a reader cannot reach is a
|
|
88
|
-
* value they cannot read, and a div takes no `disabled` anyway.
|
|
89
|
-
* @keyboard Tab — Every thumb is its own tab stop, so a range is two of them.
|
|
90
|
-
* @keyboard Right / Up — One step towards the maximum. In a right-to-left page Left is the increase, and
|
|
91
|
-
* Up never changes: the block axis has no reading order.
|
|
92
|
-
* @keyboard Left / Down — One step towards the minimum.
|
|
93
|
-
* @keyboard PageUp / PageDown — `largeStep`, ten steps unless it says otherwise.
|
|
94
|
-
* @keyboard Home / End — The minimum and the maximum themselves, on or off the step grid.
|
|
95
|
-
*/
|
|
96
|
-
declare function SliderImpl<TKey extends keyof ComponentsAndVariants = 'slider', TValue extends SliderValue = number>(props: SliderProps<TKey, TValue>): import("react").JSX.Element;
|
|
97
|
-
declare const Slider: typeof SliderImpl;
|
|
43
|
+
declare const Slider: <TKey extends keyof ComponentsAndVariants = "slider", TValue extends SliderValue = number>(props: SliderProps<TKey, TValue>) => React.ReactNode;
|
|
98
44
|
export default Slider;
|
package/components/slider.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import t from "../
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { l as t, m as n } from "../platform.mjs";
|
|
4
|
+
import r from "../box.mjs";
|
|
5
|
+
import { a as i, i as a, o } from "../behavior.mjs";
|
|
6
|
+
import { r as s } from "../reporting.mjs";
|
|
7
|
+
import { useCallback as c, useRef as l, useState as u } from "react";
|
|
8
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
9
|
//#region src/utils/slider/sliderUtils.ts
|
|
9
|
-
var
|
|
10
|
+
var p;
|
|
10
11
|
(function(e) {
|
|
11
12
|
function t(e) {
|
|
12
13
|
let t = String(Math.abs(e));
|
|
@@ -106,20 +107,20 @@ var u;
|
|
|
106
107
|
return e + t.delta * i;
|
|
107
108
|
}
|
|
108
109
|
e.moved = m;
|
|
109
|
-
})(
|
|
110
|
-
var
|
|
111
|
-
function
|
|
110
|
+
})(p ||= {});
|
|
111
|
+
var m = p, h = "data-index";
|
|
112
|
+
function g(e, t, n) {
|
|
112
113
|
return {
|
|
113
114
|
min: e,
|
|
114
115
|
max: t,
|
|
115
116
|
step: n
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
+
function _(e, t) {
|
|
119
120
|
return t ? { insetBlockEnd: e } : { insetInlineStart: e };
|
|
120
121
|
}
|
|
121
|
-
function
|
|
122
|
-
let r = e.length > 1 ? Math.min(...e) : t.min, i = Math.max(...e), a =
|
|
122
|
+
function v(e, t, n) {
|
|
123
|
+
let r = e.length > 1 ? Math.min(...e) : t.min, i = Math.max(...e), a = m.percent(r, t.min, t.max), o = `${Math.round((m.percent(i, t.min, t.max) - a) * 100) / 100}%`;
|
|
123
124
|
return n ? {
|
|
124
125
|
insetBlockEnd: `${Math.round(a * 100) / 100}%`,
|
|
125
126
|
blockSize: o
|
|
@@ -128,124 +129,125 @@ function h(e, t, n) {
|
|
|
128
129
|
inlineSize: o
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
|
-
function
|
|
132
|
-
let { value:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}), q = (t) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
132
|
+
function y(e, p) {
|
|
133
|
+
let { value: y, defaultValue: b, onValueChange: x, onValueCommit: S, min: C = 0, max: w = 100, step: T = 1, largeStep: E = T * 10, orientation: D = "horizontal", disabled: O = !1, label: k, labelledBy: A, thumbLabels: j, format: M, name: N, props: ee, ...P } = e, F = l(null), I = c((e) => {
|
|
134
|
+
F.current = e, t(p, e);
|
|
135
|
+
}, [p]), L = l(null), R = l(null), z = l(!1), [B, V] = u(!1), [H, te] = a({
|
|
136
|
+
value: y,
|
|
137
|
+
defaultValue: b ?? C,
|
|
138
|
+
onChange: x
|
|
139
|
+
}), U = g(C, w, T), W = D === "vertical", G = m.thumbs(H), K = o(H), q = s(S, "slider", "valueCommit"), J = i((e, t) => {
|
|
140
|
+
te((t) => m.same(m.thumbs(t), e) ? t : m.shaped(t, e), t);
|
|
141
|
+
}), Y = (e) => {
|
|
142
|
+
let t = L.current;
|
|
143
|
+
if (!t) return;
|
|
144
|
+
let r = m.valueAt(t.getBoundingClientRect(), e.clientX, e.clientY, D, n(t));
|
|
145
|
+
return C + r * (w - C);
|
|
146
|
+
}, X = (e) => F.current?.querySelectorAll("[role=\"slider\"]")[e], Z = i((e) => {
|
|
147
|
+
if (O || e.button !== 0 || e.defaultPrevented) return;
|
|
148
|
+
let t = Y(e);
|
|
146
149
|
if (t === void 0) return;
|
|
147
|
-
let n =
|
|
148
|
-
|
|
150
|
+
let n = m.thumbs(K.current), r = m.nearest(n, t);
|
|
151
|
+
R.current = r, e.preventDefault(), e.currentTarget.setPointerCapture?.(e.pointerId), X(r)?.focus(), J(m.move(n, r, t, U), {
|
|
149
152
|
reason: "pointer",
|
|
150
153
|
event: e
|
|
151
154
|
});
|
|
152
|
-
}),
|
|
153
|
-
let t =
|
|
155
|
+
}), ne = i((e) => {
|
|
156
|
+
let t = R.current;
|
|
154
157
|
if (t === null) return;
|
|
155
|
-
let n =
|
|
156
|
-
n !== void 0 && (
|
|
158
|
+
let n = Y(e);
|
|
159
|
+
n !== void 0 && (V(!0), J(m.move(m.thumbs(K.current), t, n, U), {
|
|
157
160
|
reason: "pointer",
|
|
158
161
|
event: e
|
|
159
162
|
}));
|
|
160
|
-
}),
|
|
161
|
-
|
|
163
|
+
}), Q = i((e) => {
|
|
164
|
+
R.current !== null && (R.current = null, V(!1), e.currentTarget.releasePointerCapture?.(e.pointerId), q(K.current, {
|
|
162
165
|
reason: "pointer",
|
|
163
166
|
event: e
|
|
164
167
|
}));
|
|
165
|
-
}),
|
|
166
|
-
if (
|
|
167
|
-
let
|
|
168
|
-
if (!
|
|
169
|
-
let i =
|
|
168
|
+
}), re = i((e) => {
|
|
169
|
+
if (O || e.defaultPrevented) return;
|
|
170
|
+
let t = e.target?.closest("[role=\"slider\"]"), r = Number(t?.getAttribute(h) ?? -1);
|
|
171
|
+
if (!t || r < 0) return;
|
|
172
|
+
let i = m.moveFor(e.key, n(t));
|
|
170
173
|
if (!i) return;
|
|
171
|
-
|
|
172
|
-
let a =
|
|
173
|
-
|
|
174
|
+
e.preventDefault(), z.current = !0, V(!0);
|
|
175
|
+
let a = m.thumbs(K.current);
|
|
176
|
+
J(m.move(a, r, m.moved(a[r], i, U, E), U), {
|
|
174
177
|
reason: "keyboard",
|
|
175
|
-
event:
|
|
178
|
+
event: e
|
|
176
179
|
});
|
|
177
|
-
}),
|
|
178
|
-
|
|
180
|
+
}), ie = i((e) => {
|
|
181
|
+
z.current && (z.current = !1, V(!1), q(K.current, {
|
|
179
182
|
reason: "keyboard",
|
|
180
183
|
event: e
|
|
181
184
|
}));
|
|
182
|
-
}), $ =
|
|
183
|
-
return /* @__PURE__ */
|
|
184
|
-
ref:
|
|
185
|
+
}), $ = G.length > 1;
|
|
186
|
+
return /* @__PURE__ */ f(r, {
|
|
187
|
+
ref: I,
|
|
185
188
|
component: "slider",
|
|
186
|
-
...
|
|
187
|
-
variant: [
|
|
188
|
-
vertical:
|
|
189
|
-
disabled:
|
|
189
|
+
...P,
|
|
190
|
+
variant: [P.variant, {
|
|
191
|
+
vertical: W,
|
|
192
|
+
disabled: O
|
|
190
193
|
}],
|
|
191
194
|
props: {
|
|
192
195
|
role: $ ? "group" : void 0,
|
|
193
|
-
"aria-label": $ ?
|
|
194
|
-
"aria-labelledby": $ ?
|
|
195
|
-
...
|
|
196
|
-
onPointerDown:
|
|
197
|
-
onPointerMove:
|
|
198
|
-
onPointerUp:
|
|
199
|
-
onPointerCancel:
|
|
200
|
-
onKeyDown:
|
|
201
|
-
onKeyUp:
|
|
196
|
+
"aria-label": $ ? k : void 0,
|
|
197
|
+
"aria-labelledby": $ ? A : void 0,
|
|
198
|
+
...ee,
|
|
199
|
+
onPointerDown: Z,
|
|
200
|
+
onPointerMove: ne,
|
|
201
|
+
onPointerUp: Q,
|
|
202
|
+
onPointerCancel: Q,
|
|
203
|
+
onKeyDown: re,
|
|
204
|
+
onKeyUp: ie
|
|
202
205
|
},
|
|
203
206
|
children: [
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
ref:
|
|
207
|
+
/* @__PURE__ */ d(r, {
|
|
208
|
+
ref: L,
|
|
206
209
|
component: "slider.track",
|
|
207
|
-
variant: { vertical:
|
|
208
|
-
children: /* @__PURE__ */
|
|
210
|
+
variant: { vertical: W },
|
|
211
|
+
children: /* @__PURE__ */ d(r, {
|
|
209
212
|
component: "slider.fill",
|
|
210
213
|
variant: {
|
|
211
|
-
vertical:
|
|
212
|
-
tracking:
|
|
214
|
+
vertical: W,
|
|
215
|
+
tracking: B
|
|
213
216
|
},
|
|
214
|
-
style:
|
|
217
|
+
style: v(G, U, W)
|
|
215
218
|
})
|
|
216
219
|
}),
|
|
217
|
-
|
|
220
|
+
G.map((e, t) => /* @__PURE__ */ d(r, {
|
|
218
221
|
component: "slider.thumb",
|
|
219
222
|
variant: {
|
|
220
|
-
vertical:
|
|
221
|
-
disabled:
|
|
222
|
-
tracking:
|
|
223
|
+
vertical: W,
|
|
224
|
+
disabled: O,
|
|
225
|
+
tracking: B
|
|
223
226
|
},
|
|
224
|
-
style: m
|
|
227
|
+
style: _(m.percentage(e, C, w), W),
|
|
225
228
|
props: {
|
|
226
229
|
role: "slider",
|
|
227
|
-
tabIndex:
|
|
228
|
-
"aria-valuemin":
|
|
229
|
-
"aria-valuemax":
|
|
230
|
+
tabIndex: O ? -1 : 0,
|
|
231
|
+
"aria-valuemin": C,
|
|
232
|
+
"aria-valuemax": w,
|
|
230
233
|
"aria-valuenow": e,
|
|
231
|
-
"aria-valuetext":
|
|
232
|
-
"aria-orientation":
|
|
233
|
-
"aria-label":
|
|
234
|
-
"aria-labelledby":
|
|
235
|
-
"aria-disabled":
|
|
236
|
-
[
|
|
234
|
+
"aria-valuetext": M?.(e),
|
|
235
|
+
"aria-orientation": D,
|
|
236
|
+
"aria-label": j?.[t] ?? ($ ? void 0 : k),
|
|
237
|
+
"aria-labelledby": j?.[t] || $ ? void 0 : A,
|
|
238
|
+
"aria-disabled": O || void 0,
|
|
239
|
+
[h]: t
|
|
237
240
|
}
|
|
238
|
-
},
|
|
239
|
-
|
|
241
|
+
}, t)),
|
|
242
|
+
N !== void 0 && G.map((e, t) => /* @__PURE__ */ d("input", {
|
|
240
243
|
type: "hidden",
|
|
241
|
-
name:
|
|
244
|
+
name: N,
|
|
242
245
|
value: e,
|
|
243
246
|
readOnly: !0
|
|
244
247
|
}, t))
|
|
245
248
|
]
|
|
246
249
|
});
|
|
247
250
|
}
|
|
248
|
-
var
|
|
249
|
-
_.displayName = "Slider";
|
|
251
|
+
var b = e(y, "Slider");
|
|
250
252
|
//#endregion
|
|
251
|
-
export {
|
|
253
|
+
export { b as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../reporting.cjs"),o=require("./svg.cjs"),s=require("./visuallyHidden.cjs"),c=require("../scrolling.cjs"),l=require("./list.cjs");let u=require("react"),d=require("react/jsx-runtime");var f;(function(e){e.SLOP=4;function t(e){return e.top+e.height/2}function n(e,n,r){let i=e[n];if(!i)return n;let a=t(i)+r,o=n;if(r>0)for(let r=n+1;r<e.length&&a>t(e[r]);r++)o=r;else for(let r=n-1;r>=0&&a<t(e[r]);r--)o=r;return o}e.targetIndex=n;function r(e,t){let n=e[t];if(!n)return 0;let r=e.length>1?Math.max(0,e[1].top-e[0].top-e[0].height):0;return n.height+r}e.pitchOf=r;function i(e,t,n,i){return t<n&&i>t&&i<=n?-r(e,t):n<t&&i>=n&&i<t?r(e,t):0}e.shiftOf=i;function a(e,t,n){let r=e.slice();if(t===n||t<0||t>=r.length)return r;let[i]=r.splice(t,1);return r.splice(Math.max(0,Math.min(n,r.length)),0,i),r}e.move=a;function o(e,t,n){switch(e){case`ArrowUp`:return Math.max(0,t-1);case`ArrowDown`:return Math.min(n-1,t+1);case`Home`:return 0;case`End`:return n-1;default:return null}}e.keyTarget=o})(f||={});var p=f,m=(0,u.createContext)(null),h=(0,u.createContext)(null),g=48,ee=12,_=`:scope > [data-sortable-value]`;function v(e){return e?Array.from(e.querySelectorAll(_)):[]}function y(e){return v(e).map(e=>e.dataset.sortableValue??``)}function b(e){return new Map(v(e).map(e=>[e.dataset.sortableValue??``,e.getBoundingClientRect().top]))}function te(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function x(e,r){let{onOrderChange:o,onOrderCommit:f,children:h,variant:_,props:x,...S}=e,C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(null),[O,k]=(0,u.useState)(0),[A,j]=(0,u.useState)(!1),[ne,M]=(0,u.useState)(``),N=`${(0,u.useId)()}-sortable`,P=i.o(E),F=a.r(o,`sortableList`,`orderChange`),I=a.r(f,`sortableList`,`orderCommit`),L=a.i(`sortableList`),R=(0,u.useCallback)(e=>{C.current=e,t.l(r,e)},[r]),z=(e,t)=>`position ${e.indexOf(t)+1} of ${e.length}`,B=(e,t)=>{T.current=b(C.current),F(e,t)};n.n(()=>{let e=T.current;if(e){T.current=null;for(let t of v(C.current)){let n=e.get(t.dataset.sortableValue??``),r=n===void 0?0:n-t.getBoundingClientRect().top,i=parseFloat(getComputedStyle(t).transitionDuration)*1e3||0;Math.abs(r)<1||i===0||typeof t.animate!=`function`||t.animate([{translate:`0 ${r}px`},{translate:`0 0`}],{duration:i,easing:`ease-out`})}}}),(0,u.useEffect)(()=>{if(!A)return;let e=requestAnimationFrame(()=>j(!1));return()=>cancelAnimationFrame(e)},[A]),n.n(()=>{if(!E||E.pointer)return;let e=v(C.current).find(e=>e.dataset.sortableValue===E.value)?.querySelector(`[data-sortable-handle]`);e&&e.ownerDocument.activeElement!==e&&e.focus()});let V=i.a((e,t)=>{let n=e.pointer,r=C.current;if(!n||!r)return;n.lastY=t;let i=t-r.getBoundingClientRect().top-(n.startY-n.startTop),a=n.order.indexOf(e.value);n.to=p.targetIndex(n.slots,a,i),k(i)}),H=(e,t)=>{let n=C.current;if(!n)return;let r=n.getBoundingClientRect().top,i=v(n),a=i.map(e=>e.dataset.sortableValue??``),o=i.map(e=>{let t=e.getBoundingClientRect();return{top:t.top-r,height:t.height}}),s={value:t.value,name:t.name,origin:a,pointer:{id:t.id,startY:t.y,startTop:r,lastY:e.clientY,slots:o,order:a,to:a.indexOf(t.value)}};D(s),V(s,e.clientY)},U=E?.pointer!==void 0;(0,u.useEffect)(()=>{if(!U)return;let e=c.t(C.current),t=0,n=()=>{let r=P.current;if(r?.pointer){let t=r.pointer.lastY,n=e?e.getBoundingClientRect().top:0,i=e?e.getBoundingClientRect().bottom:window.innerHeight,a=t<n+g?-12:t>i-g?ee:0;a&&((e??window).scrollBy(0,a),V(r,t))}t=requestAnimationFrame(n)};return t=requestAnimationFrame(n),()=>cancelAnimationFrame(t)},[U,V,P]);let W=(e,t,n)=>{let r=y(C.current);D({value:e,name:t,origin:r}),L(`grab`,e,{reason:n.type===`keydown`?`keyboard`:`pointer`,event:n,from:r.indexOf(e)}),M(`${t} picked up at ${z(r,e)}. Use the arrow keys to move it, Enter to drop it.`),n.preventDefault()},G=(e,t,n=y(C.current))=>{let r=n.indexOf(e.value);D(null),I(n,{reason:`keyboard`,event:t,value:e.value,from:e.origin.indexOf(e.value),to:r}),M(`${e.name} dropped at ${z(n,e.value)}.`)},K=i.a((e,t)=>{let n=y(C.current);L(`grabCancel`,e.value,{reason:t.type===`keydown`?`escape`:t.type===`blur`?`blur`:`pointercancel`,event:t}),D(null),k(0),te(n,e.origin)||B(e.origin,{reason:e.pointer?`pointer`:`keyboard`,event:t,value:e.value,from:n.indexOf(e.value),to:e.origin.indexOf(e.value)}),M(`${e.name} put back at ${z(e.origin,e.value)}.`)}),q=(e,t,n)=>{let r=y(C.current),i=r.indexOf(e.value);if(i<0||t===i)return r;let a=p.move(r,i,t);return B(a,{reason:`keyboard`,event:n,value:e.value,from:i,to:t}),M(`${e.name}, ${z(a,e.value)}.`),a},J=i.a((e,t,n)=>{e.button!==0||e.defaultPrevented||(e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture?.(e.pointerId),w.current={id:e.pointerId,x:e.clientX,y:e.clientY,value:t,name:n})}),Y=i.a(e=>{let t=P.current;if(t?.pointer&&t.pointer.id===e.pointerId){V(t,e.clientY);return}let n=w.current;!n||n.id!==e.pointerId||Math.hypot(e.clientX-n.x,e.clientY-n.y)<p.SLOP||(w.current=null,H(e,n))}),X=i.a(e=>{let t=w.current;w.current=null;let n=P.current;if(t&&t.id===e.pointerId&&e.type===`pointerup`){n&&!n.pointer?n.value===t.value&&G(n,e):W(t.value,t.name,e);return}let r=n?.pointer;if(!n||!r||r.id!==e.pointerId)return;if(e.currentTarget.releasePointerCapture?.(e.pointerId),j(!0),e.type===`pointercancel`){T.current=b(C.current),K(n,e);return}let i=r.order.indexOf(n.value),a=p.move(r.order,i,r.to),o={reason:`pointer`,event:e,value:n.value,from:i,to:r.to};T.current=b(C.current),D(null),k(0),r.to!==i&&F(a,o),I(a,o),M(`${n.name} dropped at ${z(a,n.value)}.`)}),Z=i.a((e,t,n)=>{if(e.defaultPrevented)return;let r=P.current,i=r&&r.value===t&&!r.pointer?r:void 0;if(!i){(e.key===`Enter`||e.key===` `)&&W(t,n,e);return}if(e.key===`Escape`){e.preventDefault(),K(i,e);return}if(e.key===`Enter`||e.key===` `){e.preventDefault(),G(i,e);return}let a=y(C.current),o=p.keyTarget(e.key,a.indexOf(t),a.length);o!==null&&(e.preventDefault(),q(i,o,e))}),Q=i.a(e=>{setTimeout(()=>{let t=P.current,n=C.current;!t||t.pointer||t.value!==e||!n||n.ownerDocument.activeElement?.closest(`[data-sortable-value]`)?.getAttribute(`data-sortable-value`)!==e&&K(t,new Event(`blur`))})}),$=e=>{let t=P.current;if(!t||t.pointer||!(e.target instanceof Element))return null;let n=e.target.closest(`[data-sortable-value]`);return n&&n.parentElement===C.current&&n.dataset.sortableValue!==t.value?n:null},re=e=>{$(e)&&e.preventDefault()},ie=e=>{let t=$(e),n=P.current;!t||!n||(e.preventDefault(),e.stopPropagation(),G(n,e,q(n,y(C.current).indexOf(t.dataset.sortableValue??``),e)))},ae=(0,u.useMemo)(()=>{let e=E?.pointer,t=e?e.order.indexOf(E.value):-1;return{heldOf:e=>E&&E.value===e?E.pointer?`pointer`:`keyboard`:void 0,translateOf:n=>{if(!e)return;if(n===E.value)return`0 ${Math.round(O)}px`;let r=p.shiftOf(e.slots,t,e.to,e.order.indexOf(n));return r?`0 ${r}px`:void 0},settling:A,instructionsId:N,handleProps:(e,t)=>({type:`button`,"data-sortable-handle":``,"aria-label":`Move ${t}`,"aria-pressed":E?.value===e,"aria-describedby":N,onPointerDown:n=>J(n,e,t),onPointerMove:Y,onPointerUp:X,onPointerCancel:X,onKeyDown:n=>Z(n,e,t),onBlur:()=>Q(e)})}},[E,O,A,N,J,Y,X,Z,Q]);return(0,d.jsxs)(m.Provider,{value:ae,children:[(0,d.jsx)(l.default,{ref:R,...S,variant:_,userSelect:U?`none`:void 0,props:{...x,onMouseDownCapture:re,onClickCapture:ie},children:h}),(0,d.jsx)(s.default,{props:{role:`status`},children:ne}),(0,d.jsx)(s.default,{id:N,children:`Press Enter or Space to pick the item up, the arrow keys to move it, Enter to drop it and Escape to put it back.`})]})}function S(e,t){let{value:n,label:r,disabled:i=!1,variant:a,props:o,...s}=e,c=(0,u.useContext)(m),f=c?.heldOf(n),p=c?.translateOf(n),g=(0,u.useMemo)(()=>({value:n,name:r??n,disabled:i}),[n,r,i]);return(0,d.jsx)(h.Provider,{value:g,children:(0,d.jsx)(l.default.Item,{ref:t,...s,variant:[a,{lifted:f===`pointer`,grabbed:f===`keyboard`,settling:c?.settling??!1}],style:p?{translate:p}:void 0,props:{...o,"data-sortable-value":n}})})}function C(){return(0,d.jsx)(o.Svg,{viewBox:`0 0 16 16`,width:`1rem`,fill:`currentColor`,children:[5,11].flatMap(e=>[3,8,13].map(t=>(0,d.jsx)(o.Circle,{cx:e,cy:t,r:1.4},`${e}-${t}`)))})}function w(e,t){let{children:n,variant:i,props:a,...o}=e,s=(0,u.useContext)(m),c=(0,u.useContext)(h),l=c&&s?s.handleProps(c.value,c.name):{};return r.useBoxElement({tag:`button`,component:`sortableList.handle`,display:`flex`,ai:`center`,jc:`center`,flexShrink:0,width:10,height:10,position:`relative`,zIndex:1,css:{touchAction:`none`},...o,variant:[i,{grabbed:c?s?.heldOf(c.value)!==void 0:!1}],props:{...l,...c?.disabled?{disabled:!0}:{},...a},children:n??(0,d.jsx)(C,{})},t)}var T=e.f(x,`SortableList`);T.Item=e.f(S,`SortableList.Item`),T.Handle=e.f(w,`SortableList.Handle`),exports.SortableUtils=p,exports.default=T;
|