@salt-ds/lab 1.0.0-alpha.43 → 1.0.0-alpha.45
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/css/salt-lab.css +46 -87
- package/dist-cjs/calendar/Calendar.js +7 -0
- package/dist-cjs/calendar/Calendar.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarCarousel.js +1 -1
- package/dist-cjs/calendar/internal/CalendarCarousel.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarDay.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarDay.js +5 -1
- package/dist-cjs/calendar/internal/CalendarDay.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarMonth.js.map +1 -1
- package/dist-cjs/calendar/internal/CalendarNavigation.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarNavigation.js +2 -6
- package/dist-cjs/calendar/internal/CalendarNavigation.js.map +1 -1
- package/dist-cjs/calendar/internal/useFocusManagement.js +3 -0
- package/dist-cjs/calendar/internal/useFocusManagement.js.map +1 -1
- package/dist-cjs/calendar/useCalendar.js +30 -2
- package/dist-cjs/calendar/useCalendar.js.map +1 -1
- package/dist-cjs/calendar/useSelection.js +5 -0
- package/dist-cjs/calendar/useSelection.js.map +1 -1
- package/dist-cjs/contact-details/ContactPrimaryInfo.js.map +1 -1
- package/dist-cjs/contact-details/ContactSecondaryInfo.js.map +1 -1
- package/dist-cjs/contact-details/ContactTertiaryInfo.js.map +1 -1
- package/dist-cjs/date-input/DateInput.css.js +1 -1
- package/dist-cjs/date-input/DateInput.js +196 -49
- package/dist-cjs/date-input/DateInput.js.map +1 -1
- package/dist-cjs/date-picker/DatePicker.js +164 -0
- package/dist-cjs/date-picker/DatePicker.js.map +1 -0
- package/dist-cjs/date-picker/DatePickerContext.js +36 -0
- package/dist-cjs/date-picker/DatePickerContext.js.map +1 -0
- package/dist-cjs/date-picker/DatePickerPanel.css.js +6 -0
- package/dist-cjs/date-picker/DatePickerPanel.css.js.map +1 -0
- package/dist-cjs/date-picker/DatePickerPanel.js +139 -0
- package/dist-cjs/date-picker/DatePickerPanel.js.map +1 -0
- package/dist-cjs/index.js +4 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/stepped-tracker/StepLabel/StepLabel.js.map +1 -1
- package/dist-cjs/stepped-tracker/TrackerStep/TrackerStep.css.js +1 -1
- package/dist-cjs/stepper-input/StepperInput.css.js +1 -1
- package/dist-cjs/stepper-input/StepperInput.js +25 -74
- package/dist-cjs/stepper-input/StepperInput.js.map +1 -1
- package/dist-cjs/stepper-input/useStepperInput.js +19 -63
- package/dist-cjs/stepper-input/useStepperInput.js.map +1 -1
- package/dist-es/calendar/Calendar.js +7 -0
- package/dist-es/calendar/Calendar.js.map +1 -1
- package/dist-es/calendar/internal/CalendarCarousel.js +1 -1
- package/dist-es/calendar/internal/CalendarCarousel.js.map +1 -1
- package/dist-es/calendar/internal/CalendarDay.css.js +1 -1
- package/dist-es/calendar/internal/CalendarDay.js +5 -1
- package/dist-es/calendar/internal/CalendarDay.js.map +1 -1
- package/dist-es/calendar/internal/CalendarMonth.js.map +1 -1
- package/dist-es/calendar/internal/CalendarNavigation.css.js +1 -1
- package/dist-es/calendar/internal/CalendarNavigation.js +3 -7
- package/dist-es/calendar/internal/CalendarNavigation.js.map +1 -1
- package/dist-es/calendar/internal/useFocusManagement.js +3 -0
- package/dist-es/calendar/internal/useFocusManagement.js.map +1 -1
- package/dist-es/calendar/useCalendar.js +32 -4
- package/dist-es/calendar/useCalendar.js.map +1 -1
- package/dist-es/calendar/useSelection.js +4 -1
- package/dist-es/calendar/useSelection.js.map +1 -1
- package/dist-es/contact-details/ContactPrimaryInfo.js.map +1 -1
- package/dist-es/contact-details/ContactSecondaryInfo.js.map +1 -1
- package/dist-es/contact-details/ContactTertiaryInfo.js.map +1 -1
- package/dist-es/date-input/DateInput.css.js +1 -1
- package/dist-es/date-input/DateInput.js +200 -53
- package/dist-es/date-input/DateInput.js.map +1 -1
- package/dist-es/date-picker/DatePicker.js +160 -0
- package/dist-es/date-picker/DatePicker.js.map +1 -0
- package/dist-es/date-picker/DatePickerContext.js +31 -0
- package/dist-es/date-picker/DatePickerContext.js.map +1 -0
- package/dist-es/date-picker/DatePickerPanel.css.js +4 -0
- package/dist-es/date-picker/DatePickerPanel.css.js.map +1 -0
- package/dist-es/date-picker/DatePickerPanel.js +135 -0
- package/dist-es/date-picker/DatePickerPanel.js.map +1 -0
- package/dist-es/index.js +2 -1
- package/dist-es/index.js.map +1 -1
- package/dist-es/stepped-tracker/StepLabel/StepLabel.js.map +1 -1
- package/dist-es/stepped-tracker/TrackerStep/TrackerStep.css.js +1 -1
- package/dist-es/stepper-input/StepperInput.css.js +1 -1
- package/dist-es/stepper-input/StepperInput.js +27 -76
- package/dist-es/stepper-input/StepperInput.js.map +1 -1
- package/dist-es/stepper-input/useStepperInput.js +19 -63
- package/dist-es/stepper-input/useStepperInput.js.map +1 -1
- package/dist-types/calendar/internal/CalendarMonth.d.ts +0 -1
- package/dist-types/calendar/useSelection.d.ts +3 -0
- package/dist-types/contact-details/ContactPrimaryInfo.d.ts +1 -1
- package/dist-types/contact-details/ContactSecondaryInfo.d.ts +1 -1
- package/dist-types/contact-details/ContactTertiaryInfo.d.ts +1 -1
- package/dist-types/contact-details/types.d.ts +1 -1
- package/dist-types/date-input/DateInput.d.ts +21 -7
- package/dist-types/date-picker/DatePicker.d.ts +55 -0
- package/dist-types/date-picker/DatePickerContext.d.ts +23 -0
- package/dist-types/date-picker/DatePickerPanel.d.ts +8 -0
- package/dist-types/date-picker/index.d.ts +1 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/stepped-tracker/StepLabel/StepLabel.d.ts +4 -3
- package/dist-types/stepper-input/StepperInput.d.ts +43 -12
- package/dist-types/stepper-input/useStepperInput.d.ts +7 -288
- package/package.json +2 -2
- package/dist-cjs/stepper-input/internal/useActivationIndicatorPosition.js +0 -38
- package/dist-cjs/stepper-input/internal/useActivationIndicatorPosition.js.map +0 -1
- package/dist-cjs/stepper-input/internal/useDynamicAriaLabel.js +0 -76
- package/dist-cjs/stepper-input/internal/useDynamicAriaLabel.js.map +0 -1
- package/dist-es/stepper-input/internal/useActivationIndicatorPosition.js +0 -34
- package/dist-es/stepper-input/internal/useActivationIndicatorPosition.js.map +0 -1
- package/dist-es/stepper-input/internal/useDynamicAriaLabel.js +0 -72
- package/dist-es/stepper-input/internal/useDynamicAriaLabel.js.map +0 -1
- package/dist-types/stepper-input/internal/useActivationIndicatorPosition.d.ts +0 -2
- package/dist-types/stepper-input/internal/useDynamicAriaLabel.d.ts +0 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
3
|
+
import { makePrefixer, useFloatingComponent, useFormFieldProps, StackLayout, FlexItem, FormFieldHelperText, FlexLayout } from '@salt-ds/core';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { useDatePickerContext } from './DatePickerContext.js';
|
|
6
|
+
import css_248z from './DatePickerPanel.css.js';
|
|
7
|
+
import { useWindow } from '@salt-ds/window';
|
|
8
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
9
|
+
import { Calendar } from '../calendar/Calendar.js';
|
|
10
|
+
import { endOfMonth, startOfMonth } from '@internationalized/date';
|
|
11
|
+
import '../calendar/internal/CalendarContext.js';
|
|
12
|
+
import '../calendar/internal/utils.js';
|
|
13
|
+
import '../calendar/useSelection.js';
|
|
14
|
+
|
|
15
|
+
const withBaseName = makePrefixer("saltDatePickerPanel");
|
|
16
|
+
const DatePickerPanel = forwardRef(
|
|
17
|
+
function DatePickerPanel2(props, ref) {
|
|
18
|
+
var _a;
|
|
19
|
+
const { className, onSelect, helperText, CalendarProps: CalendarProps2, ...rest } = props;
|
|
20
|
+
const targetWindow = useWindow();
|
|
21
|
+
useComponentCssInjection({
|
|
22
|
+
testId: "salt-date-picker-panel",
|
|
23
|
+
css: css_248z,
|
|
24
|
+
window: targetWindow
|
|
25
|
+
});
|
|
26
|
+
const { Component: FloatingComponent } = useFloatingComponent();
|
|
27
|
+
const [hoveredDate, setHoveredDate] = useState(null);
|
|
28
|
+
const {
|
|
29
|
+
openState,
|
|
30
|
+
startDate,
|
|
31
|
+
setStartDate,
|
|
32
|
+
startVisibleMonth,
|
|
33
|
+
setStartVisibleMonth,
|
|
34
|
+
endDate,
|
|
35
|
+
setEndDate,
|
|
36
|
+
endVisibleMonth,
|
|
37
|
+
setEndVisibleMonth,
|
|
38
|
+
setOpen,
|
|
39
|
+
selectionVariant,
|
|
40
|
+
context,
|
|
41
|
+
getPanelPosition,
|
|
42
|
+
setValidationStatus
|
|
43
|
+
} = useDatePickerContext();
|
|
44
|
+
const { a11yProps } = useFormFieldProps();
|
|
45
|
+
const setRangeDate = (_, newDate) => {
|
|
46
|
+
setStartDate(newDate.startDate);
|
|
47
|
+
setEndDate(newDate.endDate);
|
|
48
|
+
setValidationStatus(void 0);
|
|
49
|
+
if (newDate.startDate && newDate.endDate) {
|
|
50
|
+
setOpen(false);
|
|
51
|
+
}
|
|
52
|
+
onSelect == null ? void 0 : onSelect();
|
|
53
|
+
};
|
|
54
|
+
const setSingleDate = (_, newDate) => {
|
|
55
|
+
setStartDate(newDate);
|
|
56
|
+
setValidationStatus(void 0);
|
|
57
|
+
onSelect == null ? void 0 : onSelect();
|
|
58
|
+
setOpen(false);
|
|
59
|
+
};
|
|
60
|
+
const handleHoveredDateChange = (_, newHoveredDate) => {
|
|
61
|
+
setHoveredDate(newHoveredDate);
|
|
62
|
+
};
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (startDate) {
|
|
65
|
+
setStartVisibleMonth(startDate);
|
|
66
|
+
setEndVisibleMonth(startDate.add({ months: 1 }));
|
|
67
|
+
}
|
|
68
|
+
}, [startDate]);
|
|
69
|
+
const isRangePicker = selectionVariant === "range";
|
|
70
|
+
const firstCalendarProps = isRangePicker ? {
|
|
71
|
+
selectionVariant: "range",
|
|
72
|
+
hoveredDate: startDate && hoveredDate && hoveredDate.compare(endOfMonth(startDate)) > 0 ? endOfMonth(startDate) : hoveredDate,
|
|
73
|
+
onHoveredDateChange: handleHoveredDateChange,
|
|
74
|
+
selectedDate: { startDate, endDate },
|
|
75
|
+
onSelectedDateChange: setRangeDate,
|
|
76
|
+
maxDate: startDate && endOfMonth(startDate),
|
|
77
|
+
hideOutOfRangeDates: true
|
|
78
|
+
} : {
|
|
79
|
+
selectionVariant: "default",
|
|
80
|
+
selectedDate: startDate,
|
|
81
|
+
onSelectedDateChange: setSingleDate
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ jsx(FloatingComponent, {
|
|
84
|
+
open: openState,
|
|
85
|
+
className: clsx(withBaseName(), className),
|
|
86
|
+
"aria-modal": "true",
|
|
87
|
+
ref,
|
|
88
|
+
focusManagerProps: context ? {
|
|
89
|
+
context,
|
|
90
|
+
initialFocus: 4
|
|
91
|
+
} : void 0,
|
|
92
|
+
...getPanelPosition(),
|
|
93
|
+
...a11yProps,
|
|
94
|
+
...rest,
|
|
95
|
+
children: /* @__PURE__ */ jsxs(StackLayout, {
|
|
96
|
+
separators: true,
|
|
97
|
+
gap: 0,
|
|
98
|
+
className: withBaseName("container"),
|
|
99
|
+
children: [
|
|
100
|
+
helperText && /* @__PURE__ */ jsx(FlexItem, {
|
|
101
|
+
className: withBaseName("header"),
|
|
102
|
+
children: /* @__PURE__ */ jsx(FormFieldHelperText, {
|
|
103
|
+
children: helperText
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsxs(FlexLayout, {
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx(Calendar, {
|
|
109
|
+
visibleMonth: startVisibleMonth,
|
|
110
|
+
onVisibleMonthChange: (_, month) => setStartVisibleMonth(month),
|
|
111
|
+
...firstCalendarProps,
|
|
112
|
+
...CalendarProps2
|
|
113
|
+
}),
|
|
114
|
+
isRangePicker && /* @__PURE__ */ jsx(Calendar, {
|
|
115
|
+
selectionVariant: "range",
|
|
116
|
+
hoveredDate,
|
|
117
|
+
onHoveredDateChange: handleHoveredDateChange,
|
|
118
|
+
selectedDate: { startDate, endDate },
|
|
119
|
+
onSelectedDateChange: setRangeDate,
|
|
120
|
+
visibleMonth: endVisibleMonth,
|
|
121
|
+
onVisibleMonthChange: (_, month) => setEndVisibleMonth(month),
|
|
122
|
+
hideOutOfRangeDates: true,
|
|
123
|
+
minDate: startDate ? (_a = startOfMonth(startDate)) == null ? void 0 : _a.add({ months: 1 }) : void 0,
|
|
124
|
+
...CalendarProps2
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
export { DatePickerPanel };
|
|
135
|
+
//# sourceMappingURL=DatePickerPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePickerPanel.js","sources":["../src/date-picker/DatePickerPanel.tsx"],"sourcesContent":["import {\n ComponentPropsWithoutRef,\n forwardRef,\n useEffect,\n useState,\n} from \"react\";\nimport {\n FlexItem,\n FlexLayout,\n FormFieldHelperText,\n makePrefixer,\n StackLayout,\n useFloatingComponent,\n useFormFieldProps,\n} from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { useDatePickerContext } from \"./DatePickerContext\";\nimport dateInputPanelCss from \"./DatePickerPanel.css\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport {\n Calendar,\n CalendarProps,\n UseRangeSelectionCalendarProps,\n UseSingleSelectionCalendarProps,\n} from \"../calendar\";\nimport { DateValue, endOfMonth, startOfMonth } from \"@internationalized/date\";\n\nexport interface DatePickerPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n onSelect?: () => void;\n helperText?: string;\n CalendarProps?: Partial<\n Omit<\n CalendarProps,\n | \"selectionVariant\"\n | \"selectedDate\"\n | \"defaultSelectedDate\"\n | \"onSelectedDateChange\"\n >\n >;\n}\n\nconst withBaseName = makePrefixer(\"saltDatePickerPanel\");\n\nexport const DatePickerPanel = forwardRef<HTMLDivElement, DatePickerPanelProps>(\n function DatePickerPanel(props, ref) {\n const { className, onSelect, helperText, CalendarProps, ...rest } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-date-picker-panel\",\n css: dateInputPanelCss,\n window: targetWindow,\n });\n\n const { Component: FloatingComponent } = useFloatingComponent();\n const [hoveredDate, setHoveredDate] = useState<DateValue | null>(null);\n\n const {\n openState,\n startDate,\n setStartDate,\n startVisibleMonth,\n setStartVisibleMonth,\n endDate,\n setEndDate,\n endVisibleMonth,\n setEndVisibleMonth,\n setOpen,\n selectionVariant,\n context,\n getPanelPosition,\n setValidationStatus,\n } = useDatePickerContext();\n\n const { a11yProps } = useFormFieldProps();\n\n const setRangeDate: UseRangeSelectionCalendarProps[\"onSelectedDateChange\"] =\n (_, newDate) => {\n setStartDate(newDate.startDate);\n setEndDate(newDate.endDate);\n setValidationStatus(undefined);\n if (newDate.startDate && newDate.endDate) {\n setOpen(false);\n }\n onSelect?.();\n };\n const setSingleDate: UseSingleSelectionCalendarProps[\"onSelectedDateChange\"] =\n (_, newDate) => {\n setStartDate(newDate);\n setValidationStatus(undefined);\n onSelect?.();\n setOpen(false);\n };\n const handleHoveredDateChange: CalendarProps[\"onHoveredDateChange\"] = (\n _,\n newHoveredDate\n ) => {\n setHoveredDate(newHoveredDate);\n };\n useEffect(() => {\n if (startDate) {\n setStartVisibleMonth(startDate);\n setEndVisibleMonth(startDate.add({ months: 1 }));\n }\n }, [startDate]);\n\n const isRangePicker = selectionVariant === \"range\";\n const firstCalendarProps: CalendarProps = isRangePicker\n ? {\n selectionVariant: \"range\",\n hoveredDate:\n startDate &&\n hoveredDate &&\n hoveredDate.compare(endOfMonth(startDate)) > 0\n ? endOfMonth(startDate)\n : hoveredDate,\n onHoveredDateChange: handleHoveredDateChange,\n selectedDate: { startDate, endDate },\n onSelectedDateChange: setRangeDate,\n maxDate: startDate && endOfMonth(startDate),\n hideOutOfRangeDates: true,\n }\n : {\n selectionVariant: \"default\",\n selectedDate: startDate,\n onSelectedDateChange: setSingleDate,\n };\n return (\n <FloatingComponent\n open={openState}\n className={clsx(withBaseName(), className)}\n aria-modal=\"true\"\n ref={ref}\n focusManagerProps={\n context\n ? {\n context: context,\n initialFocus: 4,\n }\n : undefined\n }\n {...getPanelPosition()}\n {...a11yProps}\n {...rest}\n >\n <StackLayout separators gap={0} className={withBaseName(\"container\")}>\n {helperText && (\n <FlexItem className={withBaseName(\"header\")}>\n <FormFieldHelperText>{helperText}</FormFieldHelperText>\n </FlexItem>\n )}\n <FlexLayout>\n <Calendar\n visibleMonth={startVisibleMonth}\n onVisibleMonthChange={(_, month) => setStartVisibleMonth(month)}\n {...firstCalendarProps}\n {...CalendarProps}\n />\n {isRangePicker && (\n <Calendar\n selectionVariant=\"range\"\n hoveredDate={hoveredDate}\n onHoveredDateChange={handleHoveredDateChange}\n selectedDate={{ startDate, endDate }}\n onSelectedDateChange={setRangeDate}\n visibleMonth={endVisibleMonth}\n onVisibleMonthChange={(_, month) => setEndVisibleMonth(month)}\n hideOutOfRangeDates\n minDate={\n startDate\n ? startOfMonth(startDate)?.add({ months: 1 })\n : undefined\n }\n {...CalendarProps}\n />\n )}\n </FlexLayout>\n </StackLayout>\n </FloatingComponent>\n );\n }\n);\n"],"names":["DatePickerPanel","CalendarProps","dateInputPanelCss"],"mappings":";;;;;;;;;;;;;;AA0CA,MAAM,YAAA,GAAe,aAAa,qBAAqB,CAAA,CAAA;AAEhD,MAAM,eAAkB,GAAA,UAAA;AAAA,EAC7B,SAASA,gBAAgB,CAAA,KAAA,EAAO,GAAK,EAAA;AA7CvC,IAAA,IAAA,EAAA,CAAA;AA8CI,IAAA,MAAM,EAAE,SAAW,EAAA,QAAA,EAAU,YAAY,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EAAA,YAAA;AAAA,gBACtB,YAAc,EAAA,eAAA;AAAA,gBACd,oBAAsB,EAAA,CAAC,CAAG,EAAA,KAAA,KAAU,mBAAmB,KAAK,CAAA;AAAA,gBAC5D,mBAAmB,EAAA,IAAA;AAAA,gBACnB,OAAA,EACE,SACI,GAAA,CAAA,EAAA,GAAA,YAAA,CAAa,SAAS,CAAA,KAAtB,mBAAyB,GAAI,CAAA,EAAE,MAAQ,EAAA,CAAA,EACvC,CAAA,GAAA,KAAA,CAAA;AAAA,gBAEL,GAAGA,cAAAA;AAAA,eACN,CAAA;AAAA,aAAA;AAAA,WAEJ,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
package/dist-es/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export { OrderedButton } from './button-bar/OrderedButton.js';
|
|
|
27
27
|
export { Calendar } from './calendar/Calendar.js';
|
|
28
28
|
export { useCalendarDay } from './calendar/useCalendarDay.js';
|
|
29
29
|
export { useCalendar } from './calendar/useCalendar.js';
|
|
30
|
-
export { useSelectionCalendar, useSelectionDay } from './calendar/useSelection.js';
|
|
30
|
+
export { isRangeOrOffsetSelectionValue, isRangeOrOffsetSelectionWithStartDate, useSelectionCalendar, useSelectionDay } from './calendar/useSelection.js';
|
|
31
31
|
export { Carousel } from './carousel/Carousel.js';
|
|
32
32
|
export { CarouselSlide } from './carousel/CarouselSlide.js';
|
|
33
33
|
export { CascadingMenu } from './cascading-menu/CascadingMenu.js';
|
|
@@ -55,6 +55,7 @@ export { ContactFavoriteToggle } from './contact-details/ContactFavoriteToggle.j
|
|
|
55
55
|
export { MailLinkComponent } from './contact-details/MailLinkComponent.js';
|
|
56
56
|
export { ContentStatus } from './content-status/ContentStatus.js';
|
|
57
57
|
export { DateInput } from './date-input/DateInput.js';
|
|
58
|
+
export { DatePicker } from './date-picker/DatePicker.js';
|
|
58
59
|
export { DeckItem } from './deck-item/DeckItem.js';
|
|
59
60
|
export { DeckLayout } from './deck-layout/DeckLayout.js';
|
|
60
61
|
export { DropdownBase } from './dropdown/DropdownBase.js';
|
package/dist-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepLabel.js","sources":["../src/stepped-tracker/StepLabel/StepLabel.tsx"],"sourcesContent":["import { forwardRef,
|
|
1
|
+
{"version":3,"file":"StepLabel.js","sources":["../src/stepped-tracker/StepLabel/StepLabel.tsx"],"sourcesContent":["import { forwardRef, ReactNode } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer, Label, TextProps } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport stepLabelCss from \"./StepLabel.css\";\n\nconst withBaseName = makePrefixer(\"saltStepLabel\");\n\nexport interface StepLabelProps extends TextProps<\"label\"> {\n /**\n * The content of Step Label\n */\n children?: ReactNode;\n}\n\nexport const StepLabel = forwardRef<HTMLLabelElement, StepLabelProps>(\n function StepLabel({ children, className, ...rest }, ref) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-step-label\",\n css: stepLabelCss,\n window: targetWindow,\n });\n\n return (\n <Label className={clsx(withBaseName(), className)} ref={ref} {...rest}>\n <strong>{children}</strong>\n </Label>\n );\n }\n);\n"],"names":["StepLabel","stepLabelCss"],"mappings":";;;;;;;;AAQA,MAAM,YAAA,GAAe,aAAa,eAAe,CAAA,CAAA;AAS1C,MAAM,SAAY,GAAA,UAAA;AAAA,EACvB,SAASA,UAAU,CAAA,EAAE,UAAU,SAAc,EAAA,GAAA,IAAA,IAAQ,GAAK,EAAA;AACxD,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,iBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,MAAM,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,MAAG,GAAA;AAAA,MAAW,GAAG,IAAA;AAAA,MAC/D,QAAC,kBAAA,GAAA,CAAA,QAAA,EAAA;AAAA,QAAQ,QAAA;AAAA,OAAS,CAAA;AAAA,KACpB,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = ".saltTrackerStep {\n --trackerStep-icon-color-active: var(--saltTrackerStep-icon-color-active, var(--salt-status-info-foreground));\n --trackerStep-icon-color-completed: var(--saltTrackerStep-icon-color-completed, var(--salt-status-success-foreground));\n\n --trackerStep-icon-color: var(--saltTrackerStep-icon-color, var(--salt-status-static-foreground));\n\n --saltIcon-color: var(--trackerStep-icon-color);\n /* We redefine Icon Size so we can use it in calc functions in the trackerConnector */\n --saltIcon-size: var(--saltTrackerStep-icon-size, max(var(--salt-size-icon), 12px));\n}\n\n.saltTrackerStep {\n margin: 0;\n text-indent: 0;\n list-style-type: none;\n flex: 1;\n position: relative;\n display: flex;\n align-items: center;\n width: var(--saltTrackerStep-width, 100%);\n gap: var(--salt-spacing-50);\n color: var(--salt-content-primary-foreground);\n font-size: var(--salt-text-label-fontSize);\n line-height: var(--salt-text-label-lineHeight);\n}\n\n.saltSteppedTracker.saltSteppedTracker-horizontal .saltTrackerStep {\n flex-direction: column;\n padding: 0 var(--salt-spacing-25);\n}\n\n.saltSteppedTracker.saltSteppedTracker-vertical .saltTrackerStep {\n flex-direction: row;\n min-height: calc(var(--salt-size-base) * 2);\n width: 100%;\n}\n\n/* Pseudo-class applied to the root element on focus */\n.saltTrackerStep:focus-visible {\n outline-style: var(--salt-focused-outlineStyle);\n outline-width: var(--salt-focused-outlineWidth);\n outline-color: var(--salt-focused-outlineColor);\n outline-offset: var(--salt-focused-outlineOffset);\n}\n\n.saltTrackerStep .saltTrackerStep-body {\n width: 100%;\n display: flex;\n align-items: center;\n flex-direction: column;\n}\n\n.saltTrackerStep.saltTrackerStep-active {\n --trackerStep-icon-color: var(--trackerStep-icon-color-active);\n}\n\n.saltTrackerStep.saltTrackerStep-completed {\n --trackerStep-icon-color: var(--trackerStep-icon-color-completed);\n}\n";
|
|
1
|
+
var css_248z = ".saltTrackerStep {\n --trackerStep-icon-color-active: var(--saltTrackerStep-icon-color-active, var(--salt-status-info-foreground-decorative));\n --trackerStep-icon-color-completed: var(--saltTrackerStep-icon-color-completed, var(--salt-status-success-foreground-decorative));\n\n --trackerStep-icon-color: var(--saltTrackerStep-icon-color, var(--salt-status-static-foreground));\n\n --saltIcon-color: var(--trackerStep-icon-color);\n /* We redefine Icon Size so we can use it in calc functions in the trackerConnector */\n --saltIcon-size: var(--saltTrackerStep-icon-size, max(var(--salt-size-icon), 12px));\n}\n\n.saltTrackerStep {\n margin: 0;\n text-indent: 0;\n list-style-type: none;\n flex: 1;\n position: relative;\n display: flex;\n align-items: center;\n width: var(--saltTrackerStep-width, 100%);\n gap: var(--salt-spacing-50);\n color: var(--salt-content-primary-foreground);\n font-size: var(--salt-text-label-fontSize);\n line-height: var(--salt-text-label-lineHeight);\n}\n\n.saltSteppedTracker.saltSteppedTracker-horizontal .saltTrackerStep {\n flex-direction: column;\n padding: 0 var(--salt-spacing-25);\n}\n\n.saltSteppedTracker.saltSteppedTracker-vertical .saltTrackerStep {\n flex-direction: row;\n min-height: calc(var(--salt-size-base) * 2);\n width: 100%;\n}\n\n/* Pseudo-class applied to the root element on focus */\n.saltTrackerStep:focus-visible {\n outline-style: var(--salt-focused-outlineStyle);\n outline-width: var(--salt-focused-outlineWidth);\n outline-color: var(--salt-focused-outlineColor);\n outline-offset: var(--salt-focused-outlineOffset);\n}\n\n.saltTrackerStep .saltTrackerStep-body {\n width: 100%;\n display: flex;\n align-items: center;\n flex-direction: column;\n}\n\n.saltTrackerStep.saltTrackerStep-active {\n --trackerStep-icon-color: var(--trackerStep-icon-color-active);\n}\n\n.saltTrackerStep.saltTrackerStep-completed {\n --trackerStep-icon-color: var(--trackerStep-icon-color-completed);\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=TrackerStep.css.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = "
|
|
1
|
+
var css_248z = "/* Styles applied to stepper container */\n.saltStepperInput {\n align-items: center;\n display: flex;\n flex-direction: row;\n gap: var(--salt-spacing-50);\n}\n\n/* Styles applied to stepper buttons container */\n.saltStepperInput-buttonContainer {\n display: flex;\n flex-direction: column;\n gap: var(--salt-spacing-50);\n}\n\n/* Styles applied to stepper buttons */\n.saltStepperInput-stepperButton {\n --saltButton-height: calc((var(--salt-size-base) - var(--salt-spacing-50)) * 0.5);\n --saltButton-width: var(--salt-size-base);\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=StepperInput.css.js.map
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { forwardRef, useRef } from 'react';
|
|
4
|
-
import { makePrefixer, Button } from '@salt-ds/core';
|
|
4
|
+
import { makePrefixer, Input, Button } from '@salt-ds/core';
|
|
5
5
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
6
6
|
import { useWindow } from '@salt-ds/window';
|
|
7
|
-
import {
|
|
8
|
-
import { InputLegacy } from '../input-legacy/InputLegacy.js';
|
|
9
|
-
import '../input-legacy/StaticInputAdornment.js';
|
|
10
|
-
import { useActivationIndicatorPosition } from './internal/useActivationIndicatorPosition.js';
|
|
7
|
+
import { TriangleUpIcon, TriangleDownIcon } from '@salt-ds/icons';
|
|
11
8
|
import { useStepperInput } from './useStepperInput.js';
|
|
12
9
|
import css_248z from './StepperInput.css.js';
|
|
13
10
|
|
|
@@ -15,11 +12,13 @@ const withBaseName = makePrefixer("saltStepperInput");
|
|
|
15
12
|
const StepperInput = forwardRef(
|
|
16
13
|
function StepperInput2(props, ref) {
|
|
17
14
|
const {
|
|
18
|
-
ButtonProps: ButtonPropsProp,
|
|
19
|
-
InputProps: InputPropsProp,
|
|
20
|
-
textAlign = "left",
|
|
21
15
|
className,
|
|
22
|
-
|
|
16
|
+
hideButtons,
|
|
17
|
+
onBlur,
|
|
18
|
+
onChange,
|
|
19
|
+
onFocus,
|
|
20
|
+
readOnly,
|
|
21
|
+
...rest
|
|
23
22
|
} = props;
|
|
24
23
|
const targetWindow = useWindow();
|
|
25
24
|
useComponentCssInjection({
|
|
@@ -27,90 +26,42 @@ const StepperInput = forwardRef(
|
|
|
27
26
|
css: css_248z,
|
|
28
27
|
window: targetWindow
|
|
29
28
|
});
|
|
30
|
-
const adornmentRef = useRef(null);
|
|
31
29
|
const inputRef = useRef(null);
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
getInputProps,
|
|
37
|
-
incrementButtonDown,
|
|
38
|
-
isAtMax,
|
|
39
|
-
isAtMin,
|
|
40
|
-
refreshCurrentValue,
|
|
41
|
-
stepperDirection,
|
|
42
|
-
valuesHaveDiverged
|
|
43
|
-
} = useStepperInput(props, inputRef);
|
|
44
|
-
useActivationIndicatorPosition(
|
|
45
|
-
adornmentRef,
|
|
46
|
-
valuesHaveDiverged() || showRefreshButton
|
|
47
|
-
);
|
|
48
|
-
const endAdornment = /* @__PURE__ */ jsxs("div", {
|
|
49
|
-
className: withBaseName("adornmentContainer"),
|
|
50
|
-
ref: adornmentRef,
|
|
30
|
+
const { getButtonProps, getInputProps } = useStepperInput(props, inputRef);
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
32
|
+
className: clsx(withBaseName(), className),
|
|
33
|
+
ref,
|
|
51
34
|
children: [
|
|
52
|
-
/* @__PURE__ */ jsx(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
variant: "secondary",
|
|
59
|
-
children: /* @__PURE__ */ jsx(RefreshIcon, {
|
|
60
|
-
"aria-label": "refresh"
|
|
61
|
-
})
|
|
35
|
+
/* @__PURE__ */ jsx(Input, {
|
|
36
|
+
onBlur,
|
|
37
|
+
onFocus,
|
|
38
|
+
ref: inputRef,
|
|
39
|
+
readOnly,
|
|
40
|
+
...getInputProps(rest)
|
|
62
41
|
}),
|
|
63
|
-
/* @__PURE__ */ jsxs("div", {
|
|
42
|
+
!hideButtons && !readOnly && /* @__PURE__ */ jsxs("div", {
|
|
64
43
|
className: withBaseName("buttonContainer"),
|
|
65
44
|
children: [
|
|
66
45
|
/* @__PURE__ */ jsx(Button, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
active: incrementButtonDown
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
disabled: isAtMax(),
|
|
75
|
-
...getButtonProps(stepperDirection.INCREMENT, ButtonPropsProp),
|
|
46
|
+
"aria-label": "increment value",
|
|
47
|
+
className: withBaseName("stepperButton"),
|
|
48
|
+
...getButtonProps("increment"),
|
|
76
49
|
children: /* @__PURE__ */ jsx(TriangleUpIcon, {
|
|
77
|
-
|
|
78
|
-
"aria-label": getButtonIcon(stepperDirection.INCREMENT)
|
|
50
|
+
"aria-hidden": true
|
|
79
51
|
})
|
|
80
52
|
}),
|
|
81
53
|
/* @__PURE__ */ jsx(Button, {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
active: decrementButtonDown
|
|
87
|
-
}
|
|
88
|
-
),
|
|
89
|
-
disabled: isAtMin(),
|
|
90
|
-
...getButtonProps(stepperDirection.DECREMENT, ButtonPropsProp),
|
|
54
|
+
"aria-label": "decrement value",
|
|
55
|
+
className: withBaseName("stepperButton"),
|
|
56
|
+
...getButtonProps("decrement"),
|
|
91
57
|
children: /* @__PURE__ */ jsx(TriangleDownIcon, {
|
|
92
|
-
|
|
93
|
-
"aria-label": getButtonIcon(stepperDirection.DECREMENT)
|
|
58
|
+
"aria-hidden": true
|
|
94
59
|
})
|
|
95
60
|
})
|
|
96
61
|
]
|
|
97
62
|
})
|
|
98
63
|
]
|
|
99
64
|
});
|
|
100
|
-
return /* @__PURE__ */ jsx("div", {
|
|
101
|
-
className: clsx(withBaseName(), className),
|
|
102
|
-
onBlur: props.onBlur,
|
|
103
|
-
onFocus: props.onFocus,
|
|
104
|
-
ref,
|
|
105
|
-
children: /* @__PURE__ */ jsx(InputLegacy, {
|
|
106
|
-
className: withBaseName("input"),
|
|
107
|
-
endAdornment,
|
|
108
|
-
highlightOnFocus: true,
|
|
109
|
-
ref: inputRef,
|
|
110
|
-
textAlign,
|
|
111
|
-
...getInputProps(InputPropsProp)
|
|
112
|
-
})
|
|
113
|
-
});
|
|
114
65
|
}
|
|
115
66
|
);
|
|
116
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepperInput.js","sources":["../src/stepper-input/StepperInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport
|
|
1
|
+
{"version":3,"file":"StepperInput.js","sources":["../src/stepper-input/StepperInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { FocusEventHandler, forwardRef, useRef } from \"react\";\nimport { Button, makePrefixer, Input, InputProps } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { TriangleDownIcon, TriangleUpIcon } from \"@salt-ds/icons\";\nimport { useStepperInput } from \"./useStepperInput\";\n\nimport stepperInputCss from \"./StepperInput.css\";\n\nconst withBaseName = makePrefixer(\"saltStepperInput\");\n\nexport interface StepperInputProps\n extends Omit<InputProps, \"onChange\" | \"emptyReadOnlyMarker\"> {\n /**\n * A multiplier applied to the `step` when the value is incremented or decremented using the PageDown/PageUp keys.\n */\n block?: number;\n /**\n * The number of decimal places to display.\n */\n decimalPlaces?: number;\n /**\n * Sets the initial default value of the component.\n */\n defaultValue?: number;\n /**\n * The maximum value that can be selected.\n */\n max?: number;\n /**\n * The minimum value that can be selected.\n */\n min?: number;\n /**\n * Whether to hide the stepper buttons. Defaults to `false`.\n */\n hideButtons?: boolean;\n /**\n * Callback when stepper input loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback when stepper input value is changed.\n */\n onChange?: (changedValue: number | string) => void;\n /**\n * Callback when stepper input gains focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * The amount to increment or decrement the value by when using the stepper buttons or Up Arrow and Down Arrow keys.\n */\n step?: number;\n /**\n * Determines the text alignment of the display value.\n */\n textAlign?: \"center\" | \"left\" | \"right\";\n /**\n * The value of the stepper input. The component will be controlled if this prop is provided.\n */\n value?: number | string;\n}\n\nexport const StepperInput = forwardRef<HTMLDivElement, StepperInputProps>(\n function StepperInput(props, ref) {\n const {\n className,\n hideButtons,\n onBlur,\n onChange,\n onFocus,\n readOnly,\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-stepper-input\",\n css: stepperInputCss,\n window: targetWindow,\n });\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const { getButtonProps, getInputProps } = useStepperInput(props, inputRef);\n\n return (\n <div className={clsx(withBaseName(), className)} ref={ref}>\n <Input\n onBlur={onBlur}\n onFocus={onFocus}\n ref={inputRef}\n readOnly={readOnly}\n {...getInputProps(rest)}\n />\n {!hideButtons && !readOnly && (\n <div className={withBaseName(\"buttonContainer\")}>\n <Button\n aria-label=\"increment value\"\n className={withBaseName(\"stepperButton\")}\n {...getButtonProps(\"increment\")}\n >\n <TriangleUpIcon aria-hidden />\n </Button>\n <Button\n aria-label=\"decrement value\"\n className={withBaseName(\"stepperButton\")}\n {...getButtonProps(\"decrement\")}\n >\n <TriangleDownIcon aria-hidden />\n </Button>\n </div>\n )}\n </div>\n );\n }\n);\n"],"names":["StepperInput","stepperInputCss"],"mappings":";;;;;;;;;;AAUA,MAAM,YAAA,GAAe,aAAa,kBAAkB,CAAA,CAAA;AAsD7C,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aAAa,CAAA,KAAA,EAAO,GAAK,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,WAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAA;AAAA,MACA,OAAA;AAAA,MACA,QAAA;AAAA,MACG,GAAA,IAAA;AAAA,KACD,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,oBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAM,MAAA,QAAA,GAAW,OAAgC,IAAI,CAAA,CAAA;AAErD,IAAA,MAAM,EAAE,cAAgB,EAAA,aAAA,EAAkB,GAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA,CAAA;AAEzE,IAAA,uBACG,IAAA,CAAA,KAAA,EAAA;AAAA,MAAI,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,MAAG,GAAA;AAAA,MAC/C,QAAA,EAAA;AAAA,wBAAC,GAAA,CAAA,KAAA,EAAA;AAAA,UACC,MAAA;AAAA,UACA,OAAA;AAAA,UACA,GAAK,EAAA,QAAA;AAAA,UACL,QAAA;AAAA,UACC,GAAG,cAAc,IAAI,CAAA;AAAA,SACxB,CAAA;AAAA,QACC,CAAC,WAAA,IAAe,CAAC,QAAA,oBACf,IAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,iBAAiB,CAAA;AAAA,UAC5C,QAAA,EAAA;AAAA,4BAAC,GAAA,CAAA,MAAA,EAAA;AAAA,cACC,YAAW,EAAA,iBAAA;AAAA,cACX,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,cACtC,GAAG,eAAe,WAAW,CAAA;AAAA,cAE9B,QAAC,kBAAA,GAAA,CAAA,cAAA,EAAA;AAAA,gBAAe,aAAW,EAAA,IAAA;AAAA,eAAC,CAAA;AAAA,aAC9B,CAAA;AAAA,4BACC,GAAA,CAAA,MAAA,EAAA;AAAA,cACC,YAAW,EAAA,iBAAA;AAAA,cACX,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,cACtC,GAAG,eAAe,WAAW,CAAA;AAAA,cAE9B,QAAC,kBAAA,GAAA,CAAA,gBAAA,EAAA;AAAA,gBAAiB,aAAW,EAAA,IAAA;AAAA,eAAC,CAAA;AAAA,aAChC,CAAA;AAAA,WAAA;AAAA,SACF,CAAA;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { useControlled, useId } from '@salt-ds/core';
|
|
2
|
-
import { useDynamicAriaLabel } from './internal/useDynamicAriaLabel.js';
|
|
3
2
|
import { useSpinner } from './internal/useSpinner.js';
|
|
4
3
|
|
|
5
|
-
const stepperDirection = {
|
|
6
|
-
INCREMENT: "increment",
|
|
7
|
-
DECREMENT: "decrement"
|
|
8
|
-
};
|
|
9
4
|
const ACCEPT_INPUT = /^[-+]?[0-9]*\.?([0-9]+)?/g;
|
|
10
5
|
const callAll = (...fns) => (...args) => fns.forEach((fn) => fn && fn(...args));
|
|
11
6
|
const toFixedDecimalPlaces = (inputNumber, decimalPlaces) => inputNumber.toFixed(decimalPlaces);
|
|
@@ -19,27 +14,25 @@ const toFloat = (inputValue) => {
|
|
|
19
14
|
return 0;
|
|
20
15
|
return parseFloat(inputValue.toString());
|
|
21
16
|
};
|
|
22
|
-
const
|
|
23
|
-
const getButtonIcon = (type) => type === stepperDirection.INCREMENT ? "triangle-up" : "triangle-down";
|
|
17
|
+
const sanitizedInput = (numberString) => (numberString.match(ACCEPT_INPUT) || []).join("");
|
|
24
18
|
const useStepperInput = (props, inputRef) => {
|
|
25
19
|
const {
|
|
26
20
|
block = 10,
|
|
27
21
|
decimalPlaces = 0,
|
|
28
22
|
defaultValue = 0,
|
|
29
|
-
|
|
23
|
+
id: idProp,
|
|
30
24
|
max = Number.MAX_SAFE_INTEGER,
|
|
31
25
|
min = Number.MIN_SAFE_INTEGER,
|
|
32
26
|
onChange,
|
|
33
27
|
step = 1,
|
|
34
|
-
value
|
|
35
|
-
InputProps: inputPropsProp = {}
|
|
28
|
+
value
|
|
36
29
|
} = props;
|
|
37
30
|
const [currentValue, setCurrentValue, isControlled] = useControlled({
|
|
38
31
|
controlled: value,
|
|
39
32
|
default: toFixedDecimalPlaces(defaultValue, decimalPlaces),
|
|
40
33
|
name: "stepper-input"
|
|
41
34
|
});
|
|
42
|
-
const inputId = useId(
|
|
35
|
+
const inputId = useId(idProp);
|
|
43
36
|
const isOutOfRange = () => {
|
|
44
37
|
if (currentValue === void 0)
|
|
45
38
|
return true;
|
|
@@ -55,18 +48,6 @@ const useStepperInput = (props, inputRef) => {
|
|
|
55
48
|
return true;
|
|
56
49
|
return toFloat(currentValue) <= min || min === 0 && currentValue === "";
|
|
57
50
|
};
|
|
58
|
-
const valuesHaveDiverged = () => {
|
|
59
|
-
if (liveValue === void 0 || currentValue === void 0)
|
|
60
|
-
return false;
|
|
61
|
-
return toFloat(toFixedDecimalPlaces(liveValue, decimalPlaces)) !== toFloat(currentValue);
|
|
62
|
-
};
|
|
63
|
-
const { setHasAnnounced } = useDynamicAriaLabel(
|
|
64
|
-
", value out of date",
|
|
65
|
-
liveValue !== void 0,
|
|
66
|
-
inputRef,
|
|
67
|
-
currentValue,
|
|
68
|
-
valuesHaveDiverged
|
|
69
|
-
);
|
|
70
51
|
const decrement = () => {
|
|
71
52
|
if (currentValue === void 0 || isAtMin())
|
|
72
53
|
return;
|
|
@@ -100,6 +81,8 @@ const useStepperInput = (props, inputRef) => {
|
|
|
100
81
|
setNextValue(nextValue);
|
|
101
82
|
};
|
|
102
83
|
const setNextValue = (modifiedValue) => {
|
|
84
|
+
if (props.readOnly)
|
|
85
|
+
return;
|
|
103
86
|
let nextValue = modifiedValue;
|
|
104
87
|
if (nextValue < min)
|
|
105
88
|
nextValue = min;
|
|
@@ -133,16 +116,13 @@ const useStepperInput = (props, inputRef) => {
|
|
|
133
116
|
onChange(roundedValue);
|
|
134
117
|
}
|
|
135
118
|
};
|
|
136
|
-
const handleInputFocus = () => {
|
|
137
|
-
setHasAnnounced(false);
|
|
138
|
-
};
|
|
139
119
|
const handleInputChange = (event) => {
|
|
140
|
-
const changedValue = event.
|
|
120
|
+
const changedValue = event.target.value;
|
|
141
121
|
if (!isControlled) {
|
|
142
|
-
setCurrentValue(
|
|
122
|
+
setCurrentValue(sanitizedInput(changedValue));
|
|
143
123
|
}
|
|
144
124
|
if (onChange) {
|
|
145
|
-
onChange(
|
|
125
|
+
onChange(sanitizedInput(changedValue));
|
|
146
126
|
}
|
|
147
127
|
};
|
|
148
128
|
const handleInputKeyDown = (event) => {
|
|
@@ -155,40 +135,21 @@ const useStepperInput = (props, inputRef) => {
|
|
|
155
135
|
event.key === "PageUp" ? incrementSpinnerBlock() : decrementSpinnerBlock();
|
|
156
136
|
}
|
|
157
137
|
};
|
|
158
|
-
const handleButtonMouseDown = (event,
|
|
138
|
+
const handleButtonMouseDown = (event, direction) => {
|
|
159
139
|
if (event.nativeEvent.button !== 0)
|
|
160
140
|
return;
|
|
161
|
-
|
|
141
|
+
direction === "increment" ? incrementSpinner() : decrementSpinner();
|
|
162
142
|
};
|
|
163
143
|
const handleButtonMouseUp = () => {
|
|
164
144
|
var _a;
|
|
165
145
|
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
166
146
|
};
|
|
167
|
-
const
|
|
168
|
-
var _a;
|
|
169
|
-
const refreshedcurrentValue = liveValue !== void 0 ? liveValue : defaultValue;
|
|
170
|
-
if (refreshedcurrentValue === void 0)
|
|
171
|
-
return;
|
|
172
|
-
setCurrentValue(
|
|
173
|
-
toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)
|
|
174
|
-
);
|
|
175
|
-
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
176
|
-
if (onChange) {
|
|
177
|
-
onChange(
|
|
178
|
-
toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
const getButtonProps = (type = stepperDirection.INCREMENT, buttonPropsProp = {}) => ({
|
|
147
|
+
const getButtonProps = (direction) => ({
|
|
183
148
|
"aria-hidden": true,
|
|
184
|
-
"
|
|
149
|
+
disabled: props.disabled || (direction === "increment" ? isAtMax() : isAtMin()),
|
|
185
150
|
tabIndex: -1,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(event) => handleButtonMouseDown(event, type),
|
|
189
|
-
buttonPropsProp.onMouseDown
|
|
190
|
-
),
|
|
191
|
-
onMouseUp: callAll(() => handleButtonMouseUp(), buttonPropsProp.onMouseUp)
|
|
151
|
+
onMouseDown: (event) => handleButtonMouseDown(event, direction),
|
|
152
|
+
onMouseUp: handleButtonMouseUp
|
|
192
153
|
});
|
|
193
154
|
const getInputProps = (inputProps = {}) => {
|
|
194
155
|
if (currentValue === void 0)
|
|
@@ -208,22 +169,17 @@ const useStepperInput = (props, inputRef) => {
|
|
|
208
169
|
},
|
|
209
170
|
onBlur: callAll(inputProps.onBlur, handleInputBlur),
|
|
210
171
|
onChange: callAll(inputProps.onChange, handleInputChange),
|
|
211
|
-
onFocus:
|
|
212
|
-
onKeyDown: callAll(inputProps.
|
|
172
|
+
onFocus: inputProps.onFocus,
|
|
173
|
+
onKeyDown: callAll(inputProps.onKeyDown, handleInputKeyDown),
|
|
174
|
+
textAlign: inputProps.textAlign,
|
|
213
175
|
value: String(currentValue)
|
|
214
176
|
};
|
|
215
177
|
};
|
|
216
178
|
return {
|
|
217
179
|
decrementButtonDown: arrowDownButtonDown || pgDnButtonDown,
|
|
218
|
-
getButtonIcon,
|
|
219
180
|
getButtonProps,
|
|
220
181
|
getInputProps,
|
|
221
|
-
incrementButtonDown: arrowUpButtonDown || pgUpButtonDown
|
|
222
|
-
isAtMax,
|
|
223
|
-
isAtMin,
|
|
224
|
-
refreshCurrentValue,
|
|
225
|
-
stepperDirection,
|
|
226
|
-
valuesHaveDiverged
|
|
182
|
+
incrementButtonDown: arrowUpButtonDown || pgUpButtonDown
|
|
227
183
|
};
|
|
228
184
|
};
|
|
229
185
|
|