xmlui 0.10.8 → 0.10.11
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/{metadata/apiInterceptorWorker-Bb5-fQup.mjs → lib/apiInterceptorWorker-DPgtUtdA.mjs} +5870 -3195
- package/dist/lib/index-BuIblMfO.mjs +50034 -0
- package/dist/lib/index.css +1 -1
- package/dist/lib/initMock-CV-9AUzP.mjs +843 -0
- package/dist/lib/language-server-web-worker.mjs +8 -7
- package/dist/lib/language-server.mjs +6 -6
- package/dist/lib/{metadata-utils-DrEexTX9.mjs → metadata-utils-DzONZF-e.mjs} +161 -111
- package/dist/lib/scss/components-core/theming/_themes.scss +6 -7
- package/dist/lib/{server-common-ddmPKhK6.mjs → server-common-Dsyp3-Ro.mjs} +14949 -10880
- package/dist/lib/syntax-monaco.mjs +14 -11
- package/dist/lib/syntax-textmate.d.ts +2 -2
- package/dist/lib/syntax-textmate.mjs +128 -109
- package/dist/lib/transform-CBz7TQJh.mjs +7375 -0
- package/dist/lib/xmlui-parser.d.ts +3 -3
- package/dist/lib/xmlui-parser.mjs +49 -49
- package/dist/lib/xmlui-serializer-Bf9bdvlV.mjs +667 -0
- package/dist/lib/xmlui.d.ts +16 -11
- package/dist/lib/xmlui.mjs +44 -44
- package/dist/{lib/apiInterceptorWorker-DH8wqOVq.mjs → metadata/apiInterceptorWorker-BmKP8bnq.mjs} +5432 -3502
- package/dist/metadata/collectedComponentMetadata-Cdi6AFD3.mjs +55851 -0
- package/dist/metadata/initMock-B7OlSKKb.mjs +843 -0
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +3 -3
- package/dist/metadata/xmlui-metadata.umd.js +207 -419
- package/dist/scripts/package.json +3 -1
- package/dist/scripts/src/components/APICall/APICall.js +4 -4
- package/dist/scripts/src/components/Accordion/Accordion.js +1 -1
- package/dist/scripts/src/components/Accordion/AccordionItemNative.js +2 -2
- package/dist/scripts/src/components/Animation/AnimationNative.js +259 -0
- package/dist/scripts/src/components/App/App.js +10 -0
- package/dist/scripts/src/components/App/AppNative.js +29 -9
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +5 -4
- package/dist/scripts/src/components/Breakout/BreakoutNative.js +2 -2
- package/dist/scripts/src/components/Button/Button.js +1 -1
- package/dist/scripts/src/components/Button/ButtonNative.js +4 -0
- package/dist/scripts/src/components/Carousel/Carousel.js +13 -20
- package/dist/scripts/src/components/Carousel/CarouselContext.js +11 -2
- package/dist/scripts/src/components/Carousel/CarouselItemNative.js +2 -2
- package/dist/scripts/src/components/Carousel/CarouselNative.js +2 -2
- package/dist/scripts/src/components/Charts/AreaChart/AreaChart.js +92 -0
- package/dist/scripts/src/components/Charts/AreaChart/AreaChartNative.js +127 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChart.js +4 -4
- package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +90 -82
- package/dist/scripts/src/components/Charts/LineChart/LineChart.js +3 -3
- package/dist/scripts/src/components/Charts/LineChart/LineChartNative.js +5 -1
- package/dist/scripts/src/components/Charts/RadarChart/RadarChart.js +92 -0
- package/dist/scripts/src/components/Charts/RadarChart/RadarChartNative.js +125 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +2 -1
- package/dist/scripts/src/components/ComponentProvider.js +4 -0
- package/dist/scripts/src/components/DataSource/DataSource.js +124 -0
- package/dist/scripts/src/components/DateInput/DateInput.js +7 -9
- package/dist/scripts/src/components/DateInput/DateInputNative.js +101 -38
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/scripts/src/components/ExpandableItem/ExpandableItemNative.js +18 -12
- package/dist/scripts/src/components/Footer/Footer.js +1 -1
- package/dist/scripts/src/components/FormItem/FormItem.js +1 -1
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +3 -3
- package/dist/scripts/src/components/Heading/Heading.js +83 -28
- package/dist/scripts/src/components/Heading/HeadingNative.js +10 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +1 -1
- package/dist/scripts/src/components/Image/ImageNative.js +13 -0
- package/dist/scripts/src/components/Input/PartialInput.js +28 -3
- package/dist/scripts/src/components/List/ListNative.js +6 -5
- package/dist/scripts/src/components/NavLink/NavLink.js +1 -1
- package/dist/scripts/src/components/NavPanel/NavPanelNative.js +3 -8
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +2 -2
- package/dist/scripts/src/components/Option/OptionNative.js +12 -1
- package/dist/scripts/src/components/Pagination/Pagination.js +2 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +7 -3
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +20 -5
- package/dist/scripts/src/components/RadioGroup/RadioItemNative.js +2 -1
- package/dist/scripts/src/components/Select/Select.js +1 -1
- package/dist/scripts/src/components/Select/SelectNative.js +1 -1
- package/dist/scripts/src/components/Slider/Slider.js +10 -8
- package/dist/scripts/src/components/Slider/SliderNative.js +24 -21
- package/dist/scripts/src/components/Switch/Switch.js +2 -1
- package/dist/scripts/src/components/Table/Table.js +1 -1
- package/dist/scripts/src/components/Table/TableNative.js +18 -13
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -1
- package/dist/scripts/src/components/Text/Text.js +32 -14
- package/dist/scripts/src/components/Text/TextNative.js +17 -5
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +3 -3
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +3 -3
- package/dist/scripts/src/components/TimeInput/TimeInput.js +10 -10
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +87 -38
- package/dist/scripts/src/components/Toggle/Toggle.js +2 -2
- package/dist/scripts/src/components/Tooltip/Tooltip.js +9 -9
- package/dist/scripts/src/components/Tooltip/TooltipNative.js +4 -4
- package/dist/scripts/src/components/abstractions.js +7 -3
- package/dist/scripts/src/components/collectedComponentMetadata.js +316 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +3 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +823 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +4 -1
- package/dist/scripts/src/components-core/interception/Backend.js +13 -7
- package/dist/scripts/src/components-core/markup-check.js +279 -0
- package/dist/scripts/src/components-core/parts.js +0 -4
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +36 -16
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +4 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +4 -1
- package/dist/scripts/src/components-core/theming/themes/root.js +30 -17
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +14 -7
- package/dist/scripts/src/components-core/xmlui-parser.js +60 -43
- package/dist/scripts/src/index.js +120 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +15 -4
- package/dist/standalone/xmlui-standalone.es.d.ts +23 -15
- package/dist/standalone/xmlui-standalone.umd.js +319 -823
- package/package.json +3 -1
- package/src/syntax/textMate/xmlui.tmLanguage.json +2 -2
- package/dist/lib/index-CqzCWOUw.mjs +0 -38579
- package/dist/lib/initMock-C5CXs0-5.mjs +0 -568
- package/dist/lib/transform-SMWeyMoq.mjs +0 -5391
- package/dist/lib/xmlui-serializer-a0O0jFY-.mjs +0 -497
- package/dist/metadata/collectedComponentMetadata-DIT5VbaH.mjs +0 -42985
- package/dist/metadata/initMock-D6Vi9kU_.mjs +0 -568
- package/dist/scripts/src/components-core/ScrollContext.js +0 -11
- package/dist/scripts/src/components-core/utils/audio-utils.js +0 -83
|
@@ -88,11 +88,6 @@ exports.TimeInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
88
88
|
"set, the gap declared by the current theme is used.",
|
|
89
89
|
valueType: "string",
|
|
90
90
|
},
|
|
91
|
-
mute: {
|
|
92
|
-
description: "Whether to mute the beep sound while still firing the beep event",
|
|
93
|
-
valueType: "boolean",
|
|
94
|
-
defaultValue: TimeInputNative_1.defaultProps.mute,
|
|
95
|
-
},
|
|
96
91
|
emptyCharacter: {
|
|
97
92
|
description: "Character to use as placeholder for empty time values. If longer than 1 character, uses the first character. Defaults to '-'",
|
|
98
93
|
valueType: "string",
|
|
@@ -104,7 +99,6 @@ exports.TimeInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
104
99
|
gotFocus: (0, metadata_helpers_1.dGotFocus)(COMP),
|
|
105
100
|
lostFocus: (0, metadata_helpers_1.dLostFocus)(COMP),
|
|
106
101
|
invalidTime: (0, metadata_helpers_1.d)("Fired when the user enters an invalid time"),
|
|
107
|
-
beep: (0, metadata_helpers_1.d)("Fired when a beep sound is played due to invalid input, allowing custom feedback implementations"),
|
|
108
102
|
},
|
|
109
103
|
apis: {
|
|
110
104
|
focus: {
|
|
@@ -122,10 +116,16 @@ exports.TimeInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
122
116
|
value: "The new time value to set for the time picker.",
|
|
123
117
|
},
|
|
124
118
|
},
|
|
119
|
+
isoValue: {
|
|
120
|
+
description: `Get the current time value formatted in ISO standard (HH:MM:SS) using 24-hour format, suitable for JSON serialization.`,
|
|
121
|
+
signature: "isoValue(): string | null",
|
|
122
|
+
},
|
|
125
123
|
},
|
|
126
124
|
themeVars: (0, themeVars_1.parseScssVar)(TimeInput_module_scss_1.default.themeVars),
|
|
127
125
|
defaultThemeVars: {
|
|
128
126
|
// TimeInput specific theme variables
|
|
127
|
+
[`paddingHorizontal-${COMP}`]: "$space-2",
|
|
128
|
+
[`paddingVertical-${COMP}`]: "$space-2",
|
|
129
129
|
[`color-divider-${COMP}`]: "$textColor-secondary",
|
|
130
130
|
[`spacing-divider-${COMP}`]: "1px 0",
|
|
131
131
|
[`width-input-${COMP}`]: "1.8em",
|
|
@@ -135,19 +135,19 @@ exports.TimeInputMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
135
135
|
[`fontSize-input-${COMP}`]: "inherit",
|
|
136
136
|
[`borderRadius-input-${COMP}`]: "$borderRadius",
|
|
137
137
|
[`backgroundColor-input-${COMP}-invalid`]: "rgba(220, 53, 69, 0.15)",
|
|
138
|
-
[`padding-button-${COMP}`]: "4px
|
|
138
|
+
[`padding-button-${COMP}`]: "4px 4px",
|
|
139
139
|
[`borderRadius-button-${COMP}`]: "$borderRadius",
|
|
140
140
|
[`hoverColor-button-${COMP}`]: "$color-surface-800",
|
|
141
141
|
[`disabledColor-button-${COMP}`]: "$textColor-disabled",
|
|
142
142
|
[`outlineColor-button-${COMP}--focused`]: "$color-accent-500",
|
|
143
143
|
[`outlineWidth-button-${COMP}--focused`]: "2px",
|
|
144
|
-
[`outlineOffset-button-${COMP}--focused`]: "
|
|
145
|
-
[`minWidth-ampm-${COMP}`]: "2em",
|
|
144
|
+
[`outlineOffset-button-${COMP}--focused`]: "0",
|
|
145
|
+
[`minWidth-ampm-${COMP}`]: "2.2em",
|
|
146
146
|
[`fontSize-ampm-${COMP}`]: "inherit",
|
|
147
147
|
},
|
|
148
148
|
});
|
|
149
149
|
exports.timeInputComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.TimeInputMd, ({ node, state, updateState, extractValue, className, lookupEventHandler, registerComponentApi, }) => {
|
|
150
150
|
const extractedInitialValue = extractValue(node.props.initialValue);
|
|
151
151
|
const stateValue = state === null || state === void 0 ? void 0 : state.value;
|
|
152
|
-
return ((0, jsx_runtime_1.jsx)(TimeInputNative_1.TimeInputNative, { className: className, initialValue: extractedInitialValue, value: stateValue, updateState: updateState, registerComponentApi: registerComponentApi, enabled: extractValue.asOptionalBoolean(node.props.enabled, TimeInputNative_1.defaultProps.enabled), autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus, TimeInputNative_1.defaultProps.autoFocus), readOnly: extractValue.asOptionalBoolean(node.props.readOnly, TimeInputNative_1.defaultProps.readOnly), validationStatus: extractValue(node.props.validationStatus), hour24: extractValue.asOptionalBoolean(node.props.hour24, TimeInputNative_1.defaultProps.hour24), seconds: extractValue.asOptionalBoolean(node.props.seconds, TimeInputNative_1.defaultProps.seconds), minTime: extractValue(node.props.minTime), maxTime: extractValue(node.props.maxTime), clearable: extractValue.asOptionalBoolean(node.props.clearable, TimeInputNative_1.defaultProps.clearable), clearIcon: extractValue(node.props.clearIcon), clearToInitialValue: extractValue.asOptionalBoolean(node.props.clearToInitialValue, TimeInputNative_1.defaultProps.clearToInitialValue), required: extractValue.asOptionalBoolean(node.props.required, TimeInputNative_1.defaultProps.required), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak, TimeInputNative_1.defaultProps.labelBreak), startText: extractValue(node.props.startText), startIcon: extractValue(node.props.startIcon), endText: extractValue(node.props.endText), endIcon: extractValue(node.props.endIcon), gap: extractValue.asOptionalString(node.props.gap),
|
|
152
|
+
return ((0, jsx_runtime_1.jsx)(TimeInputNative_1.TimeInputNative, { className: className, initialValue: extractedInitialValue, value: stateValue, updateState: updateState, registerComponentApi: registerComponentApi, enabled: extractValue.asOptionalBoolean(node.props.enabled, TimeInputNative_1.defaultProps.enabled), autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus, TimeInputNative_1.defaultProps.autoFocus), readOnly: extractValue.asOptionalBoolean(node.props.readOnly, TimeInputNative_1.defaultProps.readOnly), validationStatus: extractValue(node.props.validationStatus), hour24: extractValue.asOptionalBoolean(node.props.hour24, TimeInputNative_1.defaultProps.hour24), seconds: extractValue.asOptionalBoolean(node.props.seconds, TimeInputNative_1.defaultProps.seconds), minTime: extractValue(node.props.minTime), maxTime: extractValue(node.props.maxTime), clearable: extractValue.asOptionalBoolean(node.props.clearable, TimeInputNative_1.defaultProps.clearable), clearIcon: extractValue(node.props.clearIcon), clearToInitialValue: extractValue.asOptionalBoolean(node.props.clearToInitialValue, TimeInputNative_1.defaultProps.clearToInitialValue), required: extractValue.asOptionalBoolean(node.props.required, TimeInputNative_1.defaultProps.required), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak, TimeInputNative_1.defaultProps.labelBreak), startText: extractValue(node.props.startText), startIcon: extractValue(node.props.startIcon), endText: extractValue(node.props.endText), endIcon: extractValue(node.props.endIcon), gap: extractValue.asOptionalString(node.props.gap), emptyCharacter: extractValue.asOptionalString(node.props.emptyCharacter, TimeInputNative_1.defaultProps.emptyCharacter), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), onInvalidChange: lookupEventHandler("invalidTime") }));
|
|
153
153
|
});
|
|
@@ -22,13 +22,11 @@ const TimeInput_module_scss_1 = __importDefault(require("./TimeInput.module.scss
|
|
|
22
22
|
const PartialInput_1 = require("../Input/PartialInput");
|
|
23
23
|
const InputDivider_1 = require("../Input/InputDivider");
|
|
24
24
|
const misc_1 = require("../../components-core/utils/misc");
|
|
25
|
-
const audio_utils_1 = require("../../components-core/utils/audio-utils");
|
|
26
25
|
const InputAdornment_1 = require("../Input/InputAdornment");
|
|
27
26
|
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
28
27
|
const IconNative_1 = __importDefault(require("../Icon/IconNative"));
|
|
29
28
|
// Import utilities and types from merged utils file
|
|
30
29
|
const utils_1 = require("./utils");
|
|
31
|
-
const parts_1 = require("../../components-core/parts");
|
|
32
30
|
// Component part names
|
|
33
31
|
const PART_HOUR = "hour";
|
|
34
32
|
const PART_MINUTE = "minute";
|
|
@@ -47,11 +45,10 @@ exports.defaultProps = {
|
|
|
47
45
|
readOnly: false,
|
|
48
46
|
autoFocus: false,
|
|
49
47
|
labelBreak: false,
|
|
50
|
-
mute: false,
|
|
51
48
|
emptyCharacter: "-",
|
|
52
49
|
};
|
|
53
50
|
exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, ref) {
|
|
54
|
-
var { id, initialValue, value: controlledValue, enabled = exports.defaultProps.enabled, updateState, style, className, onDidChange, onFocus, onBlur, onInvalidChange,
|
|
51
|
+
var { id, initialValue, value: controlledValue, enabled = exports.defaultProps.enabled, updateState, style, className, onDidChange, onFocus, onBlur, onInvalidChange, validationStatus = exports.defaultProps.validationStatus, registerComponentApi, hour24 = exports.defaultProps.hour24, seconds = exports.defaultProps.seconds, minTime, maxTime, clearable = exports.defaultProps.clearable, clearIcon, clearToInitialValue = exports.defaultProps.clearToInitialValue, required = exports.defaultProps.required, startText, startIcon, endText, endIcon, gap, label, labelPosition = exports.defaultProps.labelPosition, labelWidth, labelBreak = exports.defaultProps.labelBreak, readOnly = exports.defaultProps.readOnly, autoFocus = exports.defaultProps.autoFocus, emptyCharacter = exports.defaultProps.emptyCharacter } = _a, rest = __rest(_a, ["id", "initialValue", "value", "enabled", "updateState", "style", "className", "onDidChange", "onFocus", "onBlur", "onInvalidChange", "validationStatus", "registerComponentApi", "hour24", "seconds", "minTime", "maxTime", "clearable", "clearIcon", "clearToInitialValue", "required", "startText", "startIcon", "endText", "endIcon", "gap", "label", "labelPosition", "labelWidth", "labelBreak", "readOnly", "autoFocus", "emptyCharacter"]);
|
|
55
52
|
const timeInputRef = (0, react_1.useRef)(null);
|
|
56
53
|
// Refs for auto-tabbing between inputs
|
|
57
54
|
const hourInputRef = (0, react_1.useRef)(null);
|
|
@@ -105,7 +102,7 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
105
102
|
// Parse value into individual components
|
|
106
103
|
(0, react_1.useEffect)(() => {
|
|
107
104
|
if (localValue) {
|
|
108
|
-
const { amPm: parsedAmPm, hour: hourStr, minute: minuteStr, second: secondStr, } = parseTimeString(
|
|
105
|
+
const { amPm: parsedAmPm, hour: hourStr, minute: minuteStr, second: secondStr, } = parseTimeString(localValue, is12HourFormat);
|
|
109
106
|
setAmPm(parsedAmPm);
|
|
110
107
|
setHour(hourStr);
|
|
111
108
|
setMinute(minuteStr);
|
|
@@ -128,15 +125,6 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
128
125
|
}
|
|
129
126
|
onDidChange === null || onDidChange === void 0 ? void 0 : onDidChange(newValue);
|
|
130
127
|
});
|
|
131
|
-
// Method to handle beeping - both sound and event
|
|
132
|
-
const handleBeep = (0, react_1.useCallback)(() => {
|
|
133
|
-
// Play the beep sound only if not muted
|
|
134
|
-
if (!mute) {
|
|
135
|
-
(0, audio_utils_1.beep)(440, 50);
|
|
136
|
-
}
|
|
137
|
-
// Always fire the beep event for alternative implementations
|
|
138
|
-
onBeep === null || onBeep === void 0 ? void 0 : onBeep();
|
|
139
|
-
}, [onBeep, mute]);
|
|
140
128
|
// Helper function to format the complete time value
|
|
141
129
|
const formatTimeValue = (0, react_1.useCallback)((h, m, s, ap, is12Hour) => {
|
|
142
130
|
if (!h || !m) {
|
|
@@ -184,10 +172,6 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
184
172
|
const normalizedValue = normalizeFn(currentValue);
|
|
185
173
|
// Check if the current value was invalid (needed normalization or couldn't be normalized)
|
|
186
174
|
const wasInvalid = currentValue !== "" && (normalizedValue === null || normalizedValue !== currentValue);
|
|
187
|
-
if (wasInvalid) {
|
|
188
|
-
// Play beep sound and fire beep event when manually tabbing out of invalid input
|
|
189
|
-
handleBeep();
|
|
190
|
-
}
|
|
191
175
|
if (normalizedValue !== null && normalizedValue !== currentValue) {
|
|
192
176
|
setValue(normalizedValue);
|
|
193
177
|
setInvalid(false); // Clear invalid state after normalization
|
|
@@ -214,7 +198,7 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
214
198
|
const timeString = formatTimeValue(timeValues.hour, timeValues.minute, timeValues.second, amPm, is12HourFormat);
|
|
215
199
|
handleChange(timeString);
|
|
216
200
|
}
|
|
217
|
-
}, [hour, minute, second, amPm, is12HourFormat, handleChange
|
|
201
|
+
}, [hour, minute, second, amPm, is12HourFormat, handleChange]);
|
|
218
202
|
// Handle changes from individual inputs
|
|
219
203
|
const handleHourChange = (0, react_1.useMemo)(() => createInputChangeHandler("hour", setHour, setIsHourCurrentlyInvalid, (value) => isHourInvalid(value, !is12HourFormat)), [createInputChangeHandler, is12HourFormat]);
|
|
220
204
|
const handleHourBlur = (0, react_1.useMemo)(() => createInputBlurHandler("hour", setHour, setIsHourCurrentlyInvalid, (value) => normalizeHour(value, !is12HourFormat)), [createInputBlurHandler, is12HourFormat]);
|
|
@@ -283,7 +267,9 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
283
267
|
amPmButtonRef.current.focus();
|
|
284
268
|
}
|
|
285
269
|
}
|
|
286
|
-
else if (currentTarget === secondInputRef.current &&
|
|
270
|
+
else if (currentTarget === secondInputRef.current &&
|
|
271
|
+
is12HourFormat &&
|
|
272
|
+
amPmButtonRef.current) {
|
|
287
273
|
amPmButtonRef.current.focus();
|
|
288
274
|
}
|
|
289
275
|
}
|
|
@@ -361,6 +347,32 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
361
347
|
const setValue = (0, misc_1.useEvent)((newValue) => {
|
|
362
348
|
handleChange(newValue);
|
|
363
349
|
});
|
|
350
|
+
// Function to get ISO formatted time value (HH:MM:SS in 24-hour format)
|
|
351
|
+
const getIsoValue = (0, react_1.useCallback)(() => {
|
|
352
|
+
if (!hour || !minute) {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
// Convert to 24-hour format if currently in 12-hour format
|
|
356
|
+
let hour24;
|
|
357
|
+
if (is12HourFormat && amPm) {
|
|
358
|
+
const hourInt = parseInt(hour, 10);
|
|
359
|
+
if (amPm === "am") {
|
|
360
|
+
hour24 = hourInt === 12 ? 0 : hourInt;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
// pm
|
|
364
|
+
hour24 = hourInt === 12 ? 12 : hourInt + 12;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
hour24 = parseInt(hour, 10);
|
|
369
|
+
}
|
|
370
|
+
// Format as ISO time string (HH:MM:SS)
|
|
371
|
+
const h24 = hour24.toString().padStart(2, "0");
|
|
372
|
+
const m24 = minute.padStart(2, "0");
|
|
373
|
+
const s24 = (second || "00").padStart(2, "0");
|
|
374
|
+
return `${h24}:${m24}:${s24}`;
|
|
375
|
+
}, [hour, minute, second, amPm, is12HourFormat]);
|
|
364
376
|
// Component API registration
|
|
365
377
|
(0, react_1.useImperativeHandle)(ref, () => timeInputRef.current);
|
|
366
378
|
(0, react_1.useEffect)(() => {
|
|
@@ -368,9 +380,10 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
368
380
|
registerComponentApi({
|
|
369
381
|
focus,
|
|
370
382
|
setValue,
|
|
383
|
+
isoValue: getIsoValue,
|
|
371
384
|
});
|
|
372
385
|
}
|
|
373
|
-
}, [registerComponentApi, focus, setValue]);
|
|
386
|
+
}, [registerComponentApi, focus, setValue, getIsoValue]);
|
|
374
387
|
// Custom clear icon
|
|
375
388
|
const clearIconElement = (0, react_1.useMemo)(() => {
|
|
376
389
|
if (clearIcon === null || clearIcon === "null")
|
|
@@ -393,15 +406,13 @@ exports.TimeInputNative = (0, react_1.forwardRef)(function TimeInputNative(_a, r
|
|
|
393
406
|
}
|
|
394
407
|
return null;
|
|
395
408
|
}, [endIcon, endText]);
|
|
396
|
-
// Create placeholder using processed empty character
|
|
397
|
-
const placeholder = processedEmptyCharacter.repeat(2);
|
|
398
409
|
const timeInputComponent = ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: timeInputRef, className: (0, classnames_1.default)(TimeInput_module_scss_1.default.timeInputWrapper, {
|
|
399
410
|
[TimeInput_module_scss_1.default.error]: validationStatus === "error",
|
|
400
411
|
[TimeInput_module_scss_1.default.warning]: validationStatus === "warning",
|
|
401
412
|
[TimeInput_module_scss_1.default.valid]: validationStatus === "valid",
|
|
402
413
|
[TimeInput_module_scss_1.default.disabled]: !enabled,
|
|
403
414
|
[TimeInput_module_scss_1.default.readOnly]: readOnly,
|
|
404
|
-
}, className), style: Object.assign(Object.assign({}, style), { gap }), onFocusCapture: handleComponentFocus, onBlur: handleComponentBlur, "data-validation-status": validationStatus }, rest, { children: [startAdornment, (0, jsx_runtime_1.jsxs)("div", { className: TimeInput_module_scss_1.default.wrapper, children: [(0, jsx_runtime_1.jsxs)("div", { className: TimeInput_module_scss_1.default.inputGroup, children: [(0, jsx_runtime_1.jsx)(HourInput, { amPm: amPm, autoFocus: autoFocus, disabled: !enabled, inputRef: hourInputRef, nextInputRef: minuteInputRef, maxTime: maxTime, minTime: minTime, onChange: handleHourChange, onBlur: handleHourBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: hour, isInvalid: isHourCurrentlyInvalid, is24Hour: !is12HourFormat, emptyCharacter: processedEmptyCharacter
|
|
415
|
+
}, className), style: Object.assign(Object.assign({}, style), { gap }), onFocusCapture: handleComponentFocus, onBlur: handleComponentBlur, "data-validation-status": validationStatus }, rest, { children: [startAdornment, (0, jsx_runtime_1.jsxs)("div", { className: TimeInput_module_scss_1.default.wrapper, children: [(0, jsx_runtime_1.jsxs)("div", { className: TimeInput_module_scss_1.default.inputGroup, children: [(0, jsx_runtime_1.jsx)(HourInput, { amPm: amPm, autoFocus: autoFocus, disabled: !enabled, inputRef: hourInputRef, nextInputRef: minuteInputRef, maxTime: maxTime, minTime: minTime, onChange: handleHourChange, onBlur: handleHourBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, value: hour, isInvalid: isHourCurrentlyInvalid, is24Hour: !is12HourFormat, emptyCharacter: processedEmptyCharacter }), (0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: ":" }), (0, jsx_runtime_1.jsx)(MinuteInput, { disabled: !enabled, hour: hour, inputRef: minuteInputRef, nextInputRef: showSeconds ? secondInputRef : undefined, nextButtonRef: showSeconds ? undefined : is12HourFormat ? amPmButtonRef : undefined, maxTime: maxTime, minTime: minTime, onChange: handleMinuteChange, onBlur: handleMinuteBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, showLeadingZeros: showLeadingZeros, value: minute, isInvalid: isMinuteCurrentlyInvalid, emptyCharacter: processedEmptyCharacter }), showSeconds && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(InputDivider_1.InputDivider, { separator: ":", className: TimeInput_module_scss_1.default.divider }), (0, jsx_runtime_1.jsx)(SecondInput, { disabled: !enabled, hour: hour, inputRef: secondInputRef, nextButtonRef: is12HourFormat ? amPmButtonRef : undefined, maxTime: maxTime, minTime: minTime, minute: minute, onChange: handleSecondChange, onBlur: handleSecondBlur, onKeyDown: handleArrowKeys, readOnly: readOnly, required: required, showLeadingZeros: showLeadingZeros, value: second, isInvalid: isSecondCurrentlyInvalid, emptyCharacter: processedEmptyCharacter })] })), is12HourFormat && ((0, jsx_runtime_1.jsx)(AmPmButton, { className: "timeinput", disabled: !enabled, buttonRef: amPmButtonRef, maxTime: maxTime, minTime: minTime, onClick: handleAmPmToggle, onAmPmSet: handleAmPmSet, onKeyDown: handleArrowKeys, value: amPm }))] }), clearable && ((0, jsx_runtime_1.jsx)("button", { "data-part-id": PART_CLEAR_BUTTON, className: (0, classnames_1.default)(TimeInput_module_scss_1.default.clearButton, TimeInput_module_scss_1.default.button), disabled: !enabled, onClick: clear, onFocus: stopPropagation, type: "button", children: clearIconElement }))] }), endAdornment] })));
|
|
405
416
|
// Wrap with label if needed
|
|
406
417
|
if (label) {
|
|
407
418
|
return ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { label: label, labelPosition: labelPosition, labelWidth: labelWidth, labelBreak: labelBreak, required: required, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [startAdornment, timeInputComponent, endAdornment] }) }));
|
|
@@ -434,10 +445,10 @@ function AmPmButton({ ariaLabel, autoFocus, className, disabled, locale, maxTime
|
|
|
434
445
|
onAmPmSet("pm");
|
|
435
446
|
}
|
|
436
447
|
}, [onKeyDown, disabled, onAmPmSet, value, amDisabled, pmDisabled]);
|
|
437
|
-
return ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": ariaLabel || "Toggle AM/PM (Press A for AM, P for PM)", autoFocus: autoFocus, className: (0, classnames_1.default)(
|
|
448
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-part-id": PART_AMPM, "aria-label": ariaLabel || "Toggle AM/PM (Press A for AM, P for PM)", autoFocus: autoFocus, className: (0, classnames_1.default)(TimeInput_module_scss_1.default.amPmButton, TimeInput_module_scss_1.default.button, className), disabled: isDisabled, onClick: onClick, onKeyDown: handleKeyDown, ref: buttonRef, children: (0, jsx_runtime_1.jsx)("span", { className: TimeInput_module_scss_1.default.amPmValue, children: value ? (value === "am" ? amLabel : pmLabel) : "--" }) }));
|
|
438
449
|
}
|
|
439
450
|
function HourInput(_a) {
|
|
440
|
-
var { amPm, maxTime, minTime, value, isInvalid = false, is24Hour = false, emptyCharacter = "-"
|
|
451
|
+
var { amPm, maxTime, minTime, value, isInvalid = false, is24Hour = false, emptyCharacter = "-" } = _a, otherProps = __rest(_a, ["amPm", "maxTime", "minTime", "value", "isInvalid", "is24Hour", "emptyCharacter"]);
|
|
441
452
|
// Calculate min/max based on format
|
|
442
453
|
const { minHour, maxHour } = (() => {
|
|
443
454
|
if (is24Hour) {
|
|
@@ -476,52 +487,90 @@ function HourInput(_a) {
|
|
|
476
487
|
// Always show the raw value during typing, no conversion
|
|
477
488
|
// This allows users to see invalid input like "23" before it gets normalized on blur
|
|
478
489
|
const displayValue = value || "";
|
|
479
|
-
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { value: displayValue, emptyCharacter: emptyCharacter, placeholderLength: 2, max: maxHour, min: minHour, maxLength: 2, validateFn: (val) => isHourInvalid(val, is24Hour),
|
|
490
|
+
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_HOUR, value: displayValue, emptyCharacter: emptyCharacter, placeholderLength: 2, max: maxHour, min: minHour, maxLength: 2, validateFn: (val) => isHourInvalid(val, is24Hour), onChange: otherProps.onChange, onBlur: (direction, event) => {
|
|
480
491
|
// PartialInput provides direction, but the current onBlur expects just the event
|
|
481
492
|
if (otherProps.onBlur) {
|
|
482
493
|
otherProps.onBlur(event);
|
|
483
494
|
}
|
|
484
|
-
}, onKeyDown: otherProps.onKeyDown, className: (0, classnames_1.default)(
|
|
495
|
+
}, onKeyDown: otherProps.onKeyDown, className: (0, classnames_1.default)(TimeInput_module_scss_1.default.input, TimeInput_module_scss_1.default.hour), invalidClassName: TimeInput_module_scss_1.default.invalid, disabled: otherProps.disabled, readOnly: otherProps.readOnly, required: otherProps.required, autoFocus: otherProps.autoFocus, inputRef: otherProps.inputRef, nextInputRef: otherProps.nextInputRef, nextButtonRef: otherProps.nextButtonRef, name: is24Hour ? "hour24" : "hour12", ariaLabel: otherProps.ariaLabel, isInvalid: isInvalid }));
|
|
485
496
|
}
|
|
486
497
|
function MinuteInput(_a) {
|
|
487
|
-
var { hour, maxTime, minTime, showLeadingZeros = true, value, isInvalid = false, emptyCharacter = "-"
|
|
498
|
+
var { hour, maxTime, minTime, showLeadingZeros = true, value, isInvalid = false, emptyCharacter = "-" } = _a, otherProps = __rest(_a, ["hour", "maxTime", "minTime", "showLeadingZeros", "value", "isInvalid", "emptyCharacter"]);
|
|
488
499
|
function isSameHour(date) {
|
|
489
500
|
return hour === (0, utils_1.getHours)(date).toString();
|
|
490
501
|
}
|
|
491
502
|
const maxMinute = (0, utils_1.safeMin)(59, maxTime && isSameHour(maxTime) && (0, utils_1.getMinutes)(maxTime));
|
|
492
503
|
const minMinute = (0, utils_1.safeMax)(0, minTime && isSameHour(minTime) && (0, utils_1.getMinutes)(minTime));
|
|
493
|
-
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { max: maxMinute, min: minMinute, name: "minute", value: value, validateFn: isMinuteOrSecondInvalid,
|
|
504
|
+
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_MINUTE, max: maxMinute, min: minMinute, name: "minute", value: value, validateFn: isMinuteOrSecondInvalid, emptyCharacter: emptyCharacter, placeholderLength: 2, maxLength: 2, onChange: otherProps.onChange, onBlur: (direction, event) => {
|
|
494
505
|
// PartialInput provides direction, but the current onBlur expects just the event
|
|
495
506
|
if (otherProps.onBlur) {
|
|
496
507
|
otherProps.onBlur(event);
|
|
497
508
|
}
|
|
498
|
-
}, onKeyDown: otherProps.onKeyDown, className: (0, classnames_1.default)(
|
|
509
|
+
}, onKeyDown: otherProps.onKeyDown, className: (0, classnames_1.default)(TimeInput_module_scss_1.default.input, TimeInput_module_scss_1.default.minute), invalidClassName: TimeInput_module_scss_1.default.invalid, disabled: otherProps.disabled, readOnly: otherProps.readOnly, required: otherProps.required, autoFocus: otherProps.autoFocus, inputRef: otherProps.inputRef, nextInputRef: otherProps.nextInputRef, nextButtonRef: otherProps.nextButtonRef, ariaLabel: otherProps.ariaLabel, isInvalid: isInvalid }));
|
|
499
510
|
}
|
|
500
511
|
function SecondInput(_a) {
|
|
501
|
-
var { hour, maxTime, minTime, minute, showLeadingZeros = true, value, isInvalid = false, emptyCharacter = "-"
|
|
512
|
+
var { hour, maxTime, minTime, minute, showLeadingZeros = true, value, isInvalid = false, emptyCharacter = "-" } = _a, otherProps = __rest(_a, ["hour", "maxTime", "minTime", "minute", "showLeadingZeros", "value", "isInvalid", "emptyCharacter"]);
|
|
502
513
|
function isSameMinute(date) {
|
|
503
514
|
return hour === (0, utils_1.getHours)(date).toString() && minute === (0, utils_1.getMinutes)(date).toString();
|
|
504
515
|
}
|
|
505
516
|
const maxSecond = (0, utils_1.safeMin)(59, maxTime && isSameMinute(maxTime) && (0, utils_1.getSeconds)(maxTime));
|
|
506
517
|
const minSecond = (0, utils_1.safeMax)(0, minTime && isSameMinute(minTime) && (0, utils_1.getSeconds)(minTime));
|
|
507
|
-
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { max: maxSecond, min: minSecond, name: "second", value: value, validateFn: isMinuteOrSecondInvalid,
|
|
518
|
+
return ((0, jsx_runtime_1.jsx)(PartialInput_1.PartialInput, { "data-part-id": PART_SECOND, max: maxSecond, min: minSecond, name: "second", value: value, validateFn: isMinuteOrSecondInvalid, emptyCharacter: emptyCharacter, placeholderLength: 2, maxLength: 2, onChange: otherProps.onChange, onBlur: (direction, event) => {
|
|
508
519
|
// PartialInput provides direction, but the current onBlur expects just the event
|
|
509
520
|
if (otherProps.onBlur) {
|
|
510
521
|
otherProps.onBlur(event);
|
|
511
522
|
}
|
|
512
|
-
}, onKeyDown: otherProps.onKeyDown, className: (0, classnames_1.default)(
|
|
523
|
+
}, onKeyDown: otherProps.onKeyDown, className: (0, classnames_1.default)(TimeInput_module_scss_1.default.input, TimeInput_module_scss_1.default.second), invalidClassName: TimeInput_module_scss_1.default.invalid, disabled: otherProps.disabled, readOnly: otherProps.readOnly, required: otherProps.required, autoFocus: otherProps.autoFocus, inputRef: otherProps.inputRef, nextInputRef: otherProps.nextInputRef, nextButtonRef: otherProps.nextButtonRef, ariaLabel: otherProps.ariaLabel, isInvalid: isInvalid }));
|
|
513
524
|
}
|
|
514
525
|
// Utility function to parse time string into components
|
|
515
|
-
function parseTimeString(
|
|
526
|
+
function parseTimeString(timeValue, targetIs12Hour = false) {
|
|
527
|
+
// Handle non-string values gracefully
|
|
528
|
+
if (timeValue == null || timeValue === undefined) {
|
|
529
|
+
return {
|
|
530
|
+
amPm: null,
|
|
531
|
+
hour: "",
|
|
532
|
+
minute: "",
|
|
533
|
+
second: "",
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
// If not a string, return empty values for type safety
|
|
537
|
+
if (typeof timeValue !== "string") {
|
|
538
|
+
return {
|
|
539
|
+
amPm: null,
|
|
540
|
+
hour: "",
|
|
541
|
+
minute: "",
|
|
542
|
+
second: "",
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
const timeString = timeValue;
|
|
516
546
|
const normalizedTimeString = timeString.toLowerCase();
|
|
517
547
|
// Check if the time string contains AM/PM
|
|
518
548
|
const hasAmPm = normalizedTimeString.includes("am") || normalizedTimeString.includes("pm");
|
|
519
549
|
const isAmPmPm = normalizedTimeString.includes("pm");
|
|
520
550
|
// Extract just the time part (remove AM/PM suffix)
|
|
521
551
|
const timePart = normalizedTimeString.replace(/\s*(am|pm)\s*$/i, "").trim();
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
552
|
+
let parsedHour = (0, utils_1.getHours)(timePart);
|
|
553
|
+
let parsedMinute = (0, utils_1.getMinutes)(timePart);
|
|
554
|
+
let parsedSecond = (0, utils_1.getSeconds)(timePart);
|
|
555
|
+
// If parsing with the current format fails (all zeros), try ISO time format
|
|
556
|
+
if (parsedHour === 0 &&
|
|
557
|
+
parsedMinute === 0 &&
|
|
558
|
+
parsedSecond === 0 &&
|
|
559
|
+
timePart !== "00:00:00" &&
|
|
560
|
+
timePart !== "00:00") {
|
|
561
|
+
try {
|
|
562
|
+
// Try parsing as ISO time format using Date constructor
|
|
563
|
+
const isoDate = new Date(`1970-01-01T${timePart}`);
|
|
564
|
+
if (!isNaN(isoDate.getTime())) {
|
|
565
|
+
parsedHour = isoDate.getHours();
|
|
566
|
+
parsedMinute = isoDate.getMinutes();
|
|
567
|
+
parsedSecond = isoDate.getSeconds();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
catch (_a) {
|
|
571
|
+
// If ISO parsing fails, keep the original parsed values (zeros)
|
|
572
|
+
}
|
|
573
|
+
}
|
|
525
574
|
// Set AM/PM based on the actual string content or convert from 24-hour
|
|
526
575
|
let amPmValue = null;
|
|
527
576
|
let displayHour = parsedHour;
|
|
@@ -66,7 +66,7 @@ exports.defaultProps = {
|
|
|
66
66
|
indeterminate: false,
|
|
67
67
|
};
|
|
68
68
|
exports.Toggle = (0, react_3.forwardRef)(function Toggle(_a, forwardedRef) {
|
|
69
|
-
var { id, initialValue = exports.defaultProps.initialValue, value = exports.defaultProps.value, enabled = exports.defaultProps.enabled, style, readOnly, validationStatus = exports.defaultProps.validationStatus, updateState = constants_1.noop, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, variant = "checkbox", indeterminate = exports.defaultProps.indeterminate, className, label, labelPosition = "end", labelWidth, labelBreak, required, autoFocus, registerComponentApi, inputRenderer } = _a, rest = __rest(_a, ["id", "initialValue", "value", "enabled", "style", "readOnly", "validationStatus", "updateState", "onDidChange", "onFocus", "onBlur", "variant", "indeterminate", "className", "label", "labelPosition", "labelWidth", "labelBreak", "required", "autoFocus", "registerComponentApi", "inputRenderer"]);
|
|
69
|
+
var { id, initialValue = exports.defaultProps.initialValue, value = exports.defaultProps.value, enabled = exports.defaultProps.enabled, style, readOnly, validationStatus = exports.defaultProps.validationStatus, updateState = constants_1.noop, onClick = constants_1.noop, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, variant = "checkbox", indeterminate = exports.defaultProps.indeterminate, className, label, labelPosition = "end", labelWidth, labelBreak, required, autoFocus, registerComponentApi, inputRenderer } = _a, rest = __rest(_a, ["id", "initialValue", "value", "enabled", "style", "readOnly", "validationStatus", "updateState", "onClick", "onDidChange", "onFocus", "onBlur", "variant", "indeterminate", "className", "label", "labelPosition", "labelWidth", "labelBreak", "required", "autoFocus", "registerComponentApi", "inputRenderer"]);
|
|
70
70
|
const generatedId = (0, react_1.useId)();
|
|
71
71
|
const inputId = id || generatedId;
|
|
72
72
|
const innerRef = react_3.default.useRef(null);
|
|
@@ -139,7 +139,7 @@ exports.Toggle = (0, react_3.forwardRef)(function Toggle(_a, forwardedRef) {
|
|
|
139
139
|
}, [focus, registerComponentApi, setValue]);
|
|
140
140
|
const input = (0, react_2.useMemo)(() => {
|
|
141
141
|
const legitValue = transformToLegitValue(value);
|
|
142
|
-
return ((0, jsx_runtime_1.jsx)("input", { id: inputId, ref: innerRef, type: "checkbox", role: variant, checked: legitValue, disabled: !enabled, required: required, readOnly: readOnly, "aria-readonly": readOnly, "aria-checked": indeterminate ? "mixed" : legitValue, "aria-required": required, "aria-disabled": !enabled, onChange: onInputChange, onFocus: handleOnFocus, onBlur: handleOnBlur, autoFocus: autoFocus, className: (0, classnames_1.default)(
|
|
142
|
+
return ((0, jsx_runtime_1.jsx)("input", { id: inputId, "data-part-id": parts_1.PART_INPUT, ref: innerRef, type: "checkbox", role: variant, checked: legitValue, disabled: !enabled, required: required, readOnly: readOnly, "aria-readonly": readOnly, "aria-checked": indeterminate ? "mixed" : legitValue, "aria-required": required, "aria-disabled": !enabled, onClick: onClick, onChange: onInputChange, onFocus: handleOnFocus, onBlur: handleOnBlur, autoFocus: autoFocus, className: (0, classnames_1.default)(Toggle_module_scss_1.default.resetAppearance, {
|
|
143
143
|
[Toggle_module_scss_1.default.checkbox]: variant === "checkbox",
|
|
144
144
|
[Toggle_module_scss_1.default.switch]: variant === "switch",
|
|
145
145
|
[Toggle_module_scss_1.default.error]: validationStatus === "error",
|
|
@@ -33,49 +33,49 @@ exports.TooltipMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
33
33
|
delayDuration: {
|
|
34
34
|
description: "The duration from when the mouse enters a tooltip trigger until the tooltip opens (in ms)",
|
|
35
35
|
type: "number",
|
|
36
|
-
defaultValue:
|
|
36
|
+
defaultValue: 700,
|
|
37
37
|
},
|
|
38
38
|
skipDelayDuration: {
|
|
39
39
|
description: "How much time a user has to enter another trigger without incurring a delay again (in ms)",
|
|
40
40
|
type: "number",
|
|
41
|
-
defaultValue:
|
|
41
|
+
defaultValue: 300,
|
|
42
42
|
},
|
|
43
43
|
defaultOpen: {
|
|
44
44
|
description: "The open state of the tooltip when it is initially rendered",
|
|
45
45
|
type: "boolean",
|
|
46
|
-
defaultValue:
|
|
46
|
+
defaultValue: false,
|
|
47
47
|
},
|
|
48
48
|
showArrow: {
|
|
49
49
|
description: "Whether to show the arrow pointing to the trigger element",
|
|
50
50
|
type: "boolean",
|
|
51
|
-
defaultValue:
|
|
51
|
+
defaultValue: false,
|
|
52
52
|
},
|
|
53
53
|
side: {
|
|
54
54
|
description: "The preferred side of the trigger to render against when open",
|
|
55
55
|
type: "string",
|
|
56
56
|
availableValues: ["top", "right", "bottom", "left"],
|
|
57
|
-
defaultValue:
|
|
57
|
+
defaultValue: "top",
|
|
58
58
|
},
|
|
59
59
|
align: {
|
|
60
60
|
description: "The preferred alignment against the trigger",
|
|
61
61
|
type: "string",
|
|
62
62
|
availableValues: ["start", "center", "end"],
|
|
63
|
-
defaultValue:
|
|
63
|
+
defaultValue: "center",
|
|
64
64
|
},
|
|
65
65
|
sideOffset: {
|
|
66
66
|
description: "The distance in pixels from the trigger",
|
|
67
67
|
type: "number",
|
|
68
|
-
defaultValue:
|
|
68
|
+
defaultValue: 4,
|
|
69
69
|
},
|
|
70
70
|
alignOffset: {
|
|
71
71
|
description: "An offset in pixels from the 'start' or 'end' alignment options",
|
|
72
72
|
type: "number",
|
|
73
|
-
defaultValue:
|
|
73
|
+
defaultValue: 0,
|
|
74
74
|
},
|
|
75
75
|
avoidCollisions: {
|
|
76
76
|
description: "When true, overrides the side and align preferences to prevent collisions with boundary edges",
|
|
77
77
|
type: "boolean",
|
|
78
|
-
defaultValue:
|
|
78
|
+
defaultValue: true,
|
|
79
79
|
},
|
|
80
80
|
},
|
|
81
81
|
events: {},
|
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.Tooltip = exports.defaultProps = void 0;
|
|
40
40
|
exports.parseTooltipOptions = parseTooltipOptions;
|
|
41
41
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
+
const react_1 = require("react");
|
|
42
43
|
const RadixTooltip = __importStar(require("@radix-ui/react-tooltip"));
|
|
43
44
|
const lodash_es_1 = require("lodash-es");
|
|
44
45
|
const Tooltip_module_scss_1 = __importDefault(require("./Tooltip.module.scss"));
|
|
@@ -55,12 +56,11 @@ exports.defaultProps = {
|
|
|
55
56
|
alignOffset: 0,
|
|
56
57
|
avoidCollisions: true,
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
+
exports.Tooltip = (0, react_1.forwardRef)(function Tooltip({ text, markdown, tooltipTemplate, delayDuration = exports.defaultProps.delayDuration, skipDelayDuration = exports.defaultProps.skipDelayDuration, defaultOpen = exports.defaultProps.defaultOpen, showArrow = exports.defaultProps.showArrow, side = exports.defaultProps.side, align = exports.defaultProps.align, sideOffset = exports.defaultProps.sideOffset, alignOffset = exports.defaultProps.alignOffset, avoidCollisions = exports.defaultProps.avoidCollisions, children, open, }, ref) {
|
|
59
60
|
const { root } = (0, ThemeContext_1.useTheme)();
|
|
60
61
|
const showTooltip = !!(text || markdown || tooltipTemplate);
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(RadixTooltip.Provider, { delayDuration: delayDuration, skipDelayDuration: skipDelayDuration, children: (0, jsx_runtime_1.jsxs)(RadixTooltip.Root, { defaultOpen: defaultOpen, children: [(0, jsx_runtime_1.jsx)(RadixTooltip.Trigger, { asChild: true, children: children }), (0, jsx_runtime_1.jsx)(RadixTooltip.Portal, { container: root, children: showTooltip && ((0, jsx_runtime_1.jsxs)(RadixTooltip.Content, { className: Tooltip_module_scss_1.default.content, side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, avoidCollisions: avoidCollisions, children: [tooltipTemplate ? (tooltipTemplate) : markdown ? ((0, jsx_runtime_1.jsx)(Markdown_1.Markdown, { children: markdown })) : (text), showArrow && (0, jsx_runtime_1.jsx)(RadixTooltip.Arrow, { className: Tooltip_module_scss_1.default.arrow })] })) })] }) }));
|
|
62
|
-
};
|
|
63
|
-
exports.Tooltip = Tooltip;
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(RadixTooltip.Provider, { delayDuration: delayDuration, skipDelayDuration: skipDelayDuration, children: (0, jsx_runtime_1.jsxs)(RadixTooltip.Root, { defaultOpen: defaultOpen, open: open, children: [(0, jsx_runtime_1.jsx)(RadixTooltip.Trigger, { asChild: true, children: children }), (0, jsx_runtime_1.jsx)(RadixTooltip.Portal, { container: root, children: showTooltip && ((0, jsx_runtime_1.jsxs)(RadixTooltip.Content, { ref: ref, className: Tooltip_module_scss_1.default.content, side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, avoidCollisions: avoidCollisions, "data-tooltip-container": true, children: [tooltipTemplate ? (tooltipTemplate) : markdown ? ((0, jsx_runtime_1.jsx)(Markdown_1.Markdown, { children: markdown })) : (text), showArrow && (0, jsx_runtime_1.jsx)(RadixTooltip.Arrow, { className: Tooltip_module_scss_1.default.arrow })] })) })] }) }));
|
|
63
|
+
});
|
|
64
64
|
/**
|
|
65
65
|
* Parses tooltip options from any input and returns an object containing only the option properties
|
|
66
66
|
* of Tooltip (excludes non-option properties like text, triggerRef, and children)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.httpMethodNames = exports.VariantPropsKeys = exports.variantOptionsMd = exports.TextVariantElement = exports.orderingValues = exports.scrollAnchoringNames = exports.scrollAnchoringValues = exports.validationStatusMd = exports.validationStatusNames = exports.validationStatusValues = exports.triggerPositionNames = exports.labelPositionMd = exports.labelPositionNames = exports.labelPositionValues = exports.placementMd = exports.placementNames = exports.statusColorMd = exports.statusColorNames = exports.iconPositionMd = exports.iconPositionNames = exports.iconPositionValues = exports.orientationOptionMd = exports.orientationOptionValues = exports.alignmentOptionMd = exports.alignmentOptionNames = exports.alignmentOptionValues = exports.buttonAriaNames = exports.buttonVariantMd = exports.buttonVariantNames = exports.buttonVariantValues = exports.buttonTypesMd = exports.buttonTypeNames = exports.buttonTypeValues = exports.buttonThemeMd = exports.buttonThemeNames = exports.buttonThemeValues = exports.sizeMd = exports.
|
|
3
|
+
exports.httpMethodNames = exports.VariantPropsKeys = exports.variantOptionsMd = exports.TextVariantElement = exports.orderingValues = exports.scrollAnchoringNames = exports.scrollAnchoringValues = exports.validationStatusMd = exports.validationStatusNames = exports.validationStatusValues = exports.triggerPositionNames = exports.labelPositionMd = exports.labelPositionNames = exports.labelPositionValues = exports.placementMd = exports.placementNames = exports.statusColorMd = exports.statusColorNames = exports.iconPositionMd = exports.iconPositionNames = exports.iconPositionValues = exports.orientationOptionMd = exports.orientationOptionValues = exports.alignmentOptionMd = exports.alignmentOptionNames = exports.alignmentOptionValues = exports.buttonAriaNames = exports.buttonVariantMd = exports.buttonVariantNames = exports.buttonVariantValues = exports.buttonTypesMd = exports.buttonTypeNames = exports.buttonTypeValues = exports.buttonThemeMd = exports.buttonThemeNames = exports.buttonThemeValues = exports.sizeMd = exports.sizeValues = exports.viewportSizeNames = exports.viewportSizeMd = exports.LinkTargetMd = exports.LinkTargetNames = void 0;
|
|
4
|
+
exports.isSizeType = isSizeType;
|
|
4
5
|
exports.LinkTargetNames = ["_self", "_blank", "_parent", "_top", "_unfencedTop"];
|
|
5
6
|
exports.LinkTargetMd = [
|
|
6
7
|
{
|
|
@@ -38,14 +39,17 @@ exports.viewportSizeMd = [
|
|
|
38
39
|
];
|
|
39
40
|
exports.viewportSizeNames = Object.keys(exports.viewportSizeMd);
|
|
40
41
|
// --- Available button sizes
|
|
41
|
-
exports.
|
|
42
|
+
exports.sizeValues = ["xs", "sm", "md", "lg", "xl"];
|
|
42
43
|
exports.sizeMd = [
|
|
43
44
|
{ value: "xs", description: "Extra small" },
|
|
44
45
|
{ value: "sm", description: "Small" },
|
|
45
46
|
{ value: "md", description: "Medium" },
|
|
46
47
|
{ value: "lg", description: "Large" },
|
|
48
|
+
{ value: "xl", description: "Extra large" },
|
|
47
49
|
];
|
|
48
|
-
|
|
50
|
+
function isSizeType(value) {
|
|
51
|
+
return exports.sizeValues.includes(value);
|
|
52
|
+
}
|
|
49
53
|
// --- Available button themes
|
|
50
54
|
exports.buttonThemeValues = ["attention", "primary", "secondary"];
|
|
51
55
|
exports.buttonThemeNames = [...exports.buttonThemeValues];
|