@spark-ui/components 17.5.6-beta.0 → 17.5.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/stepper/Stepper.d.ts +10 -5
- package/dist/src/stepper/StepperButton.d.ts +2 -2
- package/dist/src/stepper/types.d.ts +26 -23
- package/dist/src/stepper/useStepper.d.ts +1 -1
- package/dist/stepper/index.js +1 -1
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/index.mjs +103 -117
- package/dist/stepper/index.mjs.map +1 -1
- package/package.json +13 -18
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { PropsWithChildren, RefObject } from 'react';
|
|
2
|
-
import { StepperProps
|
|
2
|
+
import { StepperProps } from './types';
|
|
3
|
+
interface StepperContextValue {
|
|
4
|
+
inputRef: RefObject<HTMLInputElement | null>;
|
|
5
|
+
fieldId?: string;
|
|
6
|
+
fieldIsInvalid?: boolean;
|
|
7
|
+
fieldIsRequired?: boolean;
|
|
8
|
+
}
|
|
3
9
|
export declare const Stepper: {
|
|
4
|
-
({ children, formatOptions, minValue, maxValue, ref: forwardedRef, ...stepperProps }: PropsWithChildren<StepperProps>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
({ children, formatOptions, minValue, maxValue, ref: forwardedRef, onValueChange, locale, name: nameProp, ...stepperProps }: PropsWithChildren<StepperProps>): import("react/jsx-runtime").JSX.Element;
|
|
5
11
|
displayName: string;
|
|
6
12
|
};
|
|
7
|
-
export declare const useStepperContext: () =>
|
|
8
|
-
|
|
9
|
-
};
|
|
13
|
+
export declare const useStepperContext: () => StepperContextValue;
|
|
14
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { StepperButtonProps } from './types';
|
|
3
3
|
export declare const StepperIncrementButton: {
|
|
4
|
-
({ children, design, intent, className, ref: forwardedRef, ...rest }: PropsWithChildren<StepperButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
({ children, design, intent, className, ref: forwardedRef, disabled, ...rest }: PropsWithChildren<StepperButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
} & {
|
|
7
7
|
id: string;
|
|
8
8
|
};
|
|
9
9
|
export declare const StepperDecrementButton: {
|
|
10
|
-
({ children, design, intent, className, ref: forwardedRef, ...rest }: PropsWithChildren<StepperButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
({ children, design, intent, className, ref: forwardedRef, disabled, ...rest }: PropsWithChildren<StepperButtonProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
displayName: string;
|
|
12
12
|
} & {
|
|
13
13
|
id: string;
|
|
@@ -1,46 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { NumberFieldStateOptions } from '@react-stately/numberfield';
|
|
4
|
-
import { AriaNumberFieldProps } from '@react-types/numberfield';
|
|
5
|
-
import { Ref, RefObject } from 'react';
|
|
1
|
+
import { NumberField } from '@base-ui/react/number-field';
|
|
2
|
+
import { ComponentProps, Ref, RefObject } from 'react';
|
|
6
3
|
import { IconButtonProps } from '../icon-button';
|
|
7
4
|
import { InputGroupProps, InputProps } from '../input';
|
|
8
|
-
|
|
9
|
-
* As we're using React Spectrum library to build this component, we also want
|
|
10
|
-
* to build our typing uppon theirs.
|
|
11
|
-
* Still, we have to adapt it to avoid exposing useless props.
|
|
12
|
-
*/
|
|
13
|
-
export type StepperButtonProps = Omit<IconButtonProps, 'shape' | 'size' | 'disabled' | 'asChild' | 'isLoading' | 'loadingLabel'> & Omit<AriaButtonOptions<'button'>, 'elementType' | 'href' | 'target' | 'isDisabled' | 'excludeFromTabOrder' | 'aria-label' | 'preventFocusOnPress'> & {
|
|
5
|
+
export type StepperButtonProps = Omit<IconButtonProps, 'shape' | 'size' | 'disabled' | 'asChild' | 'isLoading' | 'loadingLabel'> & {
|
|
14
6
|
disabled?: boolean;
|
|
15
7
|
ref?: Ref<HTMLButtonElement>;
|
|
16
8
|
};
|
|
17
|
-
|
|
18
|
-
export interface UseStepperArgs extends Omit<Omit<NumberFieldStateOptions, 'locale'> & Omit<AriaNumberFieldProps, 'incrementAriaLabel' | 'decrementAriaLabel'>, SpectrumNumberFieldPropsFilter> {
|
|
9
|
+
export interface UseStepperArgs extends Omit<ComponentProps<typeof NumberField.Root>, 'render' | 'children' | 'onValueChange' | 'onValueCommitted' | 'allowWheelScrub' | 'allowOutOfRange' | 'snapOnStep' | 'smallStep' | 'largeStep' | 'inputRef' | 'form' | 'min' | 'max' | 'format'> {
|
|
19
10
|
inputRef: RefObject<HTMLInputElement | null>;
|
|
20
11
|
/**
|
|
21
|
-
*
|
|
12
|
+
* The minimum allowed value.
|
|
22
13
|
*/
|
|
23
|
-
|
|
14
|
+
minValue?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The maximum allowed value.
|
|
17
|
+
*/
|
|
18
|
+
maxValue?: number;
|
|
24
19
|
/**
|
|
25
|
-
*
|
|
20
|
+
* Formatting options for number display.
|
|
26
21
|
*/
|
|
27
|
-
|
|
22
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
24
|
+
* Callback fired when the value changes.
|
|
30
25
|
*/
|
|
31
|
-
|
|
26
|
+
onValueChange?: (value: number) => void;
|
|
32
27
|
/**
|
|
33
28
|
* The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale.
|
|
34
29
|
* @default 'fr'
|
|
35
30
|
*/
|
|
36
31
|
locale?: string;
|
|
37
32
|
}
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
export interface UseStepperReturn {
|
|
34
|
+
groupProps: ComponentProps<typeof NumberField.Group>;
|
|
35
|
+
inputProps: ComponentProps<typeof NumberField.Input>;
|
|
36
|
+
incrementButtonProps: ComponentProps<typeof NumberField.Increment>;
|
|
37
|
+
decrementButtonProps: ComponentProps<typeof NumberField.Decrement>;
|
|
38
|
+
}
|
|
39
|
+
export type StepperProps = Omit<Omit<UseStepperArgs, 'inputRef'> & Omit<InputGroupProps, 'onClear'>, 'id' | 'name'> & {
|
|
41
40
|
ref?: Ref<HTMLDivElement>;
|
|
41
|
+
/**
|
|
42
|
+
* The name of the stepper. Submitted with its owning form as part of a name/value pair.
|
|
43
|
+
* If wrapped with a FormField with a name, will be inherited from it.
|
|
44
|
+
*/
|
|
45
|
+
name?: string;
|
|
42
46
|
};
|
|
43
47
|
export type StepperInputProps = Omit<InputProps, 'asChild'> & {
|
|
44
48
|
ref?: Ref<HTMLInputElement>;
|
|
45
49
|
};
|
|
46
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { UseStepperArgs, UseStepperReturn } from './types';
|
|
2
|
-
export declare const useStepper: (
|
|
2
|
+
export declare const useStepper: (_args: UseStepperArgs) => UseStepperReturn;
|
package/dist/stepper/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../icon-CRPcdgYp.js`),t=require(`../icon-button-CYz_Fitz.js`),n=require(`../input-DaShg4eE.js`);let r=require(`react`),i=require(`react/jsx-runtime`),a=require(`@spark-ui/hooks/use-merge-refs`),o=require(`@spark-ui/components/form-field`),s=require(`@spark-ui/icons/Minus`),c=require(`@
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../icon-CRPcdgYp.js`),t=require(`../icon-button-CYz_Fitz.js`),n=require(`../input-DaShg4eE.js`);let r=require(`react`),i=require(`react/jsx-runtime`),a=require(`@spark-ui/hooks/use-merge-refs`),o=require(`@spark-ui/components/form-field`),s=require(`@spark-ui/icons/Minus`),c=require(`@base-ui/react/number-field`),l=require(`@spark-ui/icons/Plus`);var u=(0,r.createContext)(null),d=({children:e,formatOptions:t,minValue:a,maxValue:s,ref:l,onValueChange:d,locale:f=`fr`,name:p,...m})=>{let h=(0,r.useRef)(null),g=(0,o.useFormFieldControl)(),_=g.name??p,v=g.disabled??m.disabled,y=g.readOnly??m.readOnly,b=g.isRequired??m.required,x=e=>{d&&e!==null&&d(e)};return(0,i.jsx)(u.Provider,{value:{inputRef:h,fieldId:g.id,fieldIsInvalid:g.isInvalid,fieldIsRequired:b},children:(0,i.jsx)(c.NumberField.Root,{...m,format:t,min:a,max:s,locale:f,disabled:v,readOnly:y,required:b,name:_,inputRef:h,onValueChange:x,"aria-describedby":g.description,children:(0,i.jsx)(n.t,{"data-spark-component":`stepper`,ref:l,state:m.state,disabled:v,readOnly:y,children:(0,i.jsx)(c.NumberField.Group,{children:e})})})})};d.displayName=`Stepper`;var f=()=>{let e=(0,r.useContext)(u);if(!e)throw Error(`useStepperContext must be used within a Stepper provider`);return e},p=({children:r,design:a=`ghost`,intent:o=`neutral`,className:s,ref:u,disabled:d,...p})=>{let{fieldId:m}=f();return(0,i.jsx)(c.NumberField.Increment,{render:c=>{let f=d||`disabled`in c&&c.disabled;return(0,i.jsx)(n.t.TrailingAddon,{asChild:!0,"data-spark-component":`stepper-increment-button`,children:(0,i.jsx)(t.t,{ref:u,design:a,intent:o,className:s,...p,...c,"aria-label":p[`aria-label`]||c[`aria-label`],"aria-controls":m,disabled:f,children:r||(0,i.jsx)(e.t,{children:(0,i.jsx)(l.Plus,{})})})})}})},m=({children:r,design:a=`ghost`,intent:o=`neutral`,className:l,ref:u,disabled:d,...p})=>{let{fieldId:m}=f();return(0,i.jsx)(c.NumberField.Decrement,{render:c=>{let f=d||`disabled`in c&&c.disabled;return(0,i.jsx)(n.t.LeadingAddon,{asChild:!0,"data-spark-component":`stepper-decrement-button`,children:(0,i.jsx)(t.t,{ref:u,design:a,intent:o,className:l,...p,...c,"aria-label":p[`aria-label`]||c[`aria-label`],"aria-controls":m,disabled:f,children:r||(0,i.jsx)(e.t,{children:(0,i.jsx)(s.Minus,{})})})})}})},h=Object.assign(p,{id:`TrailingAddon`}),g=Object.assign(m,{id:`LeadingAddon`});p.displayName=`Stepper.IncrementButton`,m.displayName=`Stepper.DecrementButton`;var _=({ref:e,...t})=>{let{inputRef:r,fieldId:o,fieldIsInvalid:s,fieldIsRequired:l}=f(),u=(0,a.useMergeRefs)(e,r),{className:d=``,...p}=t;return(0,i.jsx)(c.NumberField.Input,{render:e=>{let t;l===void 0?`required`in e&&(t=e.required):t=l;let r=s===void 0?e[`aria-invalid`]:s;return(0,i.jsx)(n.n,{ref:u,...e,...p,id:o||e.id,required:t,"aria-invalid":r,className:`min-w-sz-56 text-center ${d}`})}})},v=Object.assign(_,{id:`Input`});_.displayName=`Stepper.Input`;var y=Object.assign(d,{IncrementButton:h,DecrementButton:g,Input:v});y.displayName=`Stepper`,h.displayName=`Stepper.IncrementButton`,g.displayName=`Stepper.DecrementButton`,v.displayName=`Stepper.Input`,exports.Stepper=y;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/stepper/useStepper.ts","../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { useNumberField } from '@react-aria/numberfield'\nimport { useNumberFieldState } from '@react-stately/numberfield'\n\nimport type { UseStepperArgs, UseStepperReturn } from './types'\n\nexport const useStepper = ({\n inputRef,\n locale = 'fr',\n ...rest\n}: UseStepperArgs): UseStepperReturn => {\n const state = useNumberFieldState({\n ...rest,\n isDisabled: rest.disabled,\n isReadOnly: rest.readOnly,\n isRequired: rest.required,\n locale,\n })\n\n const { groupProps, inputProps, incrementButtonProps, decrementButtonProps } = useNumberField(\n {\n isWheelDisabled: false,\n ...rest,\n isDisabled: rest.disabled,\n isReadOnly: rest.readOnly,\n isRequired: rest.required,\n },\n state,\n inputRef\n )\n\n return {\n groupProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n }\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { InputGroup } from '../input'\nimport type { StepperProps, UseStepperReturn } from './types'\nimport { useStepper } from './useStepper'\n\nconst StepperContext = createContext<\n (Omit<UseStepperReturn, 'groupProps'> & { inputRef: RefObject<HTMLInputElement | null> }) | null\n>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n\n const {\n groupProps,\n inputProps: _inputProps,\n incrementButtonProps: _incrementButtonProps,\n decrementButtonProps: _decrementButtonProps,\n } = useStepper({\n ...{\n ...stepperProps,\n /**\n * To enable the possibility to init the stepper with empty (undefined) value,\n * we need to force the empty value to NaN.\n * Cf. https://github.com/adobe/react-spectrum/issues/5524\n */\n ...('value' in stepperProps && { value: stepperProps.value ?? NaN }),\n onChange: stepperProps.onValueChange,\n },\n formatOptions,\n minValue,\n maxValue,\n inputRef,\n })\n\n const formFieldControlProps = useFormFieldControl()\n const isWrappedInFormField = !!formFieldControlProps.id\n\n const incrementButtonProps = {\n ..._incrementButtonProps,\n ...(isWrappedInFormField && { 'aria-controls': formFieldControlProps.id }),\n }\n\n const decrementButtonProps = {\n ..._decrementButtonProps,\n ...(isWrappedInFormField && { 'aria-controls': formFieldControlProps.id }),\n }\n\n const inputProps = {\n ..._inputProps,\n ...(isWrappedInFormField && {\n id: formFieldControlProps.id,\n required: formFieldControlProps.isRequired,\n 'aria-invalid': formFieldControlProps.isInvalid ? true : undefined,\n }),\n }\n\n const { onValueChange: _, ...remainingStepperProps } = stepperProps\n\n return (\n <StepperContext.Provider\n value={{ incrementButtonProps, decrementButtonProps, inputProps, inputRef }}\n >\n <InputGroup\n {...remainingStepperProps}\n {...groupProps}\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n >\n {children}\n </InputGroup>\n </StepperContext.Provider>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { useButton } from '@react-aria/button'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { type PropsWithChildren, useRef } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { InputGroup } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const innerRef = useRef<HTMLButtonElement>(null)\n const ref = forwardedRef && typeof forwardedRef !== 'function' ? forwardedRef : innerRef\n\n const { incrementButtonProps } = useStepperContext()\n const { buttonProps } = useButton({ ...incrementButtonProps, ...rest }, ref)\n\n return (\n <InputGroup.TrailingAddon asChild data-spark-component=\"stepper-increment-button\">\n <IconButton\n ref={ref}\n design={design}\n intent={intent}\n className={className}\n aria-label={buttonProps['aria-label'] as string}\n {...buttonProps}\n disabled={rest.disabled || buttonProps.disabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.TrailingAddon>\n )\n}\n\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const innerRef = useRef<HTMLButtonElement>(null)\n const ref = forwardedRef && typeof forwardedRef !== 'function' ? forwardedRef : innerRef\n\n const { decrementButtonProps } = useStepperContext()\n const { buttonProps } = useButton({ ...decrementButtonProps, ...rest }, ref)\n\n return (\n <InputGroup.LeadingAddon asChild data-spark-component=\"stepper-decrement-button\">\n <IconButton\n ref={ref}\n design={design}\n intent={intent}\n className={className}\n aria-label={buttonProps['aria-label'] as string}\n {...buttonProps}\n disabled={rest.disabled || buttonProps.disabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.LeadingAddon>\n )\n}\n\nexport const StepperIncrementButton = Object.assign(IncrementButton, {\n id: 'TrailingAddon',\n})\n\nexport const StepperDecrementButton = Object.assign(DecrementButton, {\n id: 'LeadingAddon',\n})\n\nIncrementButton.displayName = 'Stepper.DecrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, inputProps } = useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n return (\n <SparkInput\n ref={ref}\n {...remainingProps}\n {...inputProps}\n className={`min-w-sz-56 text-center ${className}`}\n />\n )\n}\n\nexport const StepperInput = Object.assign(Input, {\n id: 'Input',\n})\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":"qhBAKA,IAAa,GAAc,CACzB,WACA,SAAS,KACT,GAAG,KACmC,CACtC,IAAM,GAAA,EAAA,EAAA,qBAA4B,CAChC,GAA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EAAA,EAAA,KAAC,EAAA,MAAD,EAAS,CAAA,CACJ,CAAA,CAEE,CAAA,CACW,CAAA,EAIjB,EAAyB,OAAO,OAAO,EAAiB,CACnE,GAAI,gBACL,CAAC,CAEW,EAAyB,OAAO,OAAO,EAAiB,CACnE,GAAI,eACL,CAAC,CAEF,EAAgB,YAAc,0BAC9B,EAAgB,YAAc,0BCpF9B,IAAM,GAAS,CAAE,IAAK,EAAc,GAAG,KAA+B,CACpE,GAAM,CAAE,WAAU,cAAe,GAAmB,CAC9C,GAAA,EAAA,EAAA,cAAmB,EAAc,EAAS,CAC1C,CAAE,YAAY,GAAI,GAAG,GAAmB,EAE9C,OACE,EAAA,EAAA,KAAC,EAAA,EAAD,CACO,MACL,GAAI,EACJ,GAAI,EACJ,UAAW,2BAA2B,IACtC,CAAA,EAIO,EAAe,OAAO,OAAO,EAAO,CAC/C,GAAI,QACL,CAAC,CAEF,EAAM,YAAc,gBCfpB,IAAa,EAIT,OAAO,OAAO,EAAM,CAAE,gBAAA,EAAiB,gBAAA,EAAiB,MAAA,EAAO,CAAC,CAEpE,EAAQ,YAAc,UACtB,EAAgB,YAAc,0BAC9B,EAAgB,YAAc,0BAC9B,EAAM,YAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { InputGroup } from '../input'\nimport type { StepperProps } from './types'\n\ninterface StepperContextValue {\n inputRef: RefObject<HTMLInputElement | null>\n fieldId?: string\n fieldIsInvalid?: boolean\n fieldIsRequired?: boolean\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n onValueChange,\n locale = 'fr',\n name: nameProp,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const formFieldControlProps = useFormFieldControl()\n\n const name = formFieldControlProps.name ?? nameProp\n const disabled = formFieldControlProps.disabled ?? stepperProps.disabled\n const readOnly = formFieldControlProps.readOnly ?? stepperProps.readOnly\n const required = formFieldControlProps.isRequired ?? stepperProps.required\n\n const handleValueChange = (value: number | null) => {\n if (onValueChange && value !== null) {\n onValueChange(value)\n }\n }\n\n return (\n <StepperContext.Provider\n value={{\n inputRef,\n fieldId: formFieldControlProps.id,\n fieldIsInvalid: formFieldControlProps.isInvalid,\n fieldIsRequired: required,\n }}\n >\n <NumberField.Root\n {...stepperProps}\n format={formatOptions}\n min={minValue}\n max={maxValue}\n locale={locale}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n inputRef={inputRef}\n onValueChange={handleValueChange}\n aria-describedby={formFieldControlProps.description}\n >\n <InputGroup\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n state={stepperProps.state}\n disabled={disabled}\n readOnly={readOnly}\n >\n <NumberField.Group>{children}</NumberField.Group>\n </InputGroup>\n </NumberField.Root>\n </StepperContext.Provider>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { NumberField } from '@base-ui/react/number-field'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { type PropsWithChildren } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { InputGroup } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId } = useStepperContext()\n\n return (\n <NumberField.Increment\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n return (\n <InputGroup.TrailingAddon asChild data-spark-component=\"stepper-increment-button\">\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={className}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.TrailingAddon>\n )\n }}\n />\n )\n}\n\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId } = useStepperContext()\n\n return (\n <NumberField.Decrement\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n return (\n <InputGroup.LeadingAddon asChild data-spark-component=\"stepper-decrement-button\">\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={className}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.LeadingAddon>\n )\n }}\n />\n )\n}\n\nexport const StepperIncrementButton = Object.assign(IncrementButton, {\n id: 'TrailingAddon',\n})\n\nexport const StepperDecrementButton = Object.assign(DecrementButton, {\n id: 'LeadingAddon',\n})\n\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { NumberField } from '@base-ui/react/number-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, fieldId, fieldIsInvalid, fieldIsRequired } = useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n return (\n <NumberField.Input\n render={inputProps => {\n // Determine required attribute\n let required: boolean | undefined = undefined\n if (fieldIsRequired !== undefined) {\n required = fieldIsRequired\n } else if ('required' in inputProps) {\n required = (inputProps as any).required\n }\n\n // Determine aria-invalid attribute\n const ariaInvalid =\n fieldIsInvalid !== undefined ? fieldIsInvalid : inputProps['aria-invalid']\n\n return (\n <SparkInput\n ref={ref}\n {...inputProps}\n {...remainingProps}\n id={fieldId || inputProps.id}\n required={required}\n aria-invalid={ariaInvalid}\n className={`min-w-sz-56 text-center ${className}`}\n />\n )\n }}\n />\n )\n}\n\nexport const StepperInput = Object.assign(Input, {\n id: 'Input',\n})\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":"idAcA,IAAM,GAAA,EAAA,EAAA,eAA2D,KAAK,CAEzD,GAAW,CACtB,WACA,gBACA,WACA,WACA,IAAK,EACL,gBACA,SAAS,KACT,KAAM,EACN,GAAG,KACkC,CACrC,IAAM,GAAA,EAAA,EAAA,QAAoC,KAAK,CACzC,GAAA,EAAA,EAAA,sBAA6C,CAE7C,EAAO,EAAsB,MAAQ,EACrC,EAAW,EAAsB,UAAY,EAAa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D,CACO,MACL,GAAI,EACJ,GAAI,EACJ,GAAI,GAAW,EAAW,GAChB,WACV,eAAc,EACd,UAAW,2BAA2B,IACtC,CAAA,EAGN,CAAA,EAIO,EAAe,OAAO,OAAO,EAAO,CAC/C,GAAI,QACL,CAAC,CAEF,EAAM,YAAc,gBCrCpB,IAAa,EAIT,OAAO,OAAO,EAAM,CAAE,gBAAA,EAAiB,gBAAA,EAAiB,MAAA,EAAO,CAAC,CAEpE,EAAQ,YAAc,UACtB,EAAgB,YAAc,0BAC9B,EAAgB,YAAc,0BAC9B,EAAM,YAAc"}
|
package/dist/stepper/index.mjs
CHANGED
|
@@ -6,136 +6,122 @@ import { jsx as s } from "react/jsx-runtime";
|
|
|
6
6
|
import { useMergeRefs as c } from "@spark-ui/hooks/use-merge-refs";
|
|
7
7
|
import { useFormFieldControl as l } from "@spark-ui/components/form-field";
|
|
8
8
|
import { Minus as u } from "@spark-ui/icons/Minus";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let r = f({
|
|
16
|
-
...n,
|
|
17
|
-
isDisabled: n.disabled,
|
|
18
|
-
isReadOnly: n.readOnly,
|
|
19
|
-
isRequired: n.required,
|
|
20
|
-
locale: t
|
|
21
|
-
}), { groupProps: i, inputProps: a, incrementButtonProps: o, decrementButtonProps: s } = d({
|
|
22
|
-
isWheelDisabled: !1,
|
|
23
|
-
...n,
|
|
24
|
-
isDisabled: n.disabled,
|
|
25
|
-
isReadOnly: n.readOnly,
|
|
26
|
-
isRequired: n.required
|
|
27
|
-
}, r, e);
|
|
28
|
-
return {
|
|
29
|
-
groupProps: i,
|
|
30
|
-
inputProps: a,
|
|
31
|
-
incrementButtonProps: o,
|
|
32
|
-
decrementButtonProps: s
|
|
9
|
+
import { NumberField as d } from "@base-ui/react/number-field";
|
|
10
|
+
import { Plus as f } from "@spark-ui/icons/Plus";
|
|
11
|
+
//#region src/stepper/Stepper.tsx
|
|
12
|
+
var p = i(null), m = ({ children: e, formatOptions: t, minValue: n, maxValue: i, ref: a, onValueChange: c, locale: u = "fr", name: f, ...m }) => {
|
|
13
|
+
let h = o(null), g = l(), _ = g.name ?? f, v = g.disabled ?? m.disabled, y = g.readOnly ?? m.readOnly, b = g.isRequired ?? m.required, x = (e) => {
|
|
14
|
+
c && e !== null && c(e);
|
|
33
15
|
};
|
|
34
|
-
|
|
35
|
-
let u = o(null), { groupProps: d, inputProps: f, incrementButtonProps: p, decrementButtonProps: m } = h({
|
|
36
|
-
...c,
|
|
37
|
-
..."value" in c && { value: c.value ?? NaN },
|
|
38
|
-
onChange: c.onValueChange,
|
|
39
|
-
formatOptions: t,
|
|
40
|
-
minValue: n,
|
|
41
|
-
maxValue: i,
|
|
42
|
-
inputRef: u
|
|
43
|
-
}), _ = l(), v = !!_.id, y = {
|
|
44
|
-
...p,
|
|
45
|
-
...v && { "aria-controls": _.id }
|
|
46
|
-
}, b = {
|
|
47
|
-
...m,
|
|
48
|
-
...v && { "aria-controls": _.id }
|
|
49
|
-
}, x = {
|
|
50
|
-
...f,
|
|
51
|
-
...v && {
|
|
52
|
-
id: _.id,
|
|
53
|
-
required: _.isRequired,
|
|
54
|
-
"aria-invalid": _.isInvalid ? !0 : void 0
|
|
55
|
-
}
|
|
56
|
-
}, { onValueChange: S, ...C } = c;
|
|
57
|
-
return /* @__PURE__ */ s(g.Provider, {
|
|
16
|
+
return /* @__PURE__ */ s(p.Provider, {
|
|
58
17
|
value: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
18
|
+
inputRef: h,
|
|
19
|
+
fieldId: g.id,
|
|
20
|
+
fieldIsInvalid: g.isInvalid,
|
|
21
|
+
fieldIsRequired: b
|
|
63
22
|
},
|
|
64
|
-
children: /* @__PURE__ */ s(
|
|
65
|
-
...
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
23
|
+
children: /* @__PURE__ */ s(d.Root, {
|
|
24
|
+
...m,
|
|
25
|
+
format: t,
|
|
26
|
+
min: n,
|
|
27
|
+
max: i,
|
|
28
|
+
locale: u,
|
|
29
|
+
disabled: v,
|
|
30
|
+
readOnly: y,
|
|
31
|
+
required: b,
|
|
32
|
+
name: _,
|
|
33
|
+
inputRef: h,
|
|
34
|
+
onValueChange: x,
|
|
35
|
+
"aria-describedby": g.description,
|
|
36
|
+
children: /* @__PURE__ */ s(r, {
|
|
37
|
+
"data-spark-component": "stepper",
|
|
38
|
+
ref: a,
|
|
39
|
+
state: m.state,
|
|
40
|
+
disabled: v,
|
|
41
|
+
readOnly: y,
|
|
42
|
+
children: /* @__PURE__ */ s(d.Group, { children: e })
|
|
43
|
+
})
|
|
70
44
|
})
|
|
71
45
|
});
|
|
72
46
|
};
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
let e = a(
|
|
47
|
+
m.displayName = "Stepper";
|
|
48
|
+
var h = () => {
|
|
49
|
+
let e = a(p);
|
|
76
50
|
if (!e) throw Error("useStepperContext must be used within a Stepper provider");
|
|
77
51
|
return e;
|
|
78
|
-
},
|
|
79
|
-
let
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
52
|
+
}, g = ({ children: n, design: i = "ghost", intent: a = "neutral", className: o, ref: c, disabled: l, ...u }) => {
|
|
53
|
+
let { fieldId: p } = h();
|
|
54
|
+
return /* @__PURE__ */ s(d.Increment, { render: (d) => {
|
|
55
|
+
let m = l || "disabled" in d && d.disabled;
|
|
56
|
+
return /* @__PURE__ */ s(r.TrailingAddon, {
|
|
57
|
+
asChild: !0,
|
|
58
|
+
"data-spark-component": "stepper-increment-button",
|
|
59
|
+
children: /* @__PURE__ */ s(t, {
|
|
60
|
+
ref: c,
|
|
61
|
+
design: i,
|
|
62
|
+
intent: a,
|
|
63
|
+
className: o,
|
|
64
|
+
...u,
|
|
65
|
+
...d,
|
|
66
|
+
"aria-label": u["aria-label"] || d["aria-label"],
|
|
67
|
+
"aria-controls": p,
|
|
68
|
+
disabled: m,
|
|
69
|
+
children: n || /* @__PURE__ */ s(e, { children: /* @__PURE__ */ s(f, {}) })
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
} });
|
|
73
|
+
}, _ = ({ children: n, design: i = "ghost", intent: a = "neutral", className: o, ref: c, disabled: l, ...f }) => {
|
|
74
|
+
let { fieldId: p } = h();
|
|
75
|
+
return /* @__PURE__ */ s(d.Decrement, { render: (d) => {
|
|
76
|
+
let m = l || "disabled" in d && d.disabled;
|
|
77
|
+
return /* @__PURE__ */ s(r.LeadingAddon, {
|
|
78
|
+
asChild: !0,
|
|
79
|
+
"data-spark-component": "stepper-decrement-button",
|
|
80
|
+
children: /* @__PURE__ */ s(t, {
|
|
81
|
+
ref: c,
|
|
82
|
+
design: i,
|
|
83
|
+
intent: a,
|
|
84
|
+
className: o,
|
|
85
|
+
...f,
|
|
86
|
+
...d,
|
|
87
|
+
"aria-label": f["aria-label"] || d["aria-label"],
|
|
88
|
+
"aria-controls": p,
|
|
89
|
+
disabled: m,
|
|
90
|
+
children: n || /* @__PURE__ */ s(e, { children: /* @__PURE__ */ s(u, {}) })
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
} });
|
|
94
|
+
}, v = Object.assign(g, { id: "TrailingAddon" }), y = Object.assign(_, { id: "LeadingAddon" });
|
|
95
|
+
g.displayName = "Stepper.IncrementButton", _.displayName = "Stepper.DecrementButton";
|
|
118
96
|
//#endregion
|
|
119
97
|
//#region src/stepper/StepperInput.tsx
|
|
120
|
-
var
|
|
121
|
-
let { inputRef: r,
|
|
122
|
-
return /* @__PURE__ */ s(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
98
|
+
var b = ({ ref: e, ...t }) => {
|
|
99
|
+
let { inputRef: r, fieldId: i, fieldIsInvalid: a, fieldIsRequired: o } = h(), l = c(e, r), { className: u = "", ...f } = t;
|
|
100
|
+
return /* @__PURE__ */ s(d.Input, { render: (e) => {
|
|
101
|
+
let t;
|
|
102
|
+
o === void 0 ? "required" in e && (t = e.required) : t = o;
|
|
103
|
+
let r = a === void 0 ? e["aria-invalid"] : a;
|
|
104
|
+
return /* @__PURE__ */ s(n, {
|
|
105
|
+
ref: l,
|
|
106
|
+
...e,
|
|
107
|
+
...f,
|
|
108
|
+
id: i || e.id,
|
|
109
|
+
required: t,
|
|
110
|
+
"aria-invalid": r,
|
|
111
|
+
className: `min-w-sz-56 text-center ${u}`
|
|
112
|
+
});
|
|
113
|
+
} });
|
|
114
|
+
}, x = Object.assign(b, { id: "Input" });
|
|
115
|
+
b.displayName = "Stepper.Input";
|
|
130
116
|
//#endregion
|
|
131
117
|
//#region src/stepper/index.ts
|
|
132
|
-
var
|
|
133
|
-
IncrementButton:
|
|
134
|
-
DecrementButton:
|
|
135
|
-
Input:
|
|
118
|
+
var S = Object.assign(m, {
|
|
119
|
+
IncrementButton: v,
|
|
120
|
+
DecrementButton: y,
|
|
121
|
+
Input: x
|
|
136
122
|
});
|
|
137
|
-
|
|
123
|
+
S.displayName = "Stepper", v.displayName = "Stepper.IncrementButton", y.displayName = "Stepper.DecrementButton", x.displayName = "Stepper.Input";
|
|
138
124
|
//#endregion
|
|
139
|
-
export {
|
|
125
|
+
export { S as Stepper };
|
|
140
126
|
|
|
141
127
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/stepper/useStepper.ts","../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { useNumberField } from '@react-aria/numberfield'\nimport { useNumberFieldState } from '@react-stately/numberfield'\n\nimport type { UseStepperArgs, UseStepperReturn } from './types'\n\nexport const useStepper = ({\n inputRef,\n locale = 'fr',\n ...rest\n}: UseStepperArgs): UseStepperReturn => {\n const state = useNumberFieldState({\n ...rest,\n isDisabled: rest.disabled,\n isReadOnly: rest.readOnly,\n isRequired: rest.required,\n locale,\n })\n\n const { groupProps, inputProps, incrementButtonProps, decrementButtonProps } = useNumberField(\n {\n isWheelDisabled: false,\n ...rest,\n isDisabled: rest.disabled,\n isReadOnly: rest.readOnly,\n isRequired: rest.required,\n },\n state,\n inputRef\n )\n\n return {\n groupProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n }\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { InputGroup } from '../input'\nimport type { StepperProps, UseStepperReturn } from './types'\nimport { useStepper } from './useStepper'\n\nconst StepperContext = createContext<\n (Omit<UseStepperReturn, 'groupProps'> & { inputRef: RefObject<HTMLInputElement | null> }) | null\n>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n\n const {\n groupProps,\n inputProps: _inputProps,\n incrementButtonProps: _incrementButtonProps,\n decrementButtonProps: _decrementButtonProps,\n } = useStepper({\n ...{\n ...stepperProps,\n /**\n * To enable the possibility to init the stepper with empty (undefined) value,\n * we need to force the empty value to NaN.\n * Cf. https://github.com/adobe/react-spectrum/issues/5524\n */\n ...('value' in stepperProps && { value: stepperProps.value ?? NaN }),\n onChange: stepperProps.onValueChange,\n },\n formatOptions,\n minValue,\n maxValue,\n inputRef,\n })\n\n const formFieldControlProps = useFormFieldControl()\n const isWrappedInFormField = !!formFieldControlProps.id\n\n const incrementButtonProps = {\n ..._incrementButtonProps,\n ...(isWrappedInFormField && { 'aria-controls': formFieldControlProps.id }),\n }\n\n const decrementButtonProps = {\n ..._decrementButtonProps,\n ...(isWrappedInFormField && { 'aria-controls': formFieldControlProps.id }),\n }\n\n const inputProps = {\n ..._inputProps,\n ...(isWrappedInFormField && {\n id: formFieldControlProps.id,\n required: formFieldControlProps.isRequired,\n 'aria-invalid': formFieldControlProps.isInvalid ? true : undefined,\n }),\n }\n\n const { onValueChange: _, ...remainingStepperProps } = stepperProps\n\n return (\n <StepperContext.Provider\n value={{ incrementButtonProps, decrementButtonProps, inputProps, inputRef }}\n >\n <InputGroup\n {...remainingStepperProps}\n {...groupProps}\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n >\n {children}\n </InputGroup>\n </StepperContext.Provider>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { useButton } from '@react-aria/button'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { type PropsWithChildren, useRef } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { InputGroup } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const innerRef = useRef<HTMLButtonElement>(null)\n const ref = forwardedRef && typeof forwardedRef !== 'function' ? forwardedRef : innerRef\n\n const { incrementButtonProps } = useStepperContext()\n const { buttonProps } = useButton({ ...incrementButtonProps, ...rest }, ref)\n\n return (\n <InputGroup.TrailingAddon asChild data-spark-component=\"stepper-increment-button\">\n <IconButton\n ref={ref}\n design={design}\n intent={intent}\n className={className}\n aria-label={buttonProps['aria-label'] as string}\n {...buttonProps}\n disabled={rest.disabled || buttonProps.disabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.TrailingAddon>\n )\n}\n\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const innerRef = useRef<HTMLButtonElement>(null)\n const ref = forwardedRef && typeof forwardedRef !== 'function' ? forwardedRef : innerRef\n\n const { decrementButtonProps } = useStepperContext()\n const { buttonProps } = useButton({ ...decrementButtonProps, ...rest }, ref)\n\n return (\n <InputGroup.LeadingAddon asChild data-spark-component=\"stepper-decrement-button\">\n <IconButton\n ref={ref}\n design={design}\n intent={intent}\n className={className}\n aria-label={buttonProps['aria-label'] as string}\n {...buttonProps}\n disabled={rest.disabled || buttonProps.disabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.LeadingAddon>\n )\n}\n\nexport const StepperIncrementButton = Object.assign(IncrementButton, {\n id: 'TrailingAddon',\n})\n\nexport const StepperDecrementButton = Object.assign(DecrementButton, {\n id: 'LeadingAddon',\n})\n\nIncrementButton.displayName = 'Stepper.DecrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, inputProps } = useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n return (\n <SparkInput\n ref={ref}\n {...remainingProps}\n {...inputProps}\n className={`min-w-sz-56 text-center ${className}`}\n />\n )\n}\n\nexport const StepperInput = Object.assign(Input, {\n id: 'Input',\n})\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":";;;;;;;;;;;;;AAKA,IAAa,KAAc,EACzB,aACA,YAAS,MACT,GAAG,QACmC;CACtC,IAAM,IAAQ,EAAoB;EAChC,GAAG;EACH,YAAY,EAAK;EACjB,YAAY,EAAK;EACjB,YAAY,EAAK;EACjB;EACD,CAAC,EAEI,EAAE,eAAY,eAAY,yBAAsB,4BAAyB,EAC7E;EACE,iBAAiB;EACjB,GAAG;EACH,YAAY,EAAK;EACjB,YAAY,EAAK;EACjB,YAAY,EAAK;EAClB,EACD,GACA,EACD;AAED,QAAO;EACL;EACA;EACA;EACA;EACD;GC5BG,IAAiB,EAErB,KAAK,EAEM,KAAW,EACtB,aACA,kBACA,aACA,aACA,KAAK,GACL,GAAG,QACkC;CACrC,IAAM,IAAW,EAAyB,KAAK,EAEzC,EACJ,eACA,YAAY,GACZ,sBAAsB,GACtB,sBAAsB,MACpB,EAAW;EAEX,GAAG;EAMH,GAAI,WAAW,KAAgB,EAAE,OAAO,EAAa,SAAS,KAAK;EACnE,UAAU,EAAa;EAEzB;EACA;EACA;EACA;EACD,CAAC,EAE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AAS,WACT,cACA,KAAK,GACL,GAAG,QACwC;CAC3C,IAAM,IAAW,EAA0B,KAAK,EAC1C,IAAM,KAAgB,OAAO,KAAiB,aAAa,IAAe,GAE1E,EAAE,4BAAyB,GAAmB,EAC9C,EAAE,mBAAgB,EAAU;EAAE,GAAG;EAAsB,GAAG;EAAM,EAAE,EAAI;AAE5E,QACE,kBAAC,EAAW,cAAZ;EAAyB,SAAA;EAAQ,wBAAqB;YACpD,kBAAC,GAAD;GACO;GACG;GACA;GACG;GACX,cAAY,EAAY;GACxB,GAAI;GACJ,UAAU,EAAK,YAAY,EAAY;aAEtC,KACC,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAS,CAAA,EACJ,CAAA;GAEE,CAAA;EACW,CAAA;GAIjB,IAAyB,OAAO,OAAO,GAAiB,EACnE,IAAI,iBACL,CAAC,EAEW,IAAyB,OAAO,OAAO,GAAiB,EACnE,IAAI,gBACL,CAAC;AAEF,EAAgB,cAAc,2BAC9B,EAAgB,cAAc;;;ACpF9B,IAAM,KAAS,EAAE,KAAK,GAAc,GAAG,QAA+B;CACpE,IAAM,EAAE,aAAU,kBAAe,GAAmB,EAC9C,IAAM,EAAa,GAAc,EAAS,EAC1C,EAAE,eAAY,IAAI,GAAG,MAAmB;AAE9C,QACE,kBAAC,GAAD;EACO;EACL,GAAI;EACJ,GAAI;EACJ,WAAW,2BAA2B;EACtC,CAAA;GAIO,IAAe,OAAO,OAAO,GAAO,EAC/C,IAAI,SACL,CAAC;AAEF,EAAM,cAAc;;;ACfpB,IAAa,IAIT,OAAO,OAAO,GAAM;CAAE,iBAAA;CAAiB,iBAAA;CAAiB,OAAA;CAAO,CAAC;AAEpE,EAAQ,cAAc,WACtB,EAAgB,cAAc,2BAC9B,EAAgB,cAAc,2BAC9B,EAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { InputGroup } from '../input'\nimport type { StepperProps } from './types'\n\ninterface StepperContextValue {\n inputRef: RefObject<HTMLInputElement | null>\n fieldId?: string\n fieldIsInvalid?: boolean\n fieldIsRequired?: boolean\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n onValueChange,\n locale = 'fr',\n name: nameProp,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const formFieldControlProps = useFormFieldControl()\n\n const name = formFieldControlProps.name ?? nameProp\n const disabled = formFieldControlProps.disabled ?? stepperProps.disabled\n const readOnly = formFieldControlProps.readOnly ?? stepperProps.readOnly\n const required = formFieldControlProps.isRequired ?? stepperProps.required\n\n const handleValueChange = (value: number | null) => {\n if (onValueChange && value !== null) {\n onValueChange(value)\n }\n }\n\n return (\n <StepperContext.Provider\n value={{\n inputRef,\n fieldId: formFieldControlProps.id,\n fieldIsInvalid: formFieldControlProps.isInvalid,\n fieldIsRequired: required,\n }}\n >\n <NumberField.Root\n {...stepperProps}\n format={formatOptions}\n min={minValue}\n max={maxValue}\n locale={locale}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n inputRef={inputRef}\n onValueChange={handleValueChange}\n aria-describedby={formFieldControlProps.description}\n >\n <InputGroup\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n state={stepperProps.state}\n disabled={disabled}\n readOnly={readOnly}\n >\n <NumberField.Group>{children}</NumberField.Group>\n </InputGroup>\n </NumberField.Root>\n </StepperContext.Provider>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { NumberField } from '@base-ui/react/number-field'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { type PropsWithChildren } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { InputGroup } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId } = useStepperContext()\n\n return (\n <NumberField.Increment\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n return (\n <InputGroup.TrailingAddon asChild data-spark-component=\"stepper-increment-button\">\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={className}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.TrailingAddon>\n )\n }}\n />\n )\n}\n\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId } = useStepperContext()\n\n return (\n <NumberField.Decrement\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n return (\n <InputGroup.LeadingAddon asChild data-spark-component=\"stepper-decrement-button\">\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={className}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </InputGroup.LeadingAddon>\n )\n }}\n />\n )\n}\n\nexport const StepperIncrementButton = Object.assign(IncrementButton, {\n id: 'TrailingAddon',\n})\n\nexport const StepperDecrementButton = Object.assign(DecrementButton, {\n id: 'LeadingAddon',\n})\n\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { NumberField } from '@base-ui/react/number-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, fieldId, fieldIsInvalid, fieldIsRequired } = useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n return (\n <NumberField.Input\n render={inputProps => {\n // Determine required attribute\n let required: boolean | undefined = undefined\n if (fieldIsRequired !== undefined) {\n required = fieldIsRequired\n } else if ('required' in inputProps) {\n required = (inputProps as any).required\n }\n\n // Determine aria-invalid attribute\n const ariaInvalid =\n fieldIsInvalid !== undefined ? fieldIsInvalid : inputProps['aria-invalid']\n\n return (\n <SparkInput\n ref={ref}\n {...inputProps}\n {...remainingProps}\n id={fieldId || inputProps.id}\n required={required}\n aria-invalid={ariaInvalid}\n className={`min-w-sz-56 text-center ${className}`}\n />\n )\n }}\n />\n )\n}\n\nexport const StepperInput = Object.assign(Input, {\n id: 'Input',\n})\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":";;;;;;;;;;;AAcA,IAAM,IAAiB,EAA0C,KAAK,EAEzD,KAAW,EACtB,aACA,kBACA,aACA,aACA,KAAK,GACL,kBACA,YAAS,MACT,MAAM,GACN,GAAG,QACkC;CACrC,IAAM,IAAW,EAAyB,KAAK,EACzC,IAAwB,GAAqB,EAE7C,IAAO,EAAsB,QAAQ,GACrC,IAAW,EAAsB,YAAY,EAAa,UAC1D,IAAW,EAAsB,YAAY,EAAa,UAC1D,IAAW,EAAsB,cAAc,EAAa,UAE5D,KAAqB,MAAyB;AAClD,EAAI,KAAiB,MAAU,QAC7B,EAAc,EAAM;;AAIxB,QACE,kBAAC,EAAe,UAAhB;EACE,OAAO;GACL;GACA,SAAS,EAAsB;GAC/B,gBAAgB,EAAsB;GACtC,iBAAiB;GAClB;YAED,kBAAC,EAAY,MAAb;GACE,GAAI;GACJ,QAAQ;GACR,KAAK;GACL,KAAK;GACG;GACE;GACA;GACA;GACJ;GACI;GACV,eAAe;GACf,oBAAkB,EAAsB;aAExC,kBAAC,GAAD;IACE,wBAAqB;IACrB,KAAK;IACL,OAAO,EAAa;IACV;IACA;cAEV,kBAAC,EAAY,OAAb,EAAoB,aAA6B,CAAA;IACtC,CAAA;GACI,CAAA;EACK,CAAA;;AAI9B,EAAQ,cAAc;AAEtB,IAAa,UAA0B;CACrC,IAAM,IAAU,EAAW,EAAe;AAE1C,KAAI,CAAC,EACH,OAAM,MAAM,2DAA2D;AAGzE,QAAO;GC5EH,KAAmB,EACvB,aACA,YAAS,SACT,YAAS,WACT,cACA,KAAK,GACL,aACA,GAAG,QACwC;CAC3C,IAAM,EAAE,eAAY,GAAmB;AAEvC,QACE,kBAAC,EAAY,WAAb,EACE,SAAQ,MAAe;EACrB,IAAM,IAAa,KAAa,cAAc,KAAgB,EAAoB;AAClF,SACE,kBAAC,EAAW,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Mb,IAAM,IACJ,MAAmB,KAAA,IAA6B,EAAW,kBAA5B;AAEjC,SACE,kBAAC,GAAD;GACO;GACL,GAAI;GACJ,GAAI;GACJ,IAAI,KAAW,EAAW;GAChB;GACV,gBAAc;GACd,WAAW,2BAA2B;GACtC,CAAA;IAGN,CAAA;GAIO,IAAe,OAAO,OAAO,GAAO,EAC/C,IAAI,SACL,CAAC;AAEF,EAAM,cAAc;;;ACrCpB,IAAa,IAIT,OAAO,OAAO,GAAM;CAAE,iBAAA;CAAiB,iBAAA;CAAiB,OAAA;CAAO,CAAC;AAEpE,EAAQ,cAAc,WACtB,EAAgB,cAAc,2BAC9B,EAAgB,cAAc,2BAC9B,EAAM,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-ui/components",
|
|
3
|
-
"version": "17.5.6-beta.
|
|
3
|
+
"version": "17.5.6-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Spark (Leboncoin design system) components.",
|
|
6
6
|
"exports": {
|
|
@@ -48,29 +48,24 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@base-ui/react": "1.0.0",
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@react-stately/numberfield": "3.9.11",
|
|
55
|
-
"@react-stately/toast": "^3.0.0-beta.7",
|
|
56
|
-
"@spark-ui/hooks": "^17.5.6-beta.0",
|
|
57
|
-
"@spark-ui/icons": "^17.5.6-beta.0",
|
|
58
|
-
"@spark-ui/internal-utils": "^17.5.6-beta.0",
|
|
51
|
+
"@spark-ui/hooks": "17.5.6-beta.1",
|
|
52
|
+
"@spark-ui/icons": "17.5.6-beta.1",
|
|
53
|
+
"@spark-ui/internal-utils": "17.5.6-beta.1",
|
|
59
54
|
"@zag-js/pagination": "1.30.0",
|
|
60
55
|
"@zag-js/react": "1.30.0",
|
|
61
56
|
"class-variance-authority": "0.7.1",
|
|
62
|
-
"downshift": "9.0.
|
|
63
|
-
"emulate-tab": "
|
|
64
|
-
"motion": "
|
|
57
|
+
"downshift": "9.0.13",
|
|
58
|
+
"emulate-tab": "1.2.1",
|
|
59
|
+
"motion": "12.34.5",
|
|
65
60
|
"radix-ui": "1.4.3",
|
|
66
|
-
"react-aria-components": "
|
|
67
|
-
"react-snap-carousel": "
|
|
61
|
+
"react-aria-components": "1.15.1",
|
|
62
|
+
"react-snap-carousel": "0.5.1"
|
|
68
63
|
},
|
|
69
64
|
"peerDependencies": {
|
|
70
|
-
"@spark-ui/theme-utils": "17.5.6-beta.
|
|
71
|
-
"react": "
|
|
72
|
-
"react-dom": "
|
|
73
|
-
"tailwindcss": "
|
|
65
|
+
"@spark-ui/theme-utils": "17.5.6-beta.1",
|
|
66
|
+
"react": "19.2.4",
|
|
67
|
+
"react-dom": "19.2.4",
|
|
68
|
+
"tailwindcss": "4.1.18"
|
|
74
69
|
},
|
|
75
70
|
"devDependencies": {
|
|
76
71
|
"jsdom-testing-mocks": "1.16.0"
|