@cdx-ui/primitives 0.3.5 → 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.
Files changed (76) hide show
  1. package/lib/commonjs/index.js +12 -0
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/select/SelectEmpty.js +2 -13
  4. package/lib/commonjs/select/SelectEmpty.js.map +1 -1
  5. package/lib/commonjs/slider/useSliderPointer.js +9 -4
  6. package/lib/commonjs/slider/useSliderPointer.js.map +1 -1
  7. package/lib/commonjs/stepper/StepperRoot.js +119 -0
  8. package/lib/commonjs/stepper/StepperRoot.js.map +1 -0
  9. package/lib/commonjs/stepper/StepperStep.js +78 -0
  10. package/lib/commonjs/stepper/StepperStep.js.map +1 -0
  11. package/lib/commonjs/stepper/StepperStepPressable.js +63 -0
  12. package/lib/commonjs/stepper/StepperStepPressable.js.map +1 -0
  13. package/lib/commonjs/stepper/StepperStepTrigger.js +44 -0
  14. package/lib/commonjs/stepper/StepperStepTrigger.js.map +1 -0
  15. package/lib/commonjs/stepper/StepperStepTrigger.web.js +71 -0
  16. package/lib/commonjs/stepper/StepperStepTrigger.web.js.map +1 -0
  17. package/lib/commonjs/stepper/context.js +21 -0
  18. package/lib/commonjs/stepper/context.js.map +1 -0
  19. package/lib/commonjs/stepper/index.js +46 -0
  20. package/lib/commonjs/stepper/index.js.map +1 -0
  21. package/lib/commonjs/stepper/types.js +6 -0
  22. package/lib/commonjs/stepper/types.js.map +1 -0
  23. package/lib/module/index.js +1 -0
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/select/SelectEmpty.js +2 -13
  26. package/lib/module/select/SelectEmpty.js.map +1 -1
  27. package/lib/module/slider/useSliderPointer.js +9 -4
  28. package/lib/module/slider/useSliderPointer.js.map +1 -1
  29. package/lib/module/stepper/StepperRoot.js +115 -0
  30. package/lib/module/stepper/StepperRoot.js.map +1 -0
  31. package/lib/module/stepper/StepperStep.js +74 -0
  32. package/lib/module/stepper/StepperStep.js.map +1 -0
  33. package/lib/module/stepper/StepperStepPressable.js +60 -0
  34. package/lib/module/stepper/StepperStepPressable.js.map +1 -0
  35. package/lib/module/stepper/StepperStepTrigger.js +40 -0
  36. package/lib/module/stepper/StepperStepTrigger.js.map +1 -0
  37. package/lib/module/stepper/StepperStepTrigger.web.js +67 -0
  38. package/lib/module/stepper/StepperStepTrigger.web.js.map +1 -0
  39. package/lib/module/stepper/context.js +11 -0
  40. package/lib/module/stepper/context.js.map +1 -0
  41. package/lib/module/stepper/index.js +7 -0
  42. package/lib/module/stepper/index.js.map +1 -0
  43. package/lib/module/stepper/types.js +4 -0
  44. package/lib/module/stepper/types.js.map +1 -0
  45. package/lib/typescript/index.d.ts +1 -0
  46. package/lib/typescript/index.d.ts.map +1 -1
  47. package/lib/typescript/select/SelectEmpty.d.ts.map +1 -1
  48. package/lib/typescript/slider/useSliderPointer.d.ts.map +1 -1
  49. package/lib/typescript/stepper/StepperRoot.d.ts +7 -0
  50. package/lib/typescript/stepper/StepperRoot.d.ts.map +1 -0
  51. package/lib/typescript/stepper/StepperStep.d.ts +7 -0
  52. package/lib/typescript/stepper/StepperStep.d.ts.map +1 -0
  53. package/lib/typescript/stepper/StepperStepPressable.d.ts +8 -0
  54. package/lib/typescript/stepper/StepperStepPressable.d.ts.map +1 -0
  55. package/lib/typescript/stepper/StepperStepTrigger.d.ts +9 -0
  56. package/lib/typescript/stepper/StepperStepTrigger.d.ts.map +1 -0
  57. package/lib/typescript/stepper/StepperStepTrigger.web.d.ts +9 -0
  58. package/lib/typescript/stepper/StepperStepTrigger.web.d.ts.map +1 -0
  59. package/lib/typescript/stepper/context.d.ts +16 -0
  60. package/lib/typescript/stepper/context.d.ts.map +1 -0
  61. package/lib/typescript/stepper/index.d.ts +6 -0
  62. package/lib/typescript/stepper/index.d.ts.map +1 -0
  63. package/lib/typescript/stepper/types.d.ts +96 -0
  64. package/lib/typescript/stepper/types.d.ts.map +1 -0
  65. package/package.json +3 -3
  66. package/src/index.ts +1 -0
  67. package/src/select/SelectEmpty.tsx +2 -22
  68. package/src/slider/useSliderPointer.ts +9 -4
  69. package/src/stepper/StepperRoot.tsx +148 -0
  70. package/src/stepper/StepperStep.tsx +101 -0
  71. package/src/stepper/StepperStepPressable.tsx +48 -0
  72. package/src/stepper/StepperStepTrigger.tsx +38 -0
  73. package/src/stepper/StepperStepTrigger.web.tsx +69 -0
  74. package/src/stepper/context.tsx +11 -0
  75. package/src/stepper/index.ts +16 -0
  76. package/src/stepper/types.ts +104 -0
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["stepper/types.ts"],"mappings":"","ignoreList":[]}
@@ -43,6 +43,7 @@ export * from './progress-bar';
43
43
  export * from './radio';
44
44
  export * from './accordion';
45
45
  export * from './slider';
46
+ export * from './stepper';
46
47
  export type { InteractionState } from './types';
47
48
  export { FormControlContext, useFormControlContext } from '@cdx-ui/utils';
48
49
  export { dataAttributes, mergeDataAttributes } from './utils/dataAttributes';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC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,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectEmpty.d.ts","sourceRoot":"","sources":["../../../src/select/SelectEmpty.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD;;;GAGG;AACH,eAAO,MAAM,WAAW,mGAsBvB,CAAC"}
1
+ {"version":3,"file":"SelectEmpty.d.ts","sourceRoot":"","sources":["../../../src/select/SelectEmpty.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,mGAsBvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useSliderPointer.d.ts","sourceRoot":"","sources":["../../../src/slider/useSliderPointer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAS3B;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,iBAAiB,GAAG,IAAI,EACrC,WAAW,EAAE,iBAAiB,EAC9B,SAAS,EAAE,MAAM,GAChB,MAAM,CAUR;AAQD,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,SAAS,GACV,EAAE;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/D,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;uBAyBY,MAAM,SACN,MAAM,gBACC,MAAM,wBACE,iBAAiB;EAuE5C"}
1
+ {"version":3,"file":"useSliderPointer.d.ts","sourceRoot":"","sources":["../../../src/slider/useSliderPointer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAS3B;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,iBAAiB,GAAG,IAAI,EACrC,WAAW,EAAE,iBAAiB,EAC9B,SAAS,EAAE,MAAM,GAChB,MAAM,CAUR;AAQD,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,SAAS,GACV,EAAE;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/D,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;uBA8BY,MAAM,SACN,MAAM,gBACC,MAAM,wBACE,iBAAiB;EAuE5C"}
@@ -0,0 +1,7 @@
1
+ import { View } from 'react-native';
2
+ import type { IStepperProps } from './types';
3
+ export interface StepperRootProps extends IStepperProps {
4
+ readonly className?: string;
5
+ }
6
+ export declare const StepperRoot: import("react").ForwardRefExoticComponent<StepperRootProps & import("react").RefAttributes<View>>;
7
+ //# sourceMappingURL=StepperRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperRoot.d.ts","sourceRoot":"","sources":["../../../src/stepper/StepperRoot.tsx"],"names":[],"mappings":"AASA,OAAO,EAAY,IAAI,EAAE,MAAM,cAAc,CAAC;AAK9C,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AA+CD,eAAO,MAAM,WAAW,mGAgFvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { View } from 'react-native';
2
+ import type { IStepperStepProps } from './types';
3
+ export interface StepperStepProps extends IStepperStepProps {
4
+ readonly className?: string;
5
+ }
6
+ export declare const StepperStep: import("react").ForwardRefExoticComponent<StepperStepProps & import("react").RefAttributes<View>>;
7
+ //# sourceMappingURL=StepperStep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperStep.d.ts","sourceRoot":"","sources":["../../../src/stepper/StepperStep.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAEnE,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAMD,eAAO,MAAM,WAAW,mGAmFvB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type PressableProps } from 'react-native';
2
+ /**
3
+ * Press target for a clickable step: a `button` that is reachable with Tab and activates
4
+ * with Enter or Space. Rendered by `StepperStepTrigger` only while the step is clickable,
5
+ * so display-only steps add no focus stop and no interaction state.
6
+ */
7
+ export declare const StepperStepPressable: import("react").ForwardRefExoticComponent<PressableProps & import("react").RefAttributes<import("react-native").View>>;
8
+ //# sourceMappingURL=StepperStepPressable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperStepPressable.d.ts","sourceRoot":"","sources":["../../../src/stepper/StepperStepPressable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAyC,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAO1F;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,wHAgChC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { View } from 'react-native';
2
+ /**
3
+ * Internal step region that carries the step's accessible name: the grouped visible
4
+ * content (indicator, title, description) followed by the state phrase. It becomes a
5
+ * `button` while the step is clickable. Not a public styled part; the styled
6
+ * `Stepper.Step` renders it around those slots.
7
+ */
8
+ export declare const StepperStepTrigger: import("react").ForwardRefExoticComponent<import("react-native").ViewProps & import("react").RefAttributes<View>>;
9
+ //# sourceMappingURL=StepperStepTrigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperStepTrigger.d.ts","sourceRoot":"","sources":["../../../src/stepper/StepperStepTrigger.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMpC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,mHAsB9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { View } from 'react-native';
2
+ /**
3
+ * Internal step region that carries the step's accessible name. On web the state phrase
4
+ * is screen-reader-only text after the visible content, because browse-mode screen
5
+ * readers ignore `aria-label` on a list item. It becomes a `button` while the step is
6
+ * clickable. Not a public styled part.
7
+ */
8
+ export declare const StepperStepTrigger: import("react").ForwardRefExoticComponent<import("react-native").ViewProps & import("react").RefAttributes<View>>;
9
+ //# sourceMappingURL=StepperStepTrigger.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperStepTrigger.web.d.ts","sourceRoot":"","sources":["../../../src/stepper/StepperStepTrigger.web.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQpC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,mHAmD9B,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { StepperContextValue, StepperStepState } from './types';
2
+ export declare const StepperProvider: import("react").FunctionComponent<{
3
+ children: import("react").ReactNode;
4
+ value: StepperContextValue;
5
+ }>, useStepperContext: () => StepperContextValue;
6
+ /** Position of a direct child of `StepperRoot`, supplied by the root while it renders. */
7
+ export declare const StepperIndexProvider: import("react").FunctionComponent<{
8
+ children: import("react").ReactNode;
9
+ value: number;
10
+ }>, useStepperIndex: () => number;
11
+ /** Resolved state of the enclosing step. `useStepperStep` throws outside a `StepperStep`. */
12
+ export declare const StepperStepProvider: import("react").FunctionComponent<{
13
+ children: import("react").ReactNode;
14
+ value: StepperStepState;
15
+ }>, useStepperStep: () => StepperStepState;
16
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/stepper/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAErE,eAAO,MAAO,eAAe;;;IAAE,iBAAiB,2BACM,CAAC;AAEvD,0FAA0F;AAC1F,eAAO,MAAO,oBAAoB;;;IAAE,eAAe,cAAyC,CAAC;AAE7F,6FAA6F;AAC7F,eAAO,MAAO,mBAAmB;;;IAAE,cAAc,wBAAkD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type { IStepperProps, IStepperStepProps, IStepperStepTriggerProps, InterfaceStepperProps, InterfaceStepperStepProps, StepperContextValue, StepperLabelPlacement, StepperOrientation, StepperStepState, } from './types';
2
+ export { useStepperContext, useStepperIndex, useStepperStep } from './context';
3
+ export { StepperRoot, type StepperRootProps } from './StepperRoot';
4
+ export { StepperStep, type StepperStepProps } from './StepperStep';
5
+ export { StepperStepTrigger } from './StepperStepTrigger';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stepper/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,96 @@
1
+ import type { ViewProps } from 'react-native';
2
+ export type StepperOrientation = 'horizontal' | 'vertical';
3
+ export type StepperLabelPlacement = 'end' | 'bottom';
4
+ export interface StepperStepState {
5
+ /** Zero-based position among the steps. */
6
+ readonly index: number;
7
+ /** Number of steps rendered. */
8
+ readonly count: number;
9
+ readonly isCurrent: boolean;
10
+ /** Resolved completion: the explicit `isComplete`, or `index < currentStep`. */
11
+ readonly isComplete: boolean;
12
+ /** Clamped to 0–100. Non-finite values are 0. */
13
+ readonly progress: number;
14
+ /** True when the partial ring is drawn: `0 < progress` and not complete. */
15
+ readonly hasProgress: boolean;
16
+ readonly isLast: boolean;
17
+ /** True when the step renders as a button. */
18
+ readonly isClickable: boolean;
19
+ readonly isDisabled: boolean;
20
+ readonly orientation: StepperOrientation;
21
+ readonly labelPlacement: StepperLabelPlacement;
22
+ }
23
+ export interface InterfaceStepperProps extends ViewProps {
24
+ /**
25
+ * Controlled, zero-based current step. A value outside `0…count-1` means no step is
26
+ * current; a value `>= count` makes every step complete by default.
27
+ */
28
+ readonly currentStep?: number;
29
+ /**
30
+ * Uncontrolled starting step. Ignored when `currentStep` is set.
31
+ * @default 0
32
+ */
33
+ readonly defaultStep?: number;
34
+ /** Called with the pressed step's index. Setting it makes eligible steps clickable. */
35
+ readonly onStepChange?: (index: number) => void;
36
+ /**
37
+ * When `true`, only complete steps are clickable. When `false`, every non-current,
38
+ * non-disabled step is.
39
+ * @default true
40
+ */
41
+ readonly isLinear?: boolean;
42
+ /**
43
+ * `'horizontal'` lays the steps out in a row. `labelPlacement` chooses where each label sits.
44
+ * @default 'vertical'
45
+ */
46
+ readonly orientation?: StepperOrientation;
47
+ /**
48
+ * Horizontal only; ignored when `orientation` is `'vertical'`. `'end'` puts each label after
49
+ * its indicator, sizes steps to their labels and stretches the separators between them.
50
+ * `'bottom'` gives every step an equal column with the indicator and label centered.
51
+ * @default 'end'
52
+ */
53
+ readonly labelPlacement?: StepperLabelPlacement;
54
+ /**
55
+ * Returns the state phrase appended to each step's title for assistive technology,
56
+ * replacing the English default (for example `"current step, 40% complete"`).
57
+ */
58
+ readonly getStepAccessibilityText?: (state: StepperStepState) => string;
59
+ /** @default false */
60
+ readonly asChild?: boolean;
61
+ }
62
+ export type IStepperProps = InterfaceStepperProps;
63
+ export interface InterfaceStepperStepProps extends ViewProps {
64
+ /**
65
+ * Whether the step is complete. An explicit value wins in both directions.
66
+ * @default index < currentStep
67
+ */
68
+ readonly isComplete?: boolean;
69
+ /**
70
+ * Partial progress, 0–100. Values outside the range are clamped; non-finite values are `0`.
71
+ * @default 0
72
+ */
73
+ readonly progress?: number;
74
+ /**
75
+ * Only affects clickability. A disabled step still shows its state.
76
+ * @default false
77
+ */
78
+ readonly isDisabled?: boolean;
79
+ /** @default false */
80
+ readonly asChild?: boolean;
81
+ }
82
+ export type IStepperStepProps = InterfaceStepperStepProps;
83
+ export type IStepperStepTriggerProps = ViewProps;
84
+ export interface StepperContextValue {
85
+ /** Resolved current step (controlled or uncontrolled). */
86
+ readonly currentStep: number;
87
+ readonly count: number;
88
+ readonly orientation: StepperOrientation;
89
+ readonly labelPlacement: StepperLabelPlacement;
90
+ readonly isLinear: boolean;
91
+ /** True when the consumer passed `onStepChange`. */
92
+ readonly hasStepChangeHandler: boolean;
93
+ readonly setCurrentStep: (index: number) => void;
94
+ readonly getStepAccessibilityText: (state: StepperStepState) => string;
95
+ }
96
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/stepper/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;CAChD;AAED,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,uFAAuF;IACvF,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,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C;IACjD,QAAQ,CAAC,wBAAwB,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC;CACxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/primitives",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,8 +69,8 @@
69
69
  "@react-stately/disclosure": "3.1.1",
70
70
  "@react-stately/radio": "3.12.0",
71
71
  "@react-stately/toggle": "3.9.4",
72
- "@cdx-ui/formatters": "0.3.5",
73
- "@cdx-ui/utils": "0.3.5"
72
+ "@cdx-ui/formatters": "0.3.6",
73
+ "@cdx-ui/utils": "0.3.6"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/react": "19.2.14",
package/src/index.ts CHANGED
@@ -76,6 +76,7 @@ export * from './progress-bar';
76
76
  export * from './radio';
77
77
  export * from './accordion';
78
78
  export * from './slider';
79
+ export * from './stepper';
79
80
  export type { InteractionState } from './types';
80
81
  export { FormControlContext, useFormControlContext } from '@cdx-ui/utils';
81
82
  export { dataAttributes, mergeDataAttributes } from './utils/dataAttributes';
@@ -1,12 +1,6 @@
1
- import {
2
- Children,
3
- forwardRef,
4
- isValidElement,
5
- useLayoutEffect,
6
- type ComponentRef,
7
- type ReactNode,
8
- } from 'react';
1
+ import { forwardRef, useLayoutEffect, type ComponentRef } from 'react';
9
2
  import { View } from 'react-native';
3
+ import { getTextContent } from '@cdx-ui/utils';
10
4
  import { Slot } from '../slot';
11
5
  import { useSelectContext } from './context';
12
6
  import type { ISelectEmptyProps } from './types';
@@ -16,20 +10,6 @@ export interface SelectEmptyProps extends ISelectEmptyProps {
16
10
  className?: string;
17
11
  }
18
12
 
19
- function getTextContent(node: ReactNode): string {
20
- return Children.toArray(node)
21
- .map((child) => {
22
- if (typeof child === 'string' || typeof child === 'number') {
23
- return String(child);
24
- }
25
- if (isValidElement<{ children?: ReactNode }>(child)) {
26
- return getTextContent(child.props.children);
27
- }
28
- return '';
29
- })
30
- .join('');
31
- }
32
-
33
13
  /**
34
14
  * Renders only when no option matches. Its text is also what the search live region
35
15
  * announces in that case.
@@ -63,6 +63,11 @@ export function useWebSliderDrag({
63
63
  const lastRatioRef = useRef(0);
64
64
  const dragContextRef = useRef<WebDragContext | null>(null);
65
65
  const cleanupRef = useRef<(() => void) | null>(null);
66
+ // Window listeners outlive their render; stale setters would compare against the drag-start value.
67
+ const setValueFromRatioRef = useRef(setValueFromRatio);
68
+ const setIsDraggingRef = useRef(setIsDragging);
69
+ setValueFromRatioRef.current = setValueFromRatio;
70
+ setIsDraggingRef.current = setIsDragging;
66
71
 
67
72
  useEffect(() => {
68
73
  return () => {
@@ -77,9 +82,9 @@ export function useWebSliderDrag({
77
82
  }
78
83
  draggingRef.current = false;
79
84
  dragContextRef.current = null;
80
- setValueFromRatio(lastRatioRef.current, true);
81
- setIsDragging(false);
82
- }, [setIsDragging, setValueFromRatio]);
85
+ setValueFromRatioRef.current(lastRatioRef.current, true);
86
+ setIsDraggingRef.current(false);
87
+ }, []);
83
88
 
84
89
  const startDrag = useCallback(
85
90
  (
@@ -132,7 +137,7 @@ export function useWebSliderDrag({
132
137
  1,
133
138
  );
134
139
  lastRatioRef.current = nextRatio;
135
- setValueFromRatio(nextRatio);
140
+ setValueFromRatioRef.current(nextRatio);
136
141
  };
137
142
 
138
143
  const onUp = () => {
@@ -0,0 +1,148 @@
1
+ import {
2
+ cloneElement,
3
+ forwardRef,
4
+ isValidElement,
5
+ useCallback,
6
+ useMemo,
7
+ type ComponentRef,
8
+ type ReactNode,
9
+ } from 'react';
10
+ import { Platform, View } from 'react-native';
11
+ import { flattenChildren, useControllableState } from '@cdx-ui/utils';
12
+ import { Slot } from '../slot';
13
+ import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
14
+ import { StepperIndexProvider, StepperProvider } from './context';
15
+ import type { IStepperProps, StepperStepState } from './types';
16
+
17
+ export interface StepperRootProps extends IStepperProps {
18
+ readonly className?: string;
19
+ }
20
+
21
+ function toAnnouncedPercent(progress: number): number {
22
+ return Math.min(99, Math.max(1, Math.round(progress)));
23
+ }
24
+
25
+ function defaultGetStepAccessibilityText({
26
+ isCurrent,
27
+ isComplete,
28
+ hasProgress,
29
+ progress,
30
+ }: StepperStepState): string {
31
+ const parts: string[] = [];
32
+ if (isCurrent) {
33
+ parts.push('current step');
34
+ }
35
+ if (isComplete) {
36
+ parts.push('completed');
37
+ } else if (hasProgress) {
38
+ parts.push(`${String(toAnnouncedPercent(progress))}% complete`);
39
+ } else if (!isCurrent) {
40
+ parts.push('incomplete');
41
+ }
42
+ return parts.join(', ');
43
+ }
44
+
45
+ /**
46
+ * Every direct element child is a step; fragments are unwrapped and `false`/`null` are
47
+ * dropped, so conditional steps renumber on the same render.
48
+ */
49
+ function indexSteps(children: ReactNode): { steps: ReactNode[]; count: number } {
50
+ let count = 0;
51
+ const steps = flattenChildren(children).map((child) => {
52
+ if (!isValidElement(child)) {
53
+ return child;
54
+ }
55
+ const index = count;
56
+ count += 1;
57
+ return (
58
+ <StepperIndexProvider key={child.key} value={index}>
59
+ {child}
60
+ </StepperIndexProvider>
61
+ );
62
+ });
63
+ return { steps, count };
64
+ }
65
+
66
+ export const StepperRoot = forwardRef<ComponentRef<typeof View>, StepperRootProps>(
67
+ (
68
+ {
69
+ asChild,
70
+ children,
71
+ currentStep: currentStepProp,
72
+ defaultStep = 0,
73
+ onStepChange,
74
+ isLinear = true,
75
+ orientation = 'vertical',
76
+ labelPlacement = 'end',
77
+ getStepAccessibilityText = defaultGetStepAccessibilityText,
78
+ accessibilityLabel = 'Progress',
79
+ role = 'list',
80
+ ...props
81
+ },
82
+ ref,
83
+ ) => {
84
+ const [currentStepValue, setCurrentStepValue] = useControllableState<number>({
85
+ prop: currentStepProp,
86
+ defaultProp: defaultStep,
87
+ onChange: onStepChange,
88
+ });
89
+ const currentStep = currentStepValue ?? defaultStep;
90
+
91
+ const setCurrentStep = useCallback(
92
+ (index: number) => {
93
+ setCurrentStepValue(index);
94
+ },
95
+ [setCurrentStepValue],
96
+ );
97
+
98
+ const asChildElement =
99
+ asChild && isValidElement<{ children?: ReactNode }>(children) ? children : null;
100
+ const { steps, count } = indexSteps(asChildElement ? asChildElement.props.children : children);
101
+
102
+ const contextValue = useMemo(
103
+ () => ({
104
+ currentStep,
105
+ count,
106
+ orientation,
107
+ labelPlacement,
108
+ isLinear,
109
+ hasStepChangeHandler: onStepChange !== undefined,
110
+ setCurrentStep,
111
+ getStepAccessibilityText,
112
+ }),
113
+ [
114
+ currentStep,
115
+ count,
116
+ orientation,
117
+ labelPlacement,
118
+ isLinear,
119
+ onStepChange,
120
+ setCurrentStep,
121
+ getStepAccessibilityText,
122
+ ],
123
+ );
124
+
125
+ const a11yProps =
126
+ Platform.OS === 'web'
127
+ ? ({ 'aria-label': accessibilityLabel } as const)
128
+ : ({ accessibilityLabel } as const);
129
+
130
+ const Comp = asChild ? Slot : View;
131
+
132
+ return (
133
+ <StepperProvider value={contextValue}>
134
+ <Comp
135
+ ref={ref}
136
+ {...props}
137
+ role={role}
138
+ {...a11yProps}
139
+ {...mergeDataAttributes(props, dataAttributes({ orientation, labelPlacement }))}
140
+ >
141
+ {asChildElement ? cloneElement(asChildElement, undefined, steps) : steps}
142
+ </Comp>
143
+ </StepperProvider>
144
+ );
145
+ },
146
+ );
147
+
148
+ StepperRoot.displayName = 'StepperRoot';
@@ -0,0 +1,101 @@
1
+ import { forwardRef, useMemo, type ComponentRef } from 'react';
2
+ import { Platform, View } from 'react-native';
3
+ import { Slot } from '../slot';
4
+ import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
5
+ import { StepperStepProvider, useStepperContext, useStepperIndex } from './context';
6
+ import type { IStepperStepProps, StepperStepState } from './types';
7
+
8
+ export interface StepperStepProps extends IStepperStepProps {
9
+ readonly className?: string;
10
+ }
11
+
12
+ function clampProgress(progress: number): number {
13
+ return Number.isFinite(progress) ? Math.min(100, Math.max(0, progress)) : 0;
14
+ }
15
+
16
+ export const StepperStep = forwardRef<ComponentRef<typeof View>, StepperStepProps>(
17
+ (
18
+ {
19
+ asChild,
20
+ children,
21
+ isComplete: isCompleteProp,
22
+ progress: progressProp = 0,
23
+ isDisabled = false,
24
+ role = 'listitem',
25
+ ...props
26
+ },
27
+ ref,
28
+ ) => {
29
+ const index = useStepperIndex();
30
+ const { currentStep, count, orientation, labelPlacement, isLinear, hasStepChangeHandler } =
31
+ useStepperContext();
32
+
33
+ const isCurrent = index === currentStep;
34
+ const isComplete = isCompleteProp ?? index < currentStep;
35
+ const progress = clampProgress(progressProp);
36
+ const hasProgress = progress > 0 && !isComplete;
37
+ // The current step is never a button, so it adds no Tab stop that does nothing.
38
+ const isClickable =
39
+ hasStepChangeHandler && !isDisabled && !isCurrent && (isComplete || !isLinear);
40
+
41
+ const state = useMemo(
42
+ (): StepperStepState => ({
43
+ index,
44
+ count,
45
+ isCurrent,
46
+ isComplete,
47
+ progress,
48
+ hasProgress,
49
+ isLast: index === count - 1,
50
+ isClickable,
51
+ isDisabled,
52
+ orientation,
53
+ labelPlacement,
54
+ }),
55
+ [
56
+ index,
57
+ count,
58
+ isCurrent,
59
+ isComplete,
60
+ progress,
61
+ hasProgress,
62
+ isClickable,
63
+ isDisabled,
64
+ orientation,
65
+ labelPlacement,
66
+ ],
67
+ );
68
+
69
+ const currentProps =
70
+ Platform.OS === 'web' && isCurrent ? ({ 'aria-current': 'step' } as const) : {};
71
+
72
+ const Comp = asChild ? Slot : View;
73
+
74
+ return (
75
+ <StepperStepProvider value={state}>
76
+ <Comp
77
+ ref={ref}
78
+ {...props}
79
+ role={role}
80
+ {...currentProps}
81
+ {...mergeDataAttributes(
82
+ props,
83
+ dataAttributes({
84
+ orientation,
85
+ labelPlacement,
86
+ current: isCurrent,
87
+ complete: isComplete,
88
+ progress: hasProgress,
89
+ clickable: isClickable,
90
+ disabled: isDisabled,
91
+ }),
92
+ )}
93
+ >
94
+ {children}
95
+ </Comp>
96
+ </StepperStepProvider>
97
+ );
98
+ },
99
+ );
100
+
101
+ StepperStep.displayName = 'StepperStep';
@@ -0,0 +1,48 @@
1
+ import { forwardRef, type ComponentRef } from 'react';
2
+ import { Pressable, type GestureResponderEvent, type PressableProps } from 'react-native';
3
+ import { composeEventHandlers } from '@cdx-ui/utils';
4
+ import { useFocusRing } from '@react-native-aria/focus';
5
+ import { useHover, usePress } from '@react-native-aria/interactions';
6
+ import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
7
+ import { useStepperContext, useStepperStep } from './context';
8
+
9
+ /**
10
+ * Press target for a clickable step: a `button` that is reachable with Tab and activates
11
+ * with Enter or Space. Rendered by `StepperStepTrigger` only while the step is clickable,
12
+ * so display-only steps add no focus stop and no interaction state.
13
+ */
14
+ export const StepperStepPressable = forwardRef<ComponentRef<typeof Pressable>, PressableProps>(
15
+ ({ onPress, ...props }, ref) => {
16
+ const { index } = useStepperStep();
17
+ const { setCurrentStep } = useStepperContext();
18
+ const { isFocusVisible, focusProps } = useFocusRing() as {
19
+ isFocusVisible: boolean;
20
+ focusProps: Pick<PressableProps, 'onFocus' | 'onBlur'>;
21
+ };
22
+ const { pressProps, isPressed } = usePress({});
23
+ const { isHovered, hoverProps } = useHover();
24
+
25
+ return (
26
+ <Pressable
27
+ ref={ref}
28
+ role="button"
29
+ {...props}
30
+ {...mergeDataAttributes(
31
+ props,
32
+ dataAttributes({ hover: isHovered, active: isPressed, focusVisible: isFocusVisible }),
33
+ )}
34
+ onPress={composeEventHandlers<GestureResponderEvent>(onPress, () => {
35
+ setCurrentStep(index);
36
+ })}
37
+ onPressIn={composeEventHandlers(props.onPressIn, pressProps.onPressIn)}
38
+ onPressOut={composeEventHandlers(props.onPressOut, pressProps.onPressOut)}
39
+ onHoverIn={composeEventHandlers(props.onHoverIn, hoverProps.onHoverIn)}
40
+ onHoverOut={composeEventHandlers(props.onHoverOut, hoverProps.onHoverOut)}
41
+ onFocus={composeEventHandlers(props.onFocus, focusProps.onFocus)}
42
+ onBlur={composeEventHandlers(props.onBlur, focusProps.onBlur)}
43
+ />
44
+ );
45
+ },
46
+ );
47
+
48
+ StepperStepPressable.displayName = 'StepperStepPressable';