@cdx-ui/primitives 0.3.4 → 0.3.6
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/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/select/SelectEmpty.js +2 -13
- package/lib/commonjs/select/SelectEmpty.js.map +1 -1
- package/lib/commonjs/slider/useSliderPointer.js +9 -4
- package/lib/commonjs/slider/useSliderPointer.js.map +1 -1
- package/lib/commonjs/stepper/StepperRoot.js +119 -0
- package/lib/commonjs/stepper/StepperRoot.js.map +1 -0
- package/lib/commonjs/stepper/StepperStep.js +78 -0
- package/lib/commonjs/stepper/StepperStep.js.map +1 -0
- package/lib/commonjs/stepper/StepperStepPressable.js +63 -0
- package/lib/commonjs/stepper/StepperStepPressable.js.map +1 -0
- package/lib/commonjs/stepper/StepperStepTrigger.js +44 -0
- package/lib/commonjs/stepper/StepperStepTrigger.js.map +1 -0
- package/lib/commonjs/stepper/StepperStepTrigger.web.js +71 -0
- package/lib/commonjs/stepper/StepperStepTrigger.web.js.map +1 -0
- package/lib/commonjs/stepper/context.js +21 -0
- package/lib/commonjs/stepper/context.js.map +1 -0
- package/lib/commonjs/stepper/index.js +46 -0
- package/lib/commonjs/stepper/index.js.map +1 -0
- package/lib/commonjs/stepper/types.js +6 -0
- package/lib/commonjs/stepper/types.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/select/SelectEmpty.js +2 -13
- package/lib/module/select/SelectEmpty.js.map +1 -1
- package/lib/module/slider/useSliderPointer.js +9 -4
- package/lib/module/slider/useSliderPointer.js.map +1 -1
- package/lib/module/stepper/StepperRoot.js +115 -0
- package/lib/module/stepper/StepperRoot.js.map +1 -0
- package/lib/module/stepper/StepperStep.js +74 -0
- package/lib/module/stepper/StepperStep.js.map +1 -0
- package/lib/module/stepper/StepperStepPressable.js +60 -0
- package/lib/module/stepper/StepperStepPressable.js.map +1 -0
- package/lib/module/stepper/StepperStepTrigger.js +40 -0
- package/lib/module/stepper/StepperStepTrigger.js.map +1 -0
- package/lib/module/stepper/StepperStepTrigger.web.js +67 -0
- package/lib/module/stepper/StepperStepTrigger.web.js.map +1 -0
- package/lib/module/stepper/context.js +11 -0
- package/lib/module/stepper/context.js.map +1 -0
- package/lib/module/stepper/index.js +7 -0
- package/lib/module/stepper/index.js.map +1 -0
- package/lib/module/stepper/types.js +4 -0
- package/lib/module/stepper/types.js.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/select/SelectEmpty.d.ts.map +1 -1
- package/lib/typescript/slider/useSliderPointer.d.ts.map +1 -1
- package/lib/typescript/stepper/StepperRoot.d.ts +7 -0
- package/lib/typescript/stepper/StepperRoot.d.ts.map +1 -0
- package/lib/typescript/stepper/StepperStep.d.ts +7 -0
- package/lib/typescript/stepper/StepperStep.d.ts.map +1 -0
- package/lib/typescript/stepper/StepperStepPressable.d.ts +8 -0
- package/lib/typescript/stepper/StepperStepPressable.d.ts.map +1 -0
- package/lib/typescript/stepper/StepperStepTrigger.d.ts +9 -0
- package/lib/typescript/stepper/StepperStepTrigger.d.ts.map +1 -0
- package/lib/typescript/stepper/StepperStepTrigger.web.d.ts +9 -0
- package/lib/typescript/stepper/StepperStepTrigger.web.d.ts.map +1 -0
- package/lib/typescript/stepper/context.d.ts +16 -0
- package/lib/typescript/stepper/context.d.ts.map +1 -0
- package/lib/typescript/stepper/index.d.ts +6 -0
- package/lib/typescript/stepper/index.d.ts.map +1 -0
- package/lib/typescript/stepper/types.d.ts +96 -0
- package/lib/typescript/stepper/types.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/select/SelectEmpty.tsx +2 -22
- package/src/slider/useSliderPointer.ts +9 -4
- package/src/stepper/StepperRoot.tsx +148 -0
- package/src/stepper/StepperStep.tsx +101 -0
- package/src/stepper/StepperStepPressable.tsx +48 -0
- package/src/stepper/StepperStepTrigger.tsx +38 -0
- package/src/stepper/StepperStepTrigger.web.tsx +69 -0
- package/src/stepper/context.tsx +11 -0
- package/src/stepper/index.ts +16 -0
- package/src/stepper/types.ts +104 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useStepperStep = exports.useStepperIndex = exports.useStepperContext = exports.StepperStepProvider = exports.StepperProvider = exports.StepperIndexProvider = void 0;
|
|
7
|
+
var _utils = require("@cdx-ui/utils");
|
|
8
|
+
const [StepperProvider, useStepperContext] = (0, _utils.createContext)('StepperContext');
|
|
9
|
+
|
|
10
|
+
/** Position of a direct child of `StepperRoot`, supplied by the root while it renders. */
|
|
11
|
+
exports.useStepperContext = useStepperContext;
|
|
12
|
+
exports.StepperProvider = StepperProvider;
|
|
13
|
+
const [StepperIndexProvider, useStepperIndex] = (0, _utils.createContext)('StepperIndex');
|
|
14
|
+
|
|
15
|
+
/** Resolved state of the enclosing step. `useStepperStep` throws outside a `StepperStep`. */
|
|
16
|
+
exports.useStepperIndex = useStepperIndex;
|
|
17
|
+
exports.StepperIndexProvider = StepperIndexProvider;
|
|
18
|
+
const [StepperStepProvider, useStepperStep] = (0, _utils.createContext)('StepperStep');
|
|
19
|
+
exports.useStepperStep = useStepperStep;
|
|
20
|
+
exports.StepperStepProvider = StepperStepProvider;
|
|
21
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","StepperProvider","useStepperContext","createContext","exports","StepperIndexProvider","useStepperIndex","StepperStepProvider","useStepperStep"],"sourceRoot":"../../../src","sources":["stepper/context.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAM,CAACC,eAAe,EAAEC,iBAAiB,CAAC,GAC/C,IAAAC,oBAAa,EAAsB,gBAAgB,CAAC;;AAEtD;AAAAC,OAAA,CAAAF,iBAAA,GAAAA,iBAAA;AAAAE,OAAA,CAAAH,eAAA,GAAAA,eAAA;AACO,MAAM,CAACI,oBAAoB,EAAEC,eAAe,CAAC,GAAG,IAAAH,oBAAa,EAAS,cAAc,CAAC;;AAE5F;AAAAC,OAAA,CAAAE,eAAA,GAAAA,eAAA;AAAAF,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AACO,MAAM,CAACE,mBAAmB,EAAEC,cAAc,CAAC,GAAG,IAAAL,oBAAa,EAAmB,aAAa,CAAC;AAACC,OAAA,CAAAI,cAAA,GAAAA,cAAA;AAAAJ,OAAA,CAAAG,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "StepperRoot", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _StepperRoot.StepperRoot;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "StepperStep", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _StepperStep.StepperStep;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "StepperStepTrigger", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _StepperStepTrigger.StepperStepTrigger;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useStepperContext", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _context.useStepperContext;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "useStepperIndex", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _context.useStepperIndex;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "useStepperStep", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _context.useStepperStep;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _context = require("./context");
|
|
43
|
+
var _StepperRoot = require("./StepperRoot");
|
|
44
|
+
var _StepperStep = require("./StepperStep");
|
|
45
|
+
var _StepperStepTrigger = require("./StepperStepTrigger");
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_context","require","_StepperRoot","_StepperStep","_StepperStepTrigger"],"sourceRoot":"../../../src","sources":["stepper/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["stepper/types.ts"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -45,6 +45,7 @@ export * from './progress-bar';
|
|
|
45
45
|
export * from './radio';
|
|
46
46
|
export * from './accordion';
|
|
47
47
|
export * from './slider';
|
|
48
|
+
export * from './stepper';
|
|
48
49
|
export { FormControlContext, useFormControlContext } from '@cdx-ui/utils';
|
|
49
50
|
export { dataAttributes, mergeDataAttributes } from './utils/dataAttributes';
|
|
50
51
|
export { domDataAttributes, mergeDomDataAttributes } from './utils/domDataAttributes';
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MODAL_OVERLAY_Z_INDEX","NOTIFICATION_OVERLAY_Z_INDEX","OVERLAY_PLACEMENTS","getAnchoredOverlayPosition","OverlayContainer","OverlayInsetsProvider","OverlayStackProvider","useAnchorPosition","useAnchoredOverlay","useDismissOverlay","useEscapeKey","useOverlayStackRegistration","useOverlayPosition","FormControlContext","useFormControlContext","dataAttributes","mergeDataAttributes","domDataAttributes","mergeDomDataAttributes","mapViewPropsToDom","assignRef","createPortalFn","useHasTextAncestor","Slot"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,SACEA,qBAAqB,EACrBC,4BAA4B,EAC5BC,kBAAkB,EAElBC,0BAA0B,EAC1BC,gBAAgB,EAChBC,qBAAqB,EACrBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,YAAY,EACZC,2BAA2B,EAC3BC,kBAAkB,QAmBb,WAAW;AAClB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;
|
|
1
|
+
{"version":3,"names":["MODAL_OVERLAY_Z_INDEX","NOTIFICATION_OVERLAY_Z_INDEX","OVERLAY_PLACEMENTS","getAnchoredOverlayPosition","OverlayContainer","OverlayInsetsProvider","OverlayStackProvider","useAnchorPosition","useAnchoredOverlay","useDismissOverlay","useEscapeKey","useOverlayStackRegistration","useOverlayPosition","FormControlContext","useFormControlContext","dataAttributes","mergeDataAttributes","domDataAttributes","mergeDomDataAttributes","mapViewPropsToDom","assignRef","createPortalFn","useHasTextAncestor","Slot"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,SACEA,qBAAqB,EACrBC,4BAA4B,EAC5BC,kBAAkB,EAElBC,0BAA0B,EAC1BC,gBAAgB,EAChBC,qBAAqB,EACrBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,YAAY,EACZC,2BAA2B,EAC3BC,kBAAkB,QAmBb,WAAW;AAClB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,WAAW;AAEzB,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,eAAe;AACzE,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,wBAAwB;AAC5E,SACEC,iBAAiB,EACjBC,sBAAsB,QAEjB,2BAA2B;AAClC,SAASC,iBAAiB,QAAuC,2BAA2B;AAC5F,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,IAAI,QAAQ,QAAQ","ignoreList":[]}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, useLayoutEffect } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
+
import { getTextContent } from '@cdx-ui/utils';
|
|
5
6
|
import { Slot } from '../slot';
|
|
6
7
|
import { useSelectContext } from './context';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
function getTextContent(node) {
|
|
9
|
-
return Children.toArray(node).map(child => {
|
|
10
|
-
if (typeof child === 'string' || typeof child === 'number') {
|
|
11
|
-
return String(child);
|
|
12
|
-
}
|
|
13
|
-
if (/*#__PURE__*/isValidElement(child)) {
|
|
14
|
-
return getTextContent(child.props.children);
|
|
15
|
-
}
|
|
16
|
-
return '';
|
|
17
|
-
}).join('');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
9
|
/**
|
|
21
10
|
* Renders only when no option matches. Its text is also what the search live region
|
|
22
11
|
* announces in that case.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["forwardRef","useLayoutEffect","View","getTextContent","Slot","useSelectContext","jsx","_jsx","SelectEmpty","asChild","children","props","ref","visibleItems","setEmptyText","text","undefined","length","Comp","displayName"],"sourceRoot":"../../../src","sources":["select/SelectEmpty.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,eAAe,QAA2B,OAAO;AACtE,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,gBAAgB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ7C;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,gBAAGR,UAAU,CACnC,CAAC;EAAES,OAAO;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACxC,MAAM;IAAEC,YAAY;IAAEC;EAAa,CAAC,GAAGT,gBAAgB,CAAC,CAAC;EACzD,MAAMU,IAAI,GAAGZ,cAAc,CAACO,QAAQ,CAAC;EAErCT,eAAe,CAAC,MAAM;IACpBa,YAAY,CAACC,IAAI,IAAIC,SAAS,CAAC;IAC/B,OAAO,MAAMF,YAAY,CAACE,SAAS,CAAC;EACtC,CAAC,EAAE,CAACF,YAAY,EAAEC,IAAI,CAAC,CAAC;EAExB,IAAIF,YAAY,CAACI,MAAM,GAAG,CAAC,EAAE;IAC3B,OAAO,IAAI;EACb;EAEA,MAAMC,IAAI,GAAGT,OAAO,GAAGL,IAAI,GAAGF,IAAI;EAElC,oBACEK,IAAA,CAACW,IAAI;IAACN,GAAG,EAAEA,GAAI;IAAA,GAAKD,KAAK;IAAAD,QAAA,EACtBA;EAAQ,CACL,CAAC;AAEX,CACF,CAAC;AAEDF,WAAW,CAACW,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -36,6 +36,11 @@ export function useWebSliderDrag({
|
|
|
36
36
|
const lastRatioRef = useRef(0);
|
|
37
37
|
const dragContextRef = useRef(null);
|
|
38
38
|
const cleanupRef = useRef(null);
|
|
39
|
+
// Window listeners outlive their render; stale setters would compare against the drag-start value.
|
|
40
|
+
const setValueFromRatioRef = useRef(setValueFromRatio);
|
|
41
|
+
const setIsDraggingRef = useRef(setIsDragging);
|
|
42
|
+
setValueFromRatioRef.current = setValueFromRatio;
|
|
43
|
+
setIsDraggingRef.current = setIsDragging;
|
|
39
44
|
useEffect(() => {
|
|
40
45
|
return () => {
|
|
41
46
|
cleanupRef.current?.();
|
|
@@ -48,9 +53,9 @@ export function useWebSliderDrag({
|
|
|
48
53
|
}
|
|
49
54
|
draggingRef.current = false;
|
|
50
55
|
dragContextRef.current = null;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [
|
|
56
|
+
setValueFromRatioRef.current(lastRatioRef.current, true);
|
|
57
|
+
setIsDraggingRef.current(false);
|
|
58
|
+
}, []);
|
|
54
59
|
const startDrag = useCallback((pageX, pageY, anchorRatio, trackLayoutOverride) => {
|
|
55
60
|
if (isDisabled || Platform.OS !== 'web' || typeof window === 'undefined') {
|
|
56
61
|
return;
|
|
@@ -87,7 +92,7 @@ export function useWebSliderDrag({
|
|
|
87
92
|
const deltaAlongTrack = orientation === 'horizontal' ? delta : -delta;
|
|
88
93
|
const nextRatio = clamp(dragContextRef.current.startRatio + deltaAlongTrack / dragContextRef.current.travel, 0, 1);
|
|
89
94
|
lastRatioRef.current = nextRatio;
|
|
90
|
-
|
|
95
|
+
setValueFromRatioRef.current(nextRatio);
|
|
91
96
|
};
|
|
92
97
|
const onUp = () => {
|
|
93
98
|
cleanupRef.current = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useRef","Platform","clamp","getThumbTravel","pointerCoordToRatio","pointerCoordToVerticalRatio","getPointerCoords","nativeEvent","OS","clientX","clientY","x","y","pageX","pageY","getRatioFromPagePoint","trackLayout","orientation","thumbSize","width","height","useWebSliderDrag","isDisabled","setIsDragging","setValueFromRatio","draggingRef","lastRatioRef","dragContextRef","cleanupRef","current","endDrag","startDrag","anchorRatio","trackLayoutOverride","window","layout","trackSize","travel","startPointer","startRatio","onMove","event","preventDefault","pointer","delta","deltaAlongTrack","nextRatio","onUp","removeEventListener","addEventListener"],"sourceRoot":"../../../src","sources":["slider/useSliderPointer.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACtD,SAASC,QAAQ,QAAQ,cAAc;AAGvC,SAASC,KAAK,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,2BAA2B,QAAQ,SAAS;AAEjG,OAAO,SAASC,gBAAgBA,CAACC,WAKhC,EAA4B;EAC3B,IAAIN,QAAQ,CAACO,EAAE,KAAK,KAAK,IAAID,WAAW,CAACE,OAAO,IAAI,IAAI,IAAIF,WAAW,CAACG,OAAO,IAAI,IAAI,EAAE;IACvF,OAAO;MAAEC,CAAC,EAAEJ,WAAW,CAACE,OAAO;MAAEG,CAAC,EAAEL,WAAW,CAACG;IAAQ,CAAC;EAC3D;EAEA,OAAO;IACLC,CAAC,EAAEJ,WAAW,CAACM,KAAK,IAAI,CAAC;IACzBD,CAAC,EAAEL,WAAW,CAACO,KAAK,IAAI;EAC1B,CAAC;AACH;AAEA,OAAO,SAASC,qBAAqBA,CACnCF,KAAa,EACbC,KAAa,EACbE,WAAqC,EACrCC,WAA8B,EAC9BC,SAAiB,EACT;EACR,IAAI,CAACF,WAAW,EAAE;IAChB,OAAO,CAAC;EACV;EAEA,IAAIC,WAAW,KAAK,YAAY,EAAE;IAChC,OAAOb,mBAAmB,CAACS,KAAK,EAAEG,WAAW,CAACL,CAAC,EAAEK,WAAW,CAACG,KAAK,EAAED,SAAS,CAAC;EAChF;EAEA,OAAOb,2BAA2B,CAACS,KAAK,EAAEE,WAAW,CAACJ,CAAC,EAAEI,WAAW,CAACI,MAAM,EAAEF,SAAS,CAAC;AACzF;AAQA,OAAO,SAASG,gBAAgBA,CAAC;EAC/BC,UAAU;EACVC,aAAa;EACbC,iBAAiB;EACjBR,WAAW;EACXC,WAAW;EACXC;AAQF,CAAC,EAAE;EACD,MAAMO,WAAW,GAAGzB,MAAM,CAAC,KAAK,CAAC;EACjC,MAAM0B,YAAY,GAAG1B,MAAM,CAAC,CAAC,CAAC;EAC9B,MAAM2B,cAAc,GAAG3B,MAAM,CAAwB,IAAI,CAAC;EAC1D,MAAM4B,UAAU,GAAG5B,MAAM,CAAsB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","Platform","clamp","getThumbTravel","pointerCoordToRatio","pointerCoordToVerticalRatio","getPointerCoords","nativeEvent","OS","clientX","clientY","x","y","pageX","pageY","getRatioFromPagePoint","trackLayout","orientation","thumbSize","width","height","useWebSliderDrag","isDisabled","setIsDragging","setValueFromRatio","draggingRef","lastRatioRef","dragContextRef","cleanupRef","setValueFromRatioRef","setIsDraggingRef","current","endDrag","startDrag","anchorRatio","trackLayoutOverride","window","layout","trackSize","travel","startPointer","startRatio","onMove","event","preventDefault","pointer","delta","deltaAlongTrack","nextRatio","onUp","removeEventListener","addEventListener"],"sourceRoot":"../../../src","sources":["slider/useSliderPointer.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACtD,SAASC,QAAQ,QAAQ,cAAc;AAGvC,SAASC,KAAK,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,2BAA2B,QAAQ,SAAS;AAEjG,OAAO,SAASC,gBAAgBA,CAACC,WAKhC,EAA4B;EAC3B,IAAIN,QAAQ,CAACO,EAAE,KAAK,KAAK,IAAID,WAAW,CAACE,OAAO,IAAI,IAAI,IAAIF,WAAW,CAACG,OAAO,IAAI,IAAI,EAAE;IACvF,OAAO;MAAEC,CAAC,EAAEJ,WAAW,CAACE,OAAO;M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,CAAC;IAC9CN,MAAM,CAACe,gBAAgB,CAAC,WAAW,EAAEF,IAAI,CAAC;IAC1Cb,MAAM,CAACe,gBAAgB,CAAC,eAAe,EAAEF,IAAI,CAAC;IAE9CrB,UAAU,CAACG,OAAO,GAAG,MAAM;MACzBK,MAAM,CAACc,mBAAmB,CAAC,aAAa,EAAER,MAAM,CAAC;MACjDN,MAAM,CAACc,mBAAmB,CAAC,WAAW,EAAED,IAAI,CAAC;MAC7Cb,MAAM,CAACc,mBAAmB,CAAC,eAAe,EAAED,IAAI,CAAC;IACnD,CAAC;EACH,CAAC,EACD,CAACjB,OAAO,EAAEV,UAAU,EAAEL,WAAW,EAAEM,aAAa,EAAEC,iBAAiB,EAAEN,SAAS,EAAEF,WAAW,CAC7F,CAAC;EAED,OAAO;IAAEiB;EAAU,CAAC;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cloneElement, forwardRef, isValidElement, useCallback, useMemo } from 'react';
|
|
4
|
+
import { Platform, View } from 'react-native';
|
|
5
|
+
import { flattenChildren, useControllableState } from '@cdx-ui/utils';
|
|
6
|
+
import { Slot } from '../slot';
|
|
7
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
8
|
+
import { StepperIndexProvider, StepperProvider } from './context';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
function toAnnouncedPercent(progress) {
|
|
11
|
+
return Math.min(99, Math.max(1, Math.round(progress)));
|
|
12
|
+
}
|
|
13
|
+
function defaultGetStepAccessibilityText({
|
|
14
|
+
isCurrent,
|
|
15
|
+
isComplete,
|
|
16
|
+
hasProgress,
|
|
17
|
+
progress
|
|
18
|
+
}) {
|
|
19
|
+
const parts = [];
|
|
20
|
+
if (isCurrent) {
|
|
21
|
+
parts.push('current step');
|
|
22
|
+
}
|
|
23
|
+
if (isComplete) {
|
|
24
|
+
parts.push('completed');
|
|
25
|
+
} else if (hasProgress) {
|
|
26
|
+
parts.push(`${String(toAnnouncedPercent(progress))}% complete`);
|
|
27
|
+
} else if (!isCurrent) {
|
|
28
|
+
parts.push('incomplete');
|
|
29
|
+
}
|
|
30
|
+
return parts.join(', ');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Every direct element child is a step; fragments are unwrapped and `false`/`null` are
|
|
35
|
+
* dropped, so conditional steps renumber on the same render.
|
|
36
|
+
*/
|
|
37
|
+
function indexSteps(children) {
|
|
38
|
+
let count = 0;
|
|
39
|
+
const steps = flattenChildren(children).map(child => {
|
|
40
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
41
|
+
return child;
|
|
42
|
+
}
|
|
43
|
+
const index = count;
|
|
44
|
+
count += 1;
|
|
45
|
+
return /*#__PURE__*/_jsx(StepperIndexProvider, {
|
|
46
|
+
value: index,
|
|
47
|
+
children: child
|
|
48
|
+
}, child.key);
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
steps,
|
|
52
|
+
count
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export const StepperRoot = /*#__PURE__*/forwardRef(({
|
|
56
|
+
asChild,
|
|
57
|
+
children,
|
|
58
|
+
currentStep: currentStepProp,
|
|
59
|
+
defaultStep = 0,
|
|
60
|
+
onStepChange,
|
|
61
|
+
isLinear = true,
|
|
62
|
+
orientation = 'vertical',
|
|
63
|
+
labelPlacement = 'end',
|
|
64
|
+
getStepAccessibilityText = defaultGetStepAccessibilityText,
|
|
65
|
+
accessibilityLabel = 'Progress',
|
|
66
|
+
role = 'list',
|
|
67
|
+
...props
|
|
68
|
+
}, ref) => {
|
|
69
|
+
const [currentStepValue, setCurrentStepValue] = useControllableState({
|
|
70
|
+
prop: currentStepProp,
|
|
71
|
+
defaultProp: defaultStep,
|
|
72
|
+
onChange: onStepChange
|
|
73
|
+
});
|
|
74
|
+
const currentStep = currentStepValue ?? defaultStep;
|
|
75
|
+
const setCurrentStep = useCallback(index => {
|
|
76
|
+
setCurrentStepValue(index);
|
|
77
|
+
}, [setCurrentStepValue]);
|
|
78
|
+
const asChildElement = asChild && /*#__PURE__*/isValidElement(children) ? children : null;
|
|
79
|
+
const {
|
|
80
|
+
steps,
|
|
81
|
+
count
|
|
82
|
+
} = indexSteps(asChildElement ? asChildElement.props.children : children);
|
|
83
|
+
const contextValue = useMemo(() => ({
|
|
84
|
+
currentStep,
|
|
85
|
+
count,
|
|
86
|
+
orientation,
|
|
87
|
+
labelPlacement,
|
|
88
|
+
isLinear,
|
|
89
|
+
hasStepChangeHandler: onStepChange !== undefined,
|
|
90
|
+
setCurrentStep,
|
|
91
|
+
getStepAccessibilityText
|
|
92
|
+
}), [currentStep, count, orientation, labelPlacement, isLinear, onStepChange, setCurrentStep, getStepAccessibilityText]);
|
|
93
|
+
const a11yProps = Platform.OS === 'web' ? {
|
|
94
|
+
'aria-label': accessibilityLabel
|
|
95
|
+
} : {
|
|
96
|
+
accessibilityLabel
|
|
97
|
+
};
|
|
98
|
+
const Comp = asChild ? Slot : View;
|
|
99
|
+
return /*#__PURE__*/_jsx(StepperProvider, {
|
|
100
|
+
value: contextValue,
|
|
101
|
+
children: /*#__PURE__*/_jsx(Comp, {
|
|
102
|
+
ref: ref,
|
|
103
|
+
...props,
|
|
104
|
+
role: role,
|
|
105
|
+
...a11yProps,
|
|
106
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
107
|
+
orientation,
|
|
108
|
+
labelPlacement
|
|
109
|
+
})),
|
|
110
|
+
children: asChildElement ? /*#__PURE__*/cloneElement(asChildElement, undefined, steps) : steps
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
StepperRoot.displayName = 'StepperRoot';
|
|
115
|
+
//# sourceMappingURL=StepperRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cloneElement","forwardRef","isValidElement","useCallback","useMemo","Platform","View","flattenChildren","useControllableState","Slot","dataAttributes","mergeDataAttributes","StepperIndexProvider","StepperProvider","jsx","_jsx","toAnnouncedPercent","progress","Math","min","max","round","defaultGetStepAccessibilityText","isCurrent","isComplete","hasProgress","parts","push","String","join","indexSteps","children","count","steps","map","child","index","value","key","StepperRoot","asChild","currentStep","currentStepProp","defaultStep","onStepChange","isLinear","orientation","labelPlacement","getStepAccessibilityText","accessibilityLabel","role","props","ref","currentStepValue","setCurrentStepValue","prop","defaultProp","onChange","setCurrentStep","asChildElement","contextValue","hasStepChangeHandler","undefined","a11yProps","OS","Comp","displayName"],"sourceRoot":"../../../src","sources":["stepper/StepperRoot.tsx"],"mappings":";;AAAA,SACEA,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,OAAO,QAGF,OAAO;AACd,SAASC,QAAQ,EAAEC,IAAI,QAAQ,cAAc;AAC7C,SAASC,eAAe,EAAEC,oBAAoB,QAAQ,eAAe;AACrE,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC7E,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOlE,SAASC,kBAAkBA,CAACC,QAAgB,EAAU;EACpD,OAAOC,IAAI,CAACC,GAAG,CAAC,EAAE,EAAED,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEF,IAAI,CAACG,KAAK,CAACJ,QAAQ,CAAC,CAAC,CAAC;AACxD;AAEA,SAASK,+BAA+BA,CAAC;EACvCC,SAAS;EACTC,UAAU;EACVC,WAAW;EACXR;AACgB,CAAC,EAAU;EAC3B,MAAMS,KAAe,GAAG,EAAE;EAC1B,IAAIH,SAAS,EAAE;IACbG,KAAK,CAACC,IAAI,CAAC,cAAc,CAAC;EAC5B;EACA,IAAIH,UAAU,EAAE;IACdE,KAAK,CAACC,IAAI,CAAC,WAAW,CAAC;EACzB,CAAC,MAAM,IAAIF,WAAW,EAAE;IACtBC,KAAK,CAACC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AG3D,YAAY,CAAC2D,cAAc,EAAEG,SAAS,EAAE7B,KAAK,CAAC,GAAGA;IAAK,CACpE;EAAC,CACQ,CAAC;AAEtB,CACF,CAAC;AAEDM,WAAW,CAAC2B,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useMemo } from 'react';
|
|
4
|
+
import { Platform, View } from 'react-native';
|
|
5
|
+
import { Slot } from '../slot';
|
|
6
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
7
|
+
import { StepperStepProvider, useStepperContext, useStepperIndex } from './context';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
function clampProgress(progress) {
|
|
10
|
+
return Number.isFinite(progress) ? Math.min(100, Math.max(0, progress)) : 0;
|
|
11
|
+
}
|
|
12
|
+
export const StepperStep = /*#__PURE__*/forwardRef(({
|
|
13
|
+
asChild,
|
|
14
|
+
children,
|
|
15
|
+
isComplete: isCompleteProp,
|
|
16
|
+
progress: progressProp = 0,
|
|
17
|
+
isDisabled = false,
|
|
18
|
+
role = 'listitem',
|
|
19
|
+
...props
|
|
20
|
+
}, ref) => {
|
|
21
|
+
const index = useStepperIndex();
|
|
22
|
+
const {
|
|
23
|
+
currentStep,
|
|
24
|
+
count,
|
|
25
|
+
orientation,
|
|
26
|
+
labelPlacement,
|
|
27
|
+
isLinear,
|
|
28
|
+
hasStepChangeHandler
|
|
29
|
+
} = useStepperContext();
|
|
30
|
+
const isCurrent = index === currentStep;
|
|
31
|
+
const isComplete = isCompleteProp ?? index < currentStep;
|
|
32
|
+
const progress = clampProgress(progressProp);
|
|
33
|
+
const hasProgress = progress > 0 && !isComplete;
|
|
34
|
+
// The current step is never a button, so it adds no Tab stop that does nothing.
|
|
35
|
+
const isClickable = hasStepChangeHandler && !isDisabled && !isCurrent && (isComplete || !isLinear);
|
|
36
|
+
const state = useMemo(() => ({
|
|
37
|
+
index,
|
|
38
|
+
count,
|
|
39
|
+
isCurrent,
|
|
40
|
+
isComplete,
|
|
41
|
+
progress,
|
|
42
|
+
hasProgress,
|
|
43
|
+
isLast: index === count - 1,
|
|
44
|
+
isClickable,
|
|
45
|
+
isDisabled,
|
|
46
|
+
orientation,
|
|
47
|
+
labelPlacement
|
|
48
|
+
}), [index, count, isCurrent, isComplete, progress, hasProgress, isClickable, isDisabled, orientation, labelPlacement]);
|
|
49
|
+
const currentProps = Platform.OS === 'web' && isCurrent ? {
|
|
50
|
+
'aria-current': 'step'
|
|
51
|
+
} : {};
|
|
52
|
+
const Comp = asChild ? Slot : View;
|
|
53
|
+
return /*#__PURE__*/_jsx(StepperStepProvider, {
|
|
54
|
+
value: state,
|
|
55
|
+
children: /*#__PURE__*/_jsx(Comp, {
|
|
56
|
+
ref: ref,
|
|
57
|
+
...props,
|
|
58
|
+
role: role,
|
|
59
|
+
...currentProps,
|
|
60
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
61
|
+
orientation,
|
|
62
|
+
labelPlacement,
|
|
63
|
+
current: isCurrent,
|
|
64
|
+
complete: isComplete,
|
|
65
|
+
progress: hasProgress,
|
|
66
|
+
clickable: isClickable,
|
|
67
|
+
disabled: isDisabled
|
|
68
|
+
})),
|
|
69
|
+
children: children
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
StepperStep.displayName = 'StepperStep';
|
|
74
|
+
//# sourceMappingURL=StepperStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useMemo","Platform","View","Slot","dataAttributes","mergeDataAttributes","StepperStepProvider","useStepperContext","useStepperIndex","jsx","_jsx","clampProgress","progress","Number","isFinite","Math","min","max","StepperStep","asChild","children","isComplete","isCompleteProp","progressProp","isDisabled","role","props","ref","index","currentStep","count","orientation","labelPlacement","isLinear","hasStepChangeHandler","isCurrent","hasProgress","isClickable","state","isLast","currentProps","OS","Comp","value","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|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { Pressable } from 'react-native';
|
|
5
|
+
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
6
|
+
import { useFocusRing } from '@react-native-aria/focus';
|
|
7
|
+
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
8
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
9
|
+
import { useStepperContext, useStepperStep } from './context';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Press target for a clickable step: a `button` that is reachable with Tab and activates
|
|
13
|
+
* with Enter or Space. Rendered by `StepperStepTrigger` only while the step is clickable,
|
|
14
|
+
* so display-only steps add no focus stop and no interaction state.
|
|
15
|
+
*/
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
export const StepperStepPressable = /*#__PURE__*/forwardRef(({
|
|
18
|
+
onPress,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) => {
|
|
21
|
+
const {
|
|
22
|
+
index
|
|
23
|
+
} = useStepperStep();
|
|
24
|
+
const {
|
|
25
|
+
setCurrentStep
|
|
26
|
+
} = useStepperContext();
|
|
27
|
+
const {
|
|
28
|
+
isFocusVisible,
|
|
29
|
+
focusProps
|
|
30
|
+
} = useFocusRing();
|
|
31
|
+
const {
|
|
32
|
+
pressProps,
|
|
33
|
+
isPressed
|
|
34
|
+
} = usePress({});
|
|
35
|
+
const {
|
|
36
|
+
isHovered,
|
|
37
|
+
hoverProps
|
|
38
|
+
} = useHover();
|
|
39
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
40
|
+
ref: ref,
|
|
41
|
+
role: "button",
|
|
42
|
+
...props,
|
|
43
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
44
|
+
hover: isHovered,
|
|
45
|
+
active: isPressed,
|
|
46
|
+
focusVisible: isFocusVisible
|
|
47
|
+
})),
|
|
48
|
+
onPress: composeEventHandlers(onPress, () => {
|
|
49
|
+
setCurrentStep(index);
|
|
50
|
+
}),
|
|
51
|
+
onPressIn: composeEventHandlers(props.onPressIn, pressProps.onPressIn),
|
|
52
|
+
onPressOut: composeEventHandlers(props.onPressOut, pressProps.onPressOut),
|
|
53
|
+
onHoverIn: composeEventHandlers(props.onHoverIn, hoverProps.onHoverIn),
|
|
54
|
+
onHoverOut: composeEventHandlers(props.onHoverOut, hoverProps.onHoverOut),
|
|
55
|
+
onFocus: composeEventHandlers(props.onFocus, focusProps.onFocus),
|
|
56
|
+
onBlur: composeEventHandlers(props.onBlur, focusProps.onBlur)
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
StepperStepPressable.displayName = 'StepperStepPressable';
|
|
60
|
+
//# sourceMappingURL=StepperStepPressable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","Pressable","composeEventHandlers","useFocusRing","useHover","usePress","dataAttributes","mergeDataAttributes","useStepperContext","useStepperStep","jsx","_jsx","StepperStepPressable","onPress","props","ref","index","setCurrentStep","isFocusVisible","focusProps","pressProps","isPressed","isHovered","hoverProps","role","hover","active","focusVisible","onPressIn","onPressOut","onHoverIn","onHoverOut","onFocus","onBlur","displayName"],"sourceRoot":"../../../src","sources":["stepper/StepperStepPressable.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAA2B,OAAO;AACrD,SAASC,SAAS,QAAyD,cAAc;AACzF,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,iCAAiC;AACpE,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC7E,SAASC,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;;AAE7D;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,OAAO,MAAMC,oBAAoB,gBAAGZ,UAAU,CAC5C,CAAC;EAAEa,OAAO;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG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/D,CAAC;AAEN,CACF,CAAC;AAEDrB,oBAAoB,CAACsB,WAAW,GAAG,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
6
|
+
import { useStepperContext, useStepperStep } from './context';
|
|
7
|
+
import { StepperStepPressable } from './StepperStepPressable';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* Internal step region that carries the step's accessible name: the grouped visible
|
|
11
|
+
* content (indicator, title, description) followed by the state phrase. It becomes a
|
|
12
|
+
* `button` while the step is clickable. Not a public styled part; the styled
|
|
13
|
+
* `Stepper.Step` renders it around those slots.
|
|
14
|
+
*/
|
|
15
|
+
export const StepperStepTrigger = /*#__PURE__*/forwardRef(({
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const state = useStepperStep();
|
|
20
|
+
const {
|
|
21
|
+
getStepAccessibilityText
|
|
22
|
+
} = useStepperContext();
|
|
23
|
+
const phrase = getStepAccessibilityText(state);
|
|
24
|
+
const Comp = state.isClickable ? StepperStepPressable : View;
|
|
25
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
26
|
+
ref: ref,
|
|
27
|
+
accessible: true,
|
|
28
|
+
accessibilityValue: phrase ? {
|
|
29
|
+
text: phrase
|
|
30
|
+
} : undefined,
|
|
31
|
+
...props,
|
|
32
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
33
|
+
clickable: state.isClickable,
|
|
34
|
+
disabled: state.isDisabled
|
|
35
|
+
})),
|
|
36
|
+
children: children
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
StepperStepTrigger.displayName = 'StepperStepTrigger';
|
|
40
|
+
//# sourceMappingURL=StepperStepTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","View","dataAttributes","mergeDataAttributes","useStepperContext","useStepperStep","StepperStepPressable","jsx","_jsx","StepperStepTrigger","children","props","ref","state","getStepAccessibilityText","phrase","Comp","isClickable","accessible","accessibilityValue","text","undefined","clickable","disabled","isDisabled","displayName"],"sourceRoot":"../../../src","sources":["stepper/StepperStepTrigger.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAA2B,OAAO;AACrD,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC7E,SAASC,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAC7D,SAASC,oBAAoB,QAAQ,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG9D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,gBAAGT,UAAU,CAC1C,CAAC;EAAEU,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC/B,MAAMC,KAAK,GAAGR,cAAc,CAAC,CAAC;EAC9B,MAAM;IAAES;EAAyB,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EACxD,MAAMW,MAAM,GAAGD,wBAAwB,CAACD,KAAK,CAAC;EAC9C,MAAMG,IAAI,GAAGH,KAAK,CAACI,WAAW,GAAGX,oBAAoB,GAAGL,IAAI;EAE5D,oBACEO,IAAA,CAACQ,IAAI;IACHJ,GAAG,EAAEA,GAAI;IACTM,UAAU;IACVC,kBAAkB,EAAEJ,MAAM,GAAG;MAAEK,IAAI,EAAEL;IAAO,CAAC,GAAGM,SAAU;IAAA,GACtDV,KAAK;IAAA,GACLR,mBAAmB,CACrBQ,KAAK,EACLT,cAAc,CAAC;MAAEoB,SAAS,EAAET,KAAK,CAACI,WAAW;MAAEM,QAAQ,EAAEV,KAAK,CAACW;IAAW,CAAC,CAC7E,CAAC;IAAAd,QAAA,EAEAA;EAAQ,CACL,CAAC;AAEX,CACF,CAAC;AAEDD,kBAAkB,CAACgB,WAAW,GAAG,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useLayoutEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
6
|
+
import { composeEventHandlers, mergeRefs } from '@cdx-ui/utils';
|
|
7
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
8
|
+
import { useStepperContext, useStepperStep } from './context';
|
|
9
|
+
import { StepperStepPressable } from './StepperStepPressable';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Internal step region that carries the step's accessible name. On web the state phrase
|
|
13
|
+
* is screen-reader-only text after the visible content, because browse-mode screen
|
|
14
|
+
* readers ignore `aria-label` on a list item. It becomes a `button` while the step is
|
|
15
|
+
* clickable. Not a public styled part.
|
|
16
|
+
*/
|
|
17
|
+
export const StepperStepTrigger = /*#__PURE__*/forwardRef(({
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) => {
|
|
21
|
+
const state = useStepperStep();
|
|
22
|
+
const {
|
|
23
|
+
getStepAccessibilityText
|
|
24
|
+
} = useStepperContext();
|
|
25
|
+
const phrase = getStepAccessibilityText(state);
|
|
26
|
+
const Comp = state.isClickable ? StepperStepPressable : View;
|
|
27
|
+
const nodeRef = useRef(null);
|
|
28
|
+
const mergedRef = useMemo(() => mergeRefs(ref, nodeRef), [ref]);
|
|
29
|
+
// Activating a step makes it current, which swaps the focused button for a plain region
|
|
30
|
+
// and would drop focus to the document. Focus moves to that region instead, outside the
|
|
31
|
+
// Tab order.
|
|
32
|
+
const restoreFocusRef = useRef(false);
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
const node = nodeRef.current;
|
|
35
|
+
if (!restoreFocusRef.current || state.isClickable || node === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
restoreFocusRef.current = false;
|
|
39
|
+
node.tabIndex = -1;
|
|
40
|
+
node.focus({
|
|
41
|
+
preventScroll: true
|
|
42
|
+
});
|
|
43
|
+
}, [state.isClickable]);
|
|
44
|
+
const pressProps = state.isClickable ? {
|
|
45
|
+
onPress: () => {
|
|
46
|
+
restoreFocusRef.current = document.activeElement === nodeRef.current;
|
|
47
|
+
},
|
|
48
|
+
onBlur: composeEventHandlers(props.onBlur, () => {
|
|
49
|
+
restoreFocusRef.current = false;
|
|
50
|
+
})
|
|
51
|
+
} : {};
|
|
52
|
+
return /*#__PURE__*/_jsxs(Comp, {
|
|
53
|
+
ref: mergedRef,
|
|
54
|
+
...props,
|
|
55
|
+
...pressProps,
|
|
56
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
57
|
+
clickable: state.isClickable,
|
|
58
|
+
disabled: state.isDisabled
|
|
59
|
+
})),
|
|
60
|
+
children: [children, phrase ? /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
61
|
+
elementType: "span",
|
|
62
|
+
children: `, ${phrase}`
|
|
63
|
+
}) : null]
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
StepperStepTrigger.displayName = 'StepperStepTrigger';
|
|
67
|
+
//# sourceMappingURL=StepperStepTrigger.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useLayoutEffect","useMemo","useRef","View","VisuallyHidden","composeEventHandlers","mergeRefs","dataAttributes","mergeDataAttributes","useStepperContext","useStepperStep","StepperStepPressable","jsx","_jsx","jsxs","_jsxs","StepperStepTrigger","children","props","ref","state","getStepAccessibilityText","phrase","Comp","isClickable","nodeRef","mergedRef","restoreFocusRef","node","current","tabIndex","focus","preventScroll","pressProps","onPress","document","activeElement","onBlur","clickable","disabled","isDisabled","elementType","displayName"],"sourceRoot":"../../../src","sources":["stepper/StepperStep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AAK;IAC/BD,IAAI,CAACE,QAAQ,GAAG,CAAC,CAAC;IAClBF,IAAI,CAACG,KAAK,CAAC;MAAEC,aAAa,EAAE;IAAK,CAAC,CAAC;EACrC,CAAC,EAAE,CAACZ,KAAK,CAACI,WAAW,CAAC,CAAC;EAEvB,MAAMS,UAAU,GAAGb,KAAK,CAACI,WAAW,GAChC;IACEU,OAAO,EAAEA,CAAA,KAAM;MACbP,eAAe,CAACE,OAAO,GACrBM,QAAQ,CAACC,aAAa,KAAMX,OAAO,CAACI,OAAyC;IACjF,CAAC;IACDQ,MAAM,EAAEhC,oBAAoB,CAACa,KAAK,CAACmB,MAAM,EAAE,MAAM;MAC/CV,eAAe,CAACE,OAAO,GAAG,KAAK;IACjC,CAAC;EACH,CAAC,GACD,CAAC,CAAC;EAEN,oBACEd,KAAA,CAACQ,IAAI;IACHJ,GAAG,EAAEO,SAAU;IAAA,GACXR,KAAK;IAAA,GACLe,UAAU;IAAA,GACVzB,mBAAmB,CACrBU,KAAK,EACLX,cAAc,CAAC;MAAE+B,SAAS,EAAElB,KAAK,CAACI,WAAW;MAAEe,QAAQ,EAAEnB,KAAK,CAACoB;IAAW,CAAC,CAC7E,CAAC;IAAAvB,QAAA,GAEAA,QAAQ,EACRK,MAAM,gBAAGT,IAAA,CAACT,cAAc;MAACqC,WAAW,EAAC,MAAM;MAAAxB,QAAA,EAAE,KAAKK,MAAM;IAAE,CAAiB,CAAC,GAAG,IAAI;EAAA,CAChF,CAAC;AAEX,CACF,CAAC;AAEDN,kBAAkB,CAAC0B,WAAW,GAAG,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext } from '@cdx-ui/utils';
|
|
4
|
+
export const [StepperProvider, useStepperContext] = createContext('StepperContext');
|
|
5
|
+
|
|
6
|
+
/** Position of a direct child of `StepperRoot`, supplied by the root while it renders. */
|
|
7
|
+
export const [StepperIndexProvider, useStepperIndex] = createContext('StepperIndex');
|
|
8
|
+
|
|
9
|
+
/** Resolved state of the enclosing step. `useStepperStep` throws outside a `StepperStep`. */
|
|
10
|
+
export const [StepperStepProvider, useStepperStep] = createContext('StepperStep');
|
|
11
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","StepperProvider","useStepperContext","StepperIndexProvider","useStepperIndex","StepperStepProvider","useStepperStep"],"sourceRoot":"../../../src","sources":["stepper/context.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,eAAe;AAG7C,OAAO,MAAM,CAACC,eAAe,EAAEC,iBAAiB,CAAC,GAC/CF,aAAa,CAAsB,gBAAgB,CAAC;;AAEtD;AACA,OAAO,MAAM,CAACG,oBAAoB,EAAEC,eAAe,CAAC,GAAGJ,aAAa,CAAS,cAAc,CAAC;;AAE5F;AACA,OAAO,MAAM,CAACK,mBAAmB,EAAEC,cAAc,CAAC,GAAGN,aAAa,CAAmB,aAAa,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { useStepperContext, useStepperIndex, useStepperStep } from './context';
|
|
4
|
+
export { StepperRoot } from './StepperRoot';
|
|
5
|
+
export { StepperStep } from './StepperStep';
|
|
6
|
+
export { StepperStepTrigger } from './StepperStepTrigger';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useStepperContext","useStepperIndex","useStepperStep","StepperRoot","StepperStep","StepperStepTrigger"],"sourceRoot":"../../../src","sources":["stepper/index.ts"],"mappings":";;AAYA,SAASA,iBAAiB,EAAEC,eAAe,EAAEC,cAAc,QAAQ,WAAW;AAC9E,SAASC,WAAW,QAA+B,eAAe;AAClE,SAASC,WAAW,QAA+B,eAAe;AAClE,SAASC,kBAAkB,QAAQ,sBAAsB","ignoreList":[]}
|