@salt-ds/lab 1.0.0-alpha.44 → 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 +32 -84
- package/dist-cjs/calendar/internal/CalendarDay.js +5 -1
- package/dist-cjs/calendar/internal/CalendarDay.js.map +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/useCalendar.js +4 -4
- package/dist-cjs/calendar/useCalendar.js.map +1 -1
- package/dist-cjs/calendar/useSelection.js +4 -0
- package/dist-cjs/calendar/useSelection.js.map +1 -1
- package/dist-cjs/contact-details/ContactPrimaryInfo.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 +3 -0
- package/dist-cjs/index.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/internal/CalendarDay.js +5 -1
- package/dist-es/calendar/internal/CalendarDay.js.map +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/useCalendar.js +5 -5
- 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/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/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/breadcrumbs/internal/BreadcrumbsCollapsed.d.ts +1 -1
- package/dist-types/breadcrumbs/internal/BreadcrumbsSeparator.d.ts +1 -1
- package/dist-types/button-bar/internal/DescendantContext.d.ts +1 -1
- package/dist-types/calendar/useSelection.d.ts +1 -0
- package/dist-types/combo-box-deprecated/internal/MultiSelectComboBox.d.ts +1 -1
- package/dist-types/combo-box-deprecated/internal/useComboBox.d.ts +54 -60
- package/dist-types/combo-box-deprecated/internal/useMultiSelectComboBox.d.ts +165 -182
- package/dist-types/common-hooks/collectionProvider.d.ts +1 -1
- package/dist-types/contact-details/MailLinkComponent.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/form-field-legacy/FormActivationIndicator.d.ts +1 -1
- package/dist-types/form-field-legacy/FormHelperText.d.ts +1 -1
- package/dist-types/form-field-legacy/FormLabel.d.ts +1 -1
- package/dist-types/form-field-legacy/NecessityIndicator.d.ts +1 -1
- package/dist-types/form-field-legacy/StatusIndicator.d.ts +1 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/list-deprecated/internal/DescendantContext.d.ts +1 -1
- package/dist-types/list-deprecated/internal/Highlighter.d.ts +1 -1
- package/dist-types/query-input/internal/CategoryList.d.ts +1 -1
- package/dist-types/query-input/internal/SearchList.d.ts +1 -1
- package/dist-types/query-input/internal/ValueList.d.ts +1 -1
- package/dist-types/query-input/internal/ValueSelector.d.ts +1 -1
- package/dist-types/responsive/overflowUtils.d.ts +1 -1
- package/dist-types/slider/internal/SliderMarkLabels.d.ts +1 -1
- package/dist-types/slider/internal/SliderRail.d.ts +1 -1
- package/dist-types/slider/internal/SliderRailMarks.d.ts +1 -1
- package/dist-types/slider/internal/SliderSelection.d.ts +1 -1
- package/dist-types/stepped-tracker/SteppedTrackerContext.d.ts +2 -2
- package/dist-types/stepped-tracker/TrackerConnector/TrackerConnector.d.ts +1 -1
- package/dist-types/stepper-input/StepperInput.d.ts +43 -12
- package/dist-types/stepper-input/useStepperInput.d.ts +7 -293
- package/dist-types/tabs/TabActivationIndicator.d.ts +1 -1
- package/dist-types/toolbar/Tooltray.d.ts +1 -1
- package/dist-types/tree/TreeNode.d.ts +1 -1
- 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,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var core = require('@salt-ds/core');
|
|
8
|
+
var clsx = require('clsx');
|
|
9
|
+
var DatePickerContext = require('./DatePickerContext.js');
|
|
10
|
+
var DatePickerPanel$1 = require('./DatePickerPanel.css.js');
|
|
11
|
+
var window = require('@salt-ds/window');
|
|
12
|
+
var styles = require('@salt-ds/styles');
|
|
13
|
+
var Calendar = require('../calendar/Calendar.js');
|
|
14
|
+
var date = require('@internationalized/date');
|
|
15
|
+
require('../calendar/internal/CalendarContext.js');
|
|
16
|
+
require('../calendar/internal/utils.js');
|
|
17
|
+
require('../calendar/useSelection.js');
|
|
18
|
+
|
|
19
|
+
const withBaseName = core.makePrefixer("saltDatePickerPanel");
|
|
20
|
+
const DatePickerPanel = React.forwardRef(
|
|
21
|
+
function DatePickerPanel2(props, ref) {
|
|
22
|
+
var _a;
|
|
23
|
+
const { className, onSelect, helperText, CalendarProps: CalendarProps2, ...rest } = props;
|
|
24
|
+
const targetWindow = window.useWindow();
|
|
25
|
+
styles.useComponentCssInjection({
|
|
26
|
+
testId: "salt-date-picker-panel",
|
|
27
|
+
css: DatePickerPanel$1,
|
|
28
|
+
window: targetWindow
|
|
29
|
+
});
|
|
30
|
+
const { Component: FloatingComponent } = core.useFloatingComponent();
|
|
31
|
+
const [hoveredDate, setHoveredDate] = React.useState(null);
|
|
32
|
+
const {
|
|
33
|
+
openState,
|
|
34
|
+
startDate,
|
|
35
|
+
setStartDate,
|
|
36
|
+
startVisibleMonth,
|
|
37
|
+
setStartVisibleMonth,
|
|
38
|
+
endDate,
|
|
39
|
+
setEndDate,
|
|
40
|
+
endVisibleMonth,
|
|
41
|
+
setEndVisibleMonth,
|
|
42
|
+
setOpen,
|
|
43
|
+
selectionVariant,
|
|
44
|
+
context,
|
|
45
|
+
getPanelPosition,
|
|
46
|
+
setValidationStatus
|
|
47
|
+
} = DatePickerContext.useDatePickerContext();
|
|
48
|
+
const { a11yProps } = core.useFormFieldProps();
|
|
49
|
+
const setRangeDate = (_, newDate) => {
|
|
50
|
+
setStartDate(newDate.startDate);
|
|
51
|
+
setEndDate(newDate.endDate);
|
|
52
|
+
setValidationStatus(void 0);
|
|
53
|
+
if (newDate.startDate && newDate.endDate) {
|
|
54
|
+
setOpen(false);
|
|
55
|
+
}
|
|
56
|
+
onSelect == null ? void 0 : onSelect();
|
|
57
|
+
};
|
|
58
|
+
const setSingleDate = (_, newDate) => {
|
|
59
|
+
setStartDate(newDate);
|
|
60
|
+
setValidationStatus(void 0);
|
|
61
|
+
onSelect == null ? void 0 : onSelect();
|
|
62
|
+
setOpen(false);
|
|
63
|
+
};
|
|
64
|
+
const handleHoveredDateChange = (_, newHoveredDate) => {
|
|
65
|
+
setHoveredDate(newHoveredDate);
|
|
66
|
+
};
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (startDate) {
|
|
69
|
+
setStartVisibleMonth(startDate);
|
|
70
|
+
setEndVisibleMonth(startDate.add({ months: 1 }));
|
|
71
|
+
}
|
|
72
|
+
}, [startDate]);
|
|
73
|
+
const isRangePicker = selectionVariant === "range";
|
|
74
|
+
const firstCalendarProps = isRangePicker ? {
|
|
75
|
+
selectionVariant: "range",
|
|
76
|
+
hoveredDate: startDate && hoveredDate && hoveredDate.compare(date.endOfMonth(startDate)) > 0 ? date.endOfMonth(startDate) : hoveredDate,
|
|
77
|
+
onHoveredDateChange: handleHoveredDateChange,
|
|
78
|
+
selectedDate: { startDate, endDate },
|
|
79
|
+
onSelectedDateChange: setRangeDate,
|
|
80
|
+
maxDate: startDate && date.endOfMonth(startDate),
|
|
81
|
+
hideOutOfRangeDates: true
|
|
82
|
+
} : {
|
|
83
|
+
selectionVariant: "default",
|
|
84
|
+
selectedDate: startDate,
|
|
85
|
+
onSelectedDateChange: setSingleDate
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FloatingComponent, {
|
|
88
|
+
open: openState,
|
|
89
|
+
className: clsx.clsx(withBaseName(), className),
|
|
90
|
+
"aria-modal": "true",
|
|
91
|
+
ref,
|
|
92
|
+
focusManagerProps: context ? {
|
|
93
|
+
context,
|
|
94
|
+
initialFocus: 4
|
|
95
|
+
} : void 0,
|
|
96
|
+
...getPanelPosition(),
|
|
97
|
+
...a11yProps,
|
|
98
|
+
...rest,
|
|
99
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(core.StackLayout, {
|
|
100
|
+
separators: true,
|
|
101
|
+
gap: 0,
|
|
102
|
+
className: withBaseName("container"),
|
|
103
|
+
children: [
|
|
104
|
+
helperText && /* @__PURE__ */ jsxRuntime.jsx(core.FlexItem, {
|
|
105
|
+
className: withBaseName("header"),
|
|
106
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(core.FormFieldHelperText, {
|
|
107
|
+
children: helperText
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core.FlexLayout, {
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ jsxRuntime.jsx(Calendar.Calendar, {
|
|
113
|
+
visibleMonth: startVisibleMonth,
|
|
114
|
+
onVisibleMonthChange: (_, month) => setStartVisibleMonth(month),
|
|
115
|
+
...firstCalendarProps,
|
|
116
|
+
...CalendarProps2
|
|
117
|
+
}),
|
|
118
|
+
isRangePicker && /* @__PURE__ */ jsxRuntime.jsx(Calendar.Calendar, {
|
|
119
|
+
selectionVariant: "range",
|
|
120
|
+
hoveredDate,
|
|
121
|
+
onHoveredDateChange: handleHoveredDateChange,
|
|
122
|
+
selectedDate: { startDate, endDate },
|
|
123
|
+
onSelectedDateChange: setRangeDate,
|
|
124
|
+
visibleMonth: endVisibleMonth,
|
|
125
|
+
onVisibleMonthChange: (_, month) => setEndVisibleMonth(month),
|
|
126
|
+
hideOutOfRangeDates: true,
|
|
127
|
+
minDate: startDate ? (_a = date.startOfMonth(startDate)) == null ? void 0 : _a.add({ months: 1 }) : void 0,
|
|
128
|
+
...CalendarProps2
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
exports.DatePickerPanel = DatePickerPanel;
|
|
139
|
+
//# 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":["makePrefixer","forwardRef","DatePickerPanel","CalendarProps","useWindow","useComponentCssInjection","dateInputPanelCss","useFloatingComponent","useState","useDatePickerContext","useFormFieldProps","useEffect","endOfMonth","jsx","clsx","jsxs","StackLayout","FlexItem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EAAA,CAAC,CAAG,EAAA,KAAA,KAAU,qBAAqB,KAAK,CAAA;AAAA,gBAC7D,GAAG,kBAAA;AAAA,gBACH,GAAGjB,cAAAA;AAAA,eACN,CAAA;AAAA,cACC,iCACEU,cAAA,CAAAO,iBAAA,EAAA;AAAA,gBACC,gBAAiB,EAAA,OAAA;AAAA,gBACjB,WAAA;AAAA,gBACA,mBAAqB,EAAA,uBAAA;AAAA,gBACrB,YAAA,EAAc,EAAE,SAAA,EAAW,OAAQ,EAAA;AAAA,gBACnC,oBAAsB,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,GAAAC,iBAAA,CAAa,SAAS,CAAA,KAAtB,mBAAyB,GAAI,CAAA,EAAE,MAAQ,EAAA,CAAA,EACvC,CAAA,GAAA,KAAA,CAAA;AAAA,gBAEL,GAAGlB,cAAAA;AAAA,eACN,CAAA;AAAA,aAAA;AAAA,WAEJ,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
package/dist-cjs/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var ContactFavoriteToggle = require('./contact-details/ContactFavoriteToggle.js'
|
|
|
59
59
|
var MailLinkComponent = require('./contact-details/MailLinkComponent.js');
|
|
60
60
|
var ContentStatus = require('./content-status/ContentStatus.js');
|
|
61
61
|
var DateInput = require('./date-input/DateInput.js');
|
|
62
|
+
var DatePicker = require('./date-picker/DatePicker.js');
|
|
62
63
|
var DeckItem = require('./deck-item/DeckItem.js');
|
|
63
64
|
var DeckLayout = require('./deck-layout/DeckLayout.js');
|
|
64
65
|
var DropdownBase = require('./dropdown/DropdownBase.js');
|
|
@@ -160,6 +161,7 @@ exports.Calendar = Calendar.Calendar;
|
|
|
160
161
|
exports.useCalendarDay = useCalendarDay.useCalendarDay;
|
|
161
162
|
exports.useCalendar = useCalendar.useCalendar;
|
|
162
163
|
exports.isRangeOrOffsetSelectionValue = useSelection.isRangeOrOffsetSelectionValue;
|
|
164
|
+
exports.isRangeOrOffsetSelectionWithStartDate = useSelection.isRangeOrOffsetSelectionWithStartDate;
|
|
163
165
|
exports.useSelectionCalendar = useSelection.useSelectionCalendar;
|
|
164
166
|
exports.useSelectionDay = useSelection.useSelectionDay;
|
|
165
167
|
exports.Carousel = Carousel.Carousel;
|
|
@@ -196,6 +198,7 @@ exports.ContactFavoriteToggle = ContactFavoriteToggle.ContactFavoriteToggle;
|
|
|
196
198
|
exports.MailLinkComponent = MailLinkComponent.MailLinkComponent;
|
|
197
199
|
exports.ContentStatus = ContentStatus.ContentStatus;
|
|
198
200
|
exports.DateInput = DateInput.DateInput;
|
|
201
|
+
exports.DatePicker = DatePicker.DatePicker;
|
|
199
202
|
exports.DeckItem = DeckItem.DeckItem;
|
|
200
203
|
exports.DeckLayout = DeckLayout.DeckLayout;
|
|
201
204
|
exports.DropdownBase = DropdownBase.DropdownBase;
|
package/dist-cjs/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,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
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";
|
|
3
|
+
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";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=TrackerStep.css.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = "
|
|
3
|
+
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";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=StepperInput.css.js.map
|
|
@@ -9,9 +9,6 @@ var core = require('@salt-ds/core');
|
|
|
9
9
|
var styles = require('@salt-ds/styles');
|
|
10
10
|
var window = require('@salt-ds/window');
|
|
11
11
|
var icons = require('@salt-ds/icons');
|
|
12
|
-
var InputLegacy = require('../input-legacy/InputLegacy.js');
|
|
13
|
-
require('../input-legacy/StaticInputAdornment.js');
|
|
14
|
-
var useActivationIndicatorPosition = require('./internal/useActivationIndicatorPosition.js');
|
|
15
12
|
var useStepperInput = require('./useStepperInput.js');
|
|
16
13
|
var StepperInput$1 = require('./StepperInput.css.js');
|
|
17
14
|
|
|
@@ -19,11 +16,13 @@ const withBaseName = core.makePrefixer("saltStepperInput");
|
|
|
19
16
|
const StepperInput = React.forwardRef(
|
|
20
17
|
function StepperInput2(props, ref) {
|
|
21
18
|
const {
|
|
22
|
-
ButtonProps: ButtonPropsProp,
|
|
23
|
-
InputProps: InputPropsProp,
|
|
24
|
-
textAlign = "left",
|
|
25
19
|
className,
|
|
26
|
-
|
|
20
|
+
hideButtons,
|
|
21
|
+
onBlur,
|
|
22
|
+
onChange,
|
|
23
|
+
onFocus,
|
|
24
|
+
readOnly,
|
|
25
|
+
...rest
|
|
27
26
|
} = props;
|
|
28
27
|
const targetWindow = window.useWindow();
|
|
29
28
|
styles.useComponentCssInjection({
|
|
@@ -31,90 +30,42 @@ const StepperInput = React.forwardRef(
|
|
|
31
30
|
css: StepperInput$1,
|
|
32
31
|
window: targetWindow
|
|
33
32
|
});
|
|
34
|
-
const adornmentRef = React.useRef(null);
|
|
35
33
|
const inputRef = React.useRef(null);
|
|
36
|
-
const {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
getInputProps,
|
|
41
|
-
incrementButtonDown,
|
|
42
|
-
isAtMax,
|
|
43
|
-
isAtMin,
|
|
44
|
-
refreshCurrentValue,
|
|
45
|
-
stepperDirection,
|
|
46
|
-
valuesHaveDiverged
|
|
47
|
-
} = useStepperInput.useStepperInput(props, inputRef);
|
|
48
|
-
useActivationIndicatorPosition.useActivationIndicatorPosition(
|
|
49
|
-
adornmentRef,
|
|
50
|
-
valuesHaveDiverged() || showRefreshButton
|
|
51
|
-
);
|
|
52
|
-
const endAdornment = /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
53
|
-
className: withBaseName("adornmentContainer"),
|
|
54
|
-
ref: adornmentRef,
|
|
34
|
+
const { getButtonProps, getInputProps } = useStepperInput.useStepperInput(props, inputRef);
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
36
|
+
className: clsx.clsx(withBaseName(), className),
|
|
37
|
+
ref,
|
|
55
38
|
children: [
|
|
56
|
-
/* @__PURE__ */ jsxRuntime.jsx(core.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
variant: "secondary",
|
|
63
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.RefreshIcon, {
|
|
64
|
-
"aria-label": "refresh"
|
|
65
|
-
})
|
|
39
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Input, {
|
|
40
|
+
onBlur,
|
|
41
|
+
onFocus,
|
|
42
|
+
ref: inputRef,
|
|
43
|
+
readOnly,
|
|
44
|
+
...getInputProps(rest)
|
|
66
45
|
}),
|
|
67
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
46
|
+
!hideButtons && !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
68
47
|
className: withBaseName("buttonContainer"),
|
|
69
48
|
children: [
|
|
70
49
|
/* @__PURE__ */ jsxRuntime.jsx(core.Button, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
active: incrementButtonDown
|
|
76
|
-
}
|
|
77
|
-
),
|
|
78
|
-
disabled: isAtMax(),
|
|
79
|
-
...getButtonProps(stepperDirection.INCREMENT, ButtonPropsProp),
|
|
50
|
+
"aria-label": "increment value",
|
|
51
|
+
className: withBaseName("stepperButton"),
|
|
52
|
+
...getButtonProps("increment"),
|
|
80
53
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleUpIcon, {
|
|
81
|
-
|
|
82
|
-
"aria-label": getButtonIcon(stepperDirection.INCREMENT)
|
|
54
|
+
"aria-hidden": true
|
|
83
55
|
})
|
|
84
56
|
}),
|
|
85
57
|
/* @__PURE__ */ jsxRuntime.jsx(core.Button, {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
active: decrementButtonDown
|
|
91
|
-
}
|
|
92
|
-
),
|
|
93
|
-
disabled: isAtMin(),
|
|
94
|
-
...getButtonProps(stepperDirection.DECREMENT, ButtonPropsProp),
|
|
58
|
+
"aria-label": "decrement value",
|
|
59
|
+
className: withBaseName("stepperButton"),
|
|
60
|
+
...getButtonProps("decrement"),
|
|
95
61
|
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleDownIcon, {
|
|
96
|
-
|
|
97
|
-
"aria-label": getButtonIcon(stepperDirection.DECREMENT)
|
|
62
|
+
"aria-hidden": true
|
|
98
63
|
})
|
|
99
64
|
})
|
|
100
65
|
]
|
|
101
66
|
})
|
|
102
67
|
]
|
|
103
68
|
});
|
|
104
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
105
|
-
className: clsx.clsx(withBaseName(), className),
|
|
106
|
-
onBlur: props.onBlur,
|
|
107
|
-
onFocus: props.onFocus,
|
|
108
|
-
ref,
|
|
109
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(InputLegacy.InputLegacy, {
|
|
110
|
-
className: withBaseName("input"),
|
|
111
|
-
endAdornment,
|
|
112
|
-
highlightOnFocus: true,
|
|
113
|
-
ref: inputRef,
|
|
114
|
-
textAlign,
|
|
115
|
-
...getInputProps(InputPropsProp)
|
|
116
|
-
})
|
|
117
|
-
});
|
|
118
69
|
}
|
|
119
70
|
);
|
|
120
71
|
|
|
@@ -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":["makePrefixer","forwardRef","StepperInput","useWindow","useComponentCssInjection","stepperInputCss","useRef","useStepperInput","jsxs","clsx","jsx","Input","Button","TriangleUpIcon","TriangleDownIcon"],"mappings":";;;;;;;;;;;;;;AAUA,MAAM,YAAA,GAAeA,kBAAa,kBAAkB,CAAA,CAAA;AAsD7C,MAAM,YA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AA,CAAAG,oBAAA,EAAA;AAAA,gBAAe,aAAW,EAAA,IAAA;AAAA,eAAC,CAAA;AAAA,aAC9B,CAAA;AAAA,4BACCH,cAAA,CAAAE,WAAA,EAAA;AAAA,cACC,YAAW,EAAA,iBAAA;AAAA,cACX,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,cACtC,GAAG,eAAe,WAAW,CAAA;AAAA,cAE9B,QAAC,kBAAAF,cAAA,CAAAI,sBAAA,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;;;;"}
|
|
@@ -3,13 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@salt-ds/core');
|
|
6
|
-
var useDynamicAriaLabel = require('./internal/useDynamicAriaLabel.js');
|
|
7
6
|
var useSpinner = require('./internal/useSpinner.js');
|
|
8
7
|
|
|
9
|
-
const stepperDirection = {
|
|
10
|
-
INCREMENT: "increment",
|
|
11
|
-
DECREMENT: "decrement"
|
|
12
|
-
};
|
|
13
8
|
const ACCEPT_INPUT = /^[-+]?[0-9]*\.?([0-9]+)?/g;
|
|
14
9
|
const callAll = (...fns) => (...args) => fns.forEach((fn) => fn && fn(...args));
|
|
15
10
|
const toFixedDecimalPlaces = (inputNumber, decimalPlaces) => inputNumber.toFixed(decimalPlaces);
|
|
@@ -23,27 +18,25 @@ const toFloat = (inputValue) => {
|
|
|
23
18
|
return 0;
|
|
24
19
|
return parseFloat(inputValue.toString());
|
|
25
20
|
};
|
|
26
|
-
const
|
|
27
|
-
const getButtonIcon = (type) => type === stepperDirection.INCREMENT ? "triangle-up" : "triangle-down";
|
|
21
|
+
const sanitizedInput = (numberString) => (numberString.match(ACCEPT_INPUT) || []).join("");
|
|
28
22
|
const useStepperInput = (props, inputRef) => {
|
|
29
23
|
const {
|
|
30
24
|
block = 10,
|
|
31
25
|
decimalPlaces = 0,
|
|
32
26
|
defaultValue = 0,
|
|
33
|
-
|
|
27
|
+
id: idProp,
|
|
34
28
|
max = Number.MAX_SAFE_INTEGER,
|
|
35
29
|
min = Number.MIN_SAFE_INTEGER,
|
|
36
30
|
onChange,
|
|
37
31
|
step = 1,
|
|
38
|
-
value
|
|
39
|
-
InputProps: inputPropsProp = {}
|
|
32
|
+
value
|
|
40
33
|
} = props;
|
|
41
34
|
const [currentValue, setCurrentValue, isControlled] = core.useControlled({
|
|
42
35
|
controlled: value,
|
|
43
36
|
default: toFixedDecimalPlaces(defaultValue, decimalPlaces),
|
|
44
37
|
name: "stepper-input"
|
|
45
38
|
});
|
|
46
|
-
const inputId = core.useId(
|
|
39
|
+
const inputId = core.useId(idProp);
|
|
47
40
|
const isOutOfRange = () => {
|
|
48
41
|
if (currentValue === void 0)
|
|
49
42
|
return true;
|
|
@@ -59,18 +52,6 @@ const useStepperInput = (props, inputRef) => {
|
|
|
59
52
|
return true;
|
|
60
53
|
return toFloat(currentValue) <= min || min === 0 && currentValue === "";
|
|
61
54
|
};
|
|
62
|
-
const valuesHaveDiverged = () => {
|
|
63
|
-
if (liveValue === void 0 || currentValue === void 0)
|
|
64
|
-
return false;
|
|
65
|
-
return toFloat(toFixedDecimalPlaces(liveValue, decimalPlaces)) !== toFloat(currentValue);
|
|
66
|
-
};
|
|
67
|
-
const { setHasAnnounced } = useDynamicAriaLabel.useDynamicAriaLabel(
|
|
68
|
-
", value out of date",
|
|
69
|
-
liveValue !== void 0,
|
|
70
|
-
inputRef,
|
|
71
|
-
currentValue,
|
|
72
|
-
valuesHaveDiverged
|
|
73
|
-
);
|
|
74
55
|
const decrement = () => {
|
|
75
56
|
if (currentValue === void 0 || isAtMin())
|
|
76
57
|
return;
|
|
@@ -104,6 +85,8 @@ const useStepperInput = (props, inputRef) => {
|
|
|
104
85
|
setNextValue(nextValue);
|
|
105
86
|
};
|
|
106
87
|
const setNextValue = (modifiedValue) => {
|
|
88
|
+
if (props.readOnly)
|
|
89
|
+
return;
|
|
107
90
|
let nextValue = modifiedValue;
|
|
108
91
|
if (nextValue < min)
|
|
109
92
|
nextValue = min;
|
|
@@ -137,16 +120,13 @@ const useStepperInput = (props, inputRef) => {
|
|
|
137
120
|
onChange(roundedValue);
|
|
138
121
|
}
|
|
139
122
|
};
|
|
140
|
-
const handleInputFocus = () => {
|
|
141
|
-
setHasAnnounced(false);
|
|
142
|
-
};
|
|
143
123
|
const handleInputChange = (event) => {
|
|
144
|
-
const changedValue = event.
|
|
124
|
+
const changedValue = event.target.value;
|
|
145
125
|
if (!isControlled) {
|
|
146
|
-
setCurrentValue(
|
|
126
|
+
setCurrentValue(sanitizedInput(changedValue));
|
|
147
127
|
}
|
|
148
128
|
if (onChange) {
|
|
149
|
-
onChange(
|
|
129
|
+
onChange(sanitizedInput(changedValue));
|
|
150
130
|
}
|
|
151
131
|
};
|
|
152
132
|
const handleInputKeyDown = (event) => {
|
|
@@ -159,40 +139,21 @@ const useStepperInput = (props, inputRef) => {
|
|
|
159
139
|
event.key === "PageUp" ? incrementSpinnerBlock() : decrementSpinnerBlock();
|
|
160
140
|
}
|
|
161
141
|
};
|
|
162
|
-
const handleButtonMouseDown = (event,
|
|
142
|
+
const handleButtonMouseDown = (event, direction) => {
|
|
163
143
|
if (event.nativeEvent.button !== 0)
|
|
164
144
|
return;
|
|
165
|
-
|
|
145
|
+
direction === "increment" ? incrementSpinner() : decrementSpinner();
|
|
166
146
|
};
|
|
167
147
|
const handleButtonMouseUp = () => {
|
|
168
148
|
var _a;
|
|
169
149
|
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
170
150
|
};
|
|
171
|
-
const
|
|
172
|
-
var _a;
|
|
173
|
-
const refreshedcurrentValue = liveValue !== void 0 ? liveValue : defaultValue;
|
|
174
|
-
if (refreshedcurrentValue === void 0)
|
|
175
|
-
return;
|
|
176
|
-
setCurrentValue(
|
|
177
|
-
toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)
|
|
178
|
-
);
|
|
179
|
-
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
180
|
-
if (onChange) {
|
|
181
|
-
onChange(
|
|
182
|
-
toFixedDecimalPlaces(toFloat(refreshedcurrentValue), decimalPlaces)
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
const getButtonProps = (type = stepperDirection.INCREMENT, buttonPropsProp = {}) => ({
|
|
151
|
+
const getButtonProps = (direction) => ({
|
|
187
152
|
"aria-hidden": true,
|
|
188
|
-
"
|
|
153
|
+
disabled: props.disabled || (direction === "increment" ? isAtMax() : isAtMin()),
|
|
189
154
|
tabIndex: -1,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
(event) => handleButtonMouseDown(event, type),
|
|
193
|
-
buttonPropsProp.onMouseDown
|
|
194
|
-
),
|
|
195
|
-
onMouseUp: callAll(() => handleButtonMouseUp(), buttonPropsProp.onMouseUp)
|
|
155
|
+
onMouseDown: (event) => handleButtonMouseDown(event, direction),
|
|
156
|
+
onMouseUp: handleButtonMouseUp
|
|
196
157
|
});
|
|
197
158
|
const getInputProps = (inputProps = {}) => {
|
|
198
159
|
if (currentValue === void 0)
|
|
@@ -212,22 +173,17 @@ const useStepperInput = (props, inputRef) => {
|
|
|
212
173
|
},
|
|
213
174
|
onBlur: callAll(inputProps.onBlur, handleInputBlur),
|
|
214
175
|
onChange: callAll(inputProps.onChange, handleInputChange),
|
|
215
|
-
onFocus:
|
|
216
|
-
onKeyDown: callAll(inputProps.
|
|
176
|
+
onFocus: inputProps.onFocus,
|
|
177
|
+
onKeyDown: callAll(inputProps.onKeyDown, handleInputKeyDown),
|
|
178
|
+
textAlign: inputProps.textAlign,
|
|
217
179
|
value: String(currentValue)
|
|
218
180
|
};
|
|
219
181
|
};
|
|
220
182
|
return {
|
|
221
183
|
decrementButtonDown: arrowDownButtonDown || pgDnButtonDown,
|
|
222
|
-
getButtonIcon,
|
|
223
184
|
getButtonProps,
|
|
224
185
|
getInputProps,
|
|
225
|
-
incrementButtonDown: arrowUpButtonDown || pgUpButtonDown
|
|
226
|
-
isAtMax,
|
|
227
|
-
isAtMin,
|
|
228
|
-
refreshCurrentValue,
|
|
229
|
-
stepperDirection,
|
|
230
|
-
valuesHaveDiverged
|
|
186
|
+
incrementButtonDown: arrowUpButtonDown || pgUpButtonDown
|
|
231
187
|
};
|
|
232
188
|
};
|
|
233
189
|
|