grommet 2.55.0 → 2.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYRIGHT.md +3 -1
- package/components/Button/Button.js +7 -4
- package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
- package/components/Calendar/Calendar.js +2 -1
- package/components/Cards/Cards.js +1 -2
- package/components/DateTimeInput/DateTimeInput.js +1093 -0
- package/components/DateTimeInput/README.md +2 -0
- package/components/DateTimeInput/StyledDateTimeInput.js +74 -0
- package/components/DateTimeInput/index.d.ts +47 -0
- package/components/DateTimeInput/index.js +6 -0
- package/components/DateTimeInput/propTypes.js +42 -0
- package/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
- package/components/DateTimeInput/stories/Form.stories.tsx +44 -0
- package/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
- package/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
- package/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
- package/components/Form/Form.js +7 -4
- package/components/Form/index.d.ts +3 -0
- package/components/Form/stories/AggregateValidation.stories.js +6 -8
- package/components/FormField/FormField.js +164 -91
- package/components/Grommet/index.d.ts +21 -0
- package/components/Grommet/propTypes.js +26 -0
- package/components/Stepper/StepConnector.js +38 -0
- package/components/Stepper/Stepper.js +303 -0
- package/components/Stepper/StepperContext.js +43 -0
- package/components/Stepper/StepperDescription.js +26 -0
- package/components/Stepper/StepperHelperText.js +44 -0
- package/components/Stepper/StepperIndicator.js +74 -0
- package/components/Stepper/StepperLabel.js +41 -0
- package/components/Stepper/StepperStep.js +137 -0
- package/components/Stepper/StyledStepper.js +162 -0
- package/components/Stepper/index.d.ts +80 -0
- package/components/Stepper/index.js +18 -0
- package/components/Stepper/propTypes.js +35 -0
- package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
- package/components/Stepper/stories/ErrorStates.stories.js +45 -0
- package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
- package/components/Stepper/stories/Interactive.stories.js +60 -0
- package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
- package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
- package/components/Stepper/stories/ReadOnly.stories.js +43 -0
- package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
- package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
- package/components/Tab/Tab.js +19 -6
- package/components/Tabs/Tabs.js +156 -22
- package/components/TimeInput/README.md +2 -0
- package/components/TimeInput/StyledTimeInput.js +73 -0
- package/components/TimeInput/TimeInput.js +692 -0
- package/components/TimeInput/TimeInputPopup.js +489 -0
- package/components/TimeInput/index.d.ts +44 -0
- package/components/TimeInput/index.js +6 -0
- package/components/TimeInput/propTypes.js +39 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/components/TimeInput/useSectionedTimeField.js +358 -0
- package/components/TimeInput/utils.js +192 -0
- package/components/Wizard/StyledWizard.js +16 -0
- package/components/Wizard/Wizard.js +770 -0
- package/components/Wizard/WizardContent.js +90 -0
- package/components/Wizard/WizardContext.js +35 -0
- package/components/Wizard/WizardFooter.js +123 -0
- package/components/Wizard/WizardHeader.js +63 -0
- package/components/Wizard/WizardProgress.js +84 -0
- package/components/Wizard/WizardStepHeader.js +55 -0
- package/components/Wizard/index.d.ts +171 -0
- package/components/Wizard/index.js +19 -0
- package/components/Wizard/propTypes.js +56 -0
- package/components/Wizard/stories/BasicLinear.stories.js +71 -0
- package/components/Wizard/stories/Branching.stories.js +96 -0
- package/components/Wizard/stories/Composable.stories.js +75 -0
- package/components/Wizard/stories/Controlled.stories.js +136 -0
- package/components/Wizard/stories/LongContent.stories.js +118 -0
- package/components/Wizard/stories/Modal.stories.js +143 -0
- package/components/Wizard/stories/NestedSubSteps.stories.js +79 -0
- package/components/Wizard/stories/Validation.stories.js +123 -0
- package/components/index.d.ts +6 -0
- package/components/index.js +24 -0
- package/es6/components/Button/Button.js +7 -4
- package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -0
- package/es6/components/Calendar/Calendar.js +2 -0
- package/es6/components/Cards/Cards.js +1 -2
- package/es6/components/DateTimeInput/DateTimeInput.js +1090 -0
- package/es6/components/DateTimeInput/README.md +2 -0
- package/es6/components/DateTimeInput/StyledDateTimeInput.js +68 -0
- package/es6/components/DateTimeInput/index.d.ts +47 -0
- package/es6/components/DateTimeInput/index.js +3 -0
- package/es6/components/DateTimeInput/propTypes.js +36 -0
- package/es6/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
- package/es6/components/DateTimeInput/stories/Form.stories.tsx +44 -0
- package/es6/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
- package/es6/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
- package/es6/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
- package/es6/components/Form/Form.js +7 -3
- package/es6/components/Form/index.d.ts +3 -0
- package/es6/components/Form/stories/AggregateValidation.stories.js +6 -9
- package/es6/components/FormField/FormField.js +165 -91
- package/es6/components/Grommet/index.d.ts +21 -0
- package/es6/components/Grommet/propTypes.js +26 -0
- package/es6/components/Stepper/StepConnector.js +33 -0
- package/es6/components/Stepper/Stepper.js +301 -0
- package/es6/components/Stepper/StepperContext.js +39 -0
- package/es6/components/Stepper/StepperDescription.js +21 -0
- package/es6/components/Stepper/StepperHelperText.js +39 -0
- package/es6/components/Stepper/StepperIndicator.js +69 -0
- package/es6/components/Stepper/StepperLabel.js +36 -0
- package/es6/components/Stepper/StepperStep.js +133 -0
- package/es6/components/Stepper/StyledStepper.js +156 -0
- package/es6/components/Stepper/index.d.ts +80 -0
- package/es6/components/Stepper/index.js +6 -0
- package/es6/components/Stepper/propTypes.js +30 -0
- package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
- package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
- package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
- package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
- package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
- package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
- package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
- package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
- package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
- package/es6/components/Tab/Tab.js +19 -6
- package/es6/components/Tabs/Tabs.js +157 -23
- package/es6/components/TimeInput/README.md +2 -0
- package/es6/components/TimeInput/StyledTimeInput.js +68 -0
- package/es6/components/TimeInput/TimeInput.js +689 -0
- package/es6/components/TimeInput/TimeInputPopup.js +485 -0
- package/es6/components/TimeInput/index.d.ts +44 -0
- package/es6/components/TimeInput/index.js +1 -0
- package/es6/components/TimeInput/propTypes.js +33 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +355 -0
- package/es6/components/TimeInput/utils.js +187 -0
- package/es6/components/Wizard/StyledWizard.js +11 -0
- package/es6/components/Wizard/Wizard.js +768 -0
- package/es6/components/Wizard/WizardContent.js +87 -0
- package/es6/components/Wizard/WizardContext.js +31 -0
- package/es6/components/Wizard/WizardFooter.js +120 -0
- package/es6/components/Wizard/WizardHeader.js +60 -0
- package/es6/components/Wizard/WizardProgress.js +80 -0
- package/es6/components/Wizard/WizardStepHeader.js +51 -0
- package/es6/components/Wizard/index.d.ts +171 -0
- package/es6/components/Wizard/index.js +7 -0
- package/es6/components/Wizard/propTypes.js +51 -0
- package/es6/components/Wizard/stories/BasicLinear.stories.js +67 -0
- package/es6/components/Wizard/stories/Branching.stories.js +93 -0
- package/es6/components/Wizard/stories/Composable.stories.js +72 -0
- package/es6/components/Wizard/stories/Controlled.stories.js +133 -0
- package/es6/components/Wizard/stories/LongContent.stories.js +115 -0
- package/es6/components/Wizard/stories/Modal.stories.js +141 -0
- package/es6/components/Wizard/stories/NestedSubSteps.stories.js +76 -0
- package/es6/components/Wizard/stories/Validation.stories.js +118 -0
- package/es6/components/index.d.ts +6 -0
- package/es6/components/index.js +6 -0
- package/es6/index.d.ts +6 -0
- package/es6/languages/default.json +48 -0
- package/es6/themes/base.d.ts +223 -0
- package/es6/themes/base.js +366 -0
- package/es6/utils/DOM.js +11 -2
- package/es6/utils/dates.js +10 -0
- package/es6/utils/sectionHelpers.js +57 -0
- package/es6/utils/useSectionedField.js +45 -0
- package/grommet.min.js +2 -1
- package/grommet.min.js.LICENSE.txt +1 -0
- package/grommet.min.js.map +1 -1
- package/index.d.ts +6 -0
- package/languages/default.json +48 -0
- package/package.json +57 -52
- package/themes/base.d.ts +223 -0
- package/themes/base.js +366 -1
- package/tools/license-header.js +2 -0
- package/utils/DOM.js +11 -2
- package/utils/dates.js +11 -1
- package/utils/sectionHelpers.js +61 -0
- package/utils/useSectionedField.js +50 -0
- package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
- package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.StyledDateTimeInputSeparator = exports.StyledDateTimeInputSegment = exports.StyledDateTimeInputField = exports.StyledDateTimeInputDisplay = exports.StyledDateTimeInputContainer = exports.StyledDateTimeInput = void 0;
|
|
5
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
6
|
+
var _utils = require("../../utils");
|
|
7
|
+
var _Box = require("../Box");
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
9
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
var getActiveTokens = function getActiveTokens(theme) {
|
|
13
|
+
var _theme$dateTimeInput, _theme$timeInput;
|
|
14
|
+
return ((_theme$dateTimeInput = theme.dateTimeInput) == null ? void 0 : _theme$dateTimeInput.active) || ((_theme$timeInput = theme.timeInput) == null ? void 0 : _theme$timeInput.active);
|
|
15
|
+
};
|
|
16
|
+
var StyledDateTimeInputContainer = exports.StyledDateTimeInputContainer = (0, _styledComponents["default"])(_Box.Box).withConfig({
|
|
17
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
18
|
+
return prop !== 'disabled' && prop !== 'readOnlyProp';
|
|
19
|
+
}
|
|
20
|
+
}).withConfig({
|
|
21
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputContainer",
|
|
22
|
+
componentId: "sc-d6m1ya-0"
|
|
23
|
+
})(["", " ", " ", ""], function (props) {
|
|
24
|
+
return props.disabled && (0, _utils.disabledStyle)();
|
|
25
|
+
}, function (props) {
|
|
26
|
+
return props.readOnlyProp && (0, _utils.readOnlyStyle)(props.theme);
|
|
27
|
+
}, function (props) {
|
|
28
|
+
return props.focusIndicator !== false && (0, _styledComponents.css)(["&:focus-within:not(:has(button:focus-visible)){", "}"], (0, _utils.focusStyle)());
|
|
29
|
+
});
|
|
30
|
+
var StyledDateTimeInput = exports.StyledDateTimeInput = _styledComponents["default"].input.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
31
|
+
displayName: "StyledDateTimeInput",
|
|
32
|
+
componentId: "sc-d6m1ya-1"
|
|
33
|
+
})(["", " ", " position:relative;pointer-events:none;color:transparent;caret-color:transparent;text-shadow:none;&::selection{background:transparent;color:transparent;}&::placeholder{color:transparent;}"], _utils.inputStyle, _utils.plainInputStyle);
|
|
34
|
+
var StyledDateTimeInputField = exports.StyledDateTimeInputField = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
35
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputField",
|
|
36
|
+
componentId: "sc-d6m1ya-2"
|
|
37
|
+
})(["position:relative;flex:1 1 auto;min-width:0;"]);
|
|
38
|
+
var StyledDateTimeInputDisplay = exports.StyledDateTimeInputDisplay = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
39
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputDisplay",
|
|
40
|
+
componentId: "sc-d6m1ya-3"
|
|
41
|
+
})(["position:absolute;inset:0;display:flex;align-items:center;overflow:hidden;", ""], function (props) {
|
|
42
|
+
return props.theme.global.input.padding && (typeof props.theme.global.input.padding !== 'object' ? "padding: " + ((0, _utils.parseMetricToNum)(props.theme.global.edgeSize[props.theme.global.input.padding] || props.theme.global.input.padding) - (0, _utils.parseMetricToNum)(props.theme.global.control.border.width)) + "px;" : (0, _utils.edgeStyle)('padding', props.theme.global.input.padding, props.responsive, props.theme.box.responsiveBreakpoint, props.theme));
|
|
43
|
+
});
|
|
44
|
+
var StyledDateTimeInputSeparator = exports.StyledDateTimeInputSeparator = _styledComponents["default"].span.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
45
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputSeparator",
|
|
46
|
+
componentId: "sc-d6m1ya-4"
|
|
47
|
+
})(["display:inline-flex;align-items:center;line-height:inherit;color:", ";padding-inline:", ";", ""], function (props) {
|
|
48
|
+
return (0, _utils.normalizeColor)(props.$filled ? 'text' : props.theme.global.colors.placeholder, props.theme);
|
|
49
|
+
}, function (props) {
|
|
50
|
+
return props.$paddingInline;
|
|
51
|
+
}, function (props) {
|
|
52
|
+
var weight = props.theme.global.input.weight || props.theme.global.input.font.weight;
|
|
53
|
+
return weight && "font-weight: " + weight + ";";
|
|
54
|
+
});
|
|
55
|
+
var StyledDateTimeInputSegment = exports.StyledDateTimeInputSegment = _styledComponents["default"].span.withConfig(_utils.styledComponentsConfig).withConfig({
|
|
56
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputSegment",
|
|
57
|
+
componentId: "sc-d6m1ya-5"
|
|
58
|
+
})(["&:focus{outline:none;}display:inline-flex;align-items:center;position:relative;line-height:inherit;color:", ";", " ", ""], function (props) {
|
|
59
|
+
return (0, _utils.normalizeColor)(props.$filled ? 'text' : props.theme.global.colors.placeholder, props.theme);
|
|
60
|
+
}, function (props) {
|
|
61
|
+
var weight = props.theme.global.input.weight || props.theme.global.input.font.weight;
|
|
62
|
+
return weight && "font-weight: " + weight + ";";
|
|
63
|
+
}, function (props) {
|
|
64
|
+
var _props$theme$global$e, _activeTokens$indicat, _props$theme$global$b, _props$theme$global$e2, _activeTokens$indicat2;
|
|
65
|
+
if (!props.$active) return '';
|
|
66
|
+
var activeTokens = getActiveTokens(props.theme);
|
|
67
|
+
var activeRound = (_props$theme$global$e = props.theme.global.edgeSize) == null ? void 0 : _props$theme$global$e.hair;
|
|
68
|
+
var activeBorderToken = activeTokens == null || (_activeTokens$indicat = activeTokens.indicator) == null ? void 0 : _activeTokens$indicat.size;
|
|
69
|
+
var activeBorderSize = ((_props$theme$global$b = props.theme.global.borderSize) == null ? void 0 : _props$theme$global$b[activeBorderToken]) || ((_props$theme$global$e2 = props.theme.global.edgeSize) == null ? void 0 : _props$theme$global$e2[activeBorderToken]) || activeBorderToken || props.theme.global.borderSize.small;
|
|
70
|
+
return (0, _styledComponents.css)(["&::before{content:'';position:absolute;inset:0;background-color:", ";border-top-left-radius:", ";border-top-right-radius:", ";}&::after{content:'';position:absolute;left:0;right:0;bottom:0;height:", ";background-color:", ";border-bottom-left-radius:", ";border-bottom-right-radius:", ";}"], (0, _utils.normalizeColor)(activeTokens == null ? void 0 : activeTokens.background, props.theme), activeRound, activeRound, activeBorderSize, (0, _utils.normalizeColor)((activeTokens == null || (_activeTokens$indicat2 = activeTokens.indicator) == null ? void 0 : _activeTokens$indicat2.color) || {
|
|
71
|
+
dark: 'white',
|
|
72
|
+
light: 'black'
|
|
73
|
+
}, props.theme), activeRound, activeRound);
|
|
74
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
export interface DateTimeInputProps {
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
format?: '12' | '24';
|
|
9
|
+
id?: string;
|
|
10
|
+
locale?: string;
|
|
11
|
+
inline?: boolean;
|
|
12
|
+
messages?: {
|
|
13
|
+
activeSection?: string;
|
|
14
|
+
activeSectionValue?: string;
|
|
15
|
+
chooseDateTime?: string;
|
|
16
|
+
inputLabel?: string;
|
|
17
|
+
invalidDateTime?: string;
|
|
18
|
+
openDrop?: string;
|
|
19
|
+
sectionDay?: string;
|
|
20
|
+
sectionHours?: string;
|
|
21
|
+
sectionMeridiem?: string;
|
|
22
|
+
sectionMinutes?: string;
|
|
23
|
+
sectionMonth?: string;
|
|
24
|
+
sectionSeconds?: string;
|
|
25
|
+
sectionYear?: string;
|
|
26
|
+
};
|
|
27
|
+
minuteStep?: number;
|
|
28
|
+
name?: string;
|
|
29
|
+
onChange?: (event: { value?: string }) => void;
|
|
30
|
+
readOnly?: boolean;
|
|
31
|
+
showSeconds?: boolean;
|
|
32
|
+
value?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DateTimeInputExtendedProps
|
|
36
|
+
extends DateTimeInputProps,
|
|
37
|
+
Omit<
|
|
38
|
+
React.DetailedHTMLProps<
|
|
39
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
40
|
+
HTMLInputElement
|
|
41
|
+
>,
|
|
42
|
+
'defaultValue' | 'onChange' | 'value'
|
|
43
|
+
> {}
|
|
44
|
+
|
|
45
|
+
declare const DateTimeInput: React.FC<DateTimeInputExtendedProps>;
|
|
46
|
+
|
|
47
|
+
export { DateTimeInput };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.DateTimeInputPropTypes = void 0;
|
|
5
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
var PropType = {};
|
|
11
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
12
|
+
PropType = {
|
|
13
|
+
defaultValue: _propTypes["default"].string,
|
|
14
|
+
disabled: _propTypes["default"].bool,
|
|
15
|
+
format: _propTypes["default"].oneOf(['12', '24']),
|
|
16
|
+
id: _propTypes["default"].string,
|
|
17
|
+
locale: _propTypes["default"].string,
|
|
18
|
+
inline: _propTypes["default"].bool,
|
|
19
|
+
messages: _propTypes["default"].shape({
|
|
20
|
+
activeSection: _propTypes["default"].string,
|
|
21
|
+
activeSectionValue: _propTypes["default"].string,
|
|
22
|
+
chooseDateTime: _propTypes["default"].string,
|
|
23
|
+
inputLabel: _propTypes["default"].string,
|
|
24
|
+
invalidDateTime: _propTypes["default"].string,
|
|
25
|
+
openDrop: _propTypes["default"].string,
|
|
26
|
+
sectionDay: _propTypes["default"].string,
|
|
27
|
+
sectionHours: _propTypes["default"].string,
|
|
28
|
+
sectionMeridiem: _propTypes["default"].string,
|
|
29
|
+
sectionMinutes: _propTypes["default"].string,
|
|
30
|
+
sectionMonth: _propTypes["default"].string,
|
|
31
|
+
sectionSeconds: _propTypes["default"].string,
|
|
32
|
+
sectionYear: _propTypes["default"].string
|
|
33
|
+
}),
|
|
34
|
+
minuteStep: _propTypes["default"].number,
|
|
35
|
+
name: _propTypes["default"].string,
|
|
36
|
+
onChange: _propTypes["default"].func,
|
|
37
|
+
readOnly: _propTypes["default"].bool,
|
|
38
|
+
showSeconds: _propTypes["default"].bool,
|
|
39
|
+
value: _propTypes["default"].string
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
var DateTimeInputPropTypes = exports.DateTimeInputPropTypes = PropType;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import { Box, Grommet } from 'grommet';
|
|
7
|
+
import { Calendar } from 'grommet-icons';
|
|
8
|
+
import { DateTimeInput } from '../../index';
|
|
9
|
+
|
|
10
|
+
// Note: ThemeType annotation not used here because dateTimeInput is not yet in
|
|
11
|
+
// the published grommet package types. Type will be available post-merge.
|
|
12
|
+
const customTheme = {
|
|
13
|
+
dateTimeInput: {
|
|
14
|
+
container: {
|
|
15
|
+
round: 'xsmall',
|
|
16
|
+
},
|
|
17
|
+
button: {
|
|
18
|
+
margin: 'xsmall',
|
|
19
|
+
},
|
|
20
|
+
icon: {
|
|
21
|
+
calendar: Calendar, // Pass the component, not JSX
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const meta: Meta<typeof DateTimeInput> = {
|
|
27
|
+
title: 'Input/DateTimeInput/Custom Themed',
|
|
28
|
+
component: DateTimeInput,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof DateTimeInput>;
|
|
34
|
+
|
|
35
|
+
export const CustomThemed: Story = {
|
|
36
|
+
render: () => {
|
|
37
|
+
const [value, setValue] = React.useState('2026-07-22T18:30:00.000Z');
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Grommet theme={customTheme}>
|
|
41
|
+
<Box pad="large" width="medium" gap="small">
|
|
42
|
+
<DateTimeInput
|
|
43
|
+
format="12"
|
|
44
|
+
value={value}
|
|
45
|
+
onChange={({ value: next }: { value?: string }) => {
|
|
46
|
+
setValue(next || '');
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</Box>
|
|
50
|
+
</Grommet>
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Box, Button, Form, FormField } from 'grommet';
|
|
6
|
+
import { DateTimeInput } from '../index';
|
|
7
|
+
|
|
8
|
+
export const FormIntegration = () => {
|
|
9
|
+
const [value, setValue] = React.useState({ appointment: '' });
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Box pad="medium" width="medium" gap="small">
|
|
13
|
+
<Form
|
|
14
|
+
value={value}
|
|
15
|
+
onChange={(nextValue: { appointment: string }) => {
|
|
16
|
+
setValue(nextValue);
|
|
17
|
+
}}
|
|
18
|
+
onSubmit={() => {
|
|
19
|
+
setValue({ appointment: '' });
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<FormField
|
|
23
|
+
htmlFor="appointment-date-time"
|
|
24
|
+
label="Choose an appointment date and time"
|
|
25
|
+
name="appointment"
|
|
26
|
+
required
|
|
27
|
+
>
|
|
28
|
+
<DateTimeInput
|
|
29
|
+
id="appointment-date-time"
|
|
30
|
+
name="appointment"
|
|
31
|
+
format="12"
|
|
32
|
+
/>
|
|
33
|
+
</FormField>
|
|
34
|
+
<Button type="submit" label="submit" />
|
|
35
|
+
</Form>
|
|
36
|
+
</Box>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
FormIntegration.storyName = 'Form';
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
title: 'Input/DateTimeInput/Form',
|
|
44
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Box, Text } from 'grommet';
|
|
6
|
+
import { DateTimeInput } from '../index';
|
|
7
|
+
|
|
8
|
+
export const Inline = () => {
|
|
9
|
+
const [value, setValue] = React.useState('2026-07-22T18:30:00.000Z');
|
|
10
|
+
const localValue = value
|
|
11
|
+
? new Date(value).toLocaleString(undefined, {
|
|
12
|
+
year: 'numeric',
|
|
13
|
+
month: '2-digit',
|
|
14
|
+
day: '2-digit',
|
|
15
|
+
hour: '2-digit',
|
|
16
|
+
minute: '2-digit',
|
|
17
|
+
second: '2-digit',
|
|
18
|
+
hour12: true,
|
|
19
|
+
timeZoneName: 'short',
|
|
20
|
+
})
|
|
21
|
+
: 'none';
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Box pad="large" gap="small" width="large">
|
|
25
|
+
<DateTimeInput
|
|
26
|
+
id="inline-date-time"
|
|
27
|
+
inline
|
|
28
|
+
value={value}
|
|
29
|
+
onChange={({ value: next }: { value?: string }) => {
|
|
30
|
+
setValue(next || '');
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
<Text size="small" truncate>
|
|
34
|
+
Local display: {localValue}
|
|
35
|
+
</Text>
|
|
36
|
+
<Text size="small" truncate>
|
|
37
|
+
UTC ISO value: {value || 'none'}
|
|
38
|
+
</Text>
|
|
39
|
+
</Box>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
title: 'Input/DateTimeInput/Inline',
|
|
45
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Box, Text } from 'grommet';
|
|
6
|
+
import { DateTimeInput } from '../index';
|
|
7
|
+
|
|
8
|
+
const ISO = '2020-07-22T18:30:00.000Z';
|
|
9
|
+
|
|
10
|
+
export const Locale = () => {
|
|
11
|
+
const [usValue, setUsValue] = React.useState(ISO);
|
|
12
|
+
const [deValue, setDeValue] = React.useState(ISO);
|
|
13
|
+
const [frValue, setFrValue] = React.useState(ISO);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Box pad="large" gap="medium" width="medium">
|
|
17
|
+
<Box gap="xsmall">
|
|
18
|
+
<Text size="small" weight="bold">
|
|
19
|
+
en-US (MM/DD/YYYY, 12h)
|
|
20
|
+
</Text>
|
|
21
|
+
<DateTimeInput
|
|
22
|
+
locale="en-US"
|
|
23
|
+
value={usValue}
|
|
24
|
+
onChange={({ value: next }: { value?: string }) =>
|
|
25
|
+
setUsValue(next || '')
|
|
26
|
+
}
|
|
27
|
+
/>
|
|
28
|
+
</Box>
|
|
29
|
+
<Box gap="xsmall">
|
|
30
|
+
<Text size="small" weight="bold">
|
|
31
|
+
de-DE (DD.MM.YYYY, 24h)
|
|
32
|
+
</Text>
|
|
33
|
+
<DateTimeInput
|
|
34
|
+
locale="de-DE"
|
|
35
|
+
value={deValue}
|
|
36
|
+
onChange={({ value: next }: { value?: string }) =>
|
|
37
|
+
setDeValue(next || '')
|
|
38
|
+
}
|
|
39
|
+
/>
|
|
40
|
+
</Box>
|
|
41
|
+
<Box gap="xsmall">
|
|
42
|
+
<Text size="small" weight="bold">
|
|
43
|
+
fr-FR (DD/MM/YYYY, 24h)
|
|
44
|
+
</Text>
|
|
45
|
+
<DateTimeInput
|
|
46
|
+
locale="fr-FR"
|
|
47
|
+
value={frValue}
|
|
48
|
+
onChange={({ value: next }: { value?: string }) =>
|
|
49
|
+
setFrValue(next || '')
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
</Box>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
title: 'Input/DateTimeInput/Locale',
|
|
59
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Box } from 'grommet';
|
|
6
|
+
import { DateTimeInput } from '../index';
|
|
7
|
+
|
|
8
|
+
export const Simple = () => {
|
|
9
|
+
const [value, setValue] = React.useState('2026-07-22T18:30:00.000Z');
|
|
10
|
+
const onChange = ({ value: next }: { value?: string }) => {
|
|
11
|
+
setValue(next || '');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Box pad="large" width="medium" gap="small">
|
|
16
|
+
<DateTimeInput format="12" value={value} onChange={onChange} />
|
|
17
|
+
</Box>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: 'Input/DateTimeInput/Simple',
|
|
23
|
+
};
|
package/components/Form/Form.js
CHANGED
|
@@ -11,7 +11,8 @@ var _propTypes = require("./propTypes");
|
|
|
11
11
|
var _excluded = ["children", "errors", "infos", "messages", "kind", "onChange", "onReset", "onSubmit", "onValidate", "validate", "value"];
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
13
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
14
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
15
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
15
16
|
var defaultValue = {};
|
|
16
17
|
var defaultTouched = {};
|
|
17
18
|
var defaultValidationResults = {
|
|
@@ -511,8 +512,8 @@ var Form = exports.Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, r
|
|
|
511
512
|
useValue = componentValue;else if (valueProp && name && formValue !== undefined)
|
|
512
513
|
// form drives, pattern #1
|
|
513
514
|
useValue = formValue;else if (formValue === undefined && name)
|
|
514
|
-
// form
|
|
515
|
-
useValue = initialValue;else useValue = inputValue;
|
|
515
|
+
// controlled form: keep input controlled; uncontrolled: reset
|
|
516
|
+
useValue = valueProp !== undefined ? initialValue != null ? initialValue : '' : initialValue;else useValue = inputValue;
|
|
516
517
|
return [useValue, function (nextComponentValue) {
|
|
517
518
|
if (name) {
|
|
518
519
|
// we have somewhere to put this
|
|
@@ -677,7 +678,9 @@ var Form = exports.Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, r
|
|
|
677
678
|
// Show form's validity when clicking on Submit
|
|
678
679
|
valid: buildValid(nextErrors)
|
|
679
680
|
};
|
|
680
|
-
if (onValidate) onValidate(
|
|
681
|
+
if (onValidate) onValidate(_extends({
|
|
682
|
+
submitting: true
|
|
683
|
+
}, nextValidationResults));
|
|
681
684
|
validationResultsRef.current = nextValidationResults;
|
|
682
685
|
updateAnalytics();
|
|
683
686
|
return nextValidationResults;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
import * as React from 'react';
|
|
2
4
|
|
|
3
5
|
export interface FormExtendedEvent<R = Record<string, unknown>, T = Element>
|
|
@@ -18,6 +20,7 @@ export interface FormProps<T> {
|
|
|
18
20
|
errors: Record<string, any>;
|
|
19
21
|
infos: Record<string, any>;
|
|
20
22
|
valid: boolean;
|
|
23
|
+
submitting?: boolean;
|
|
21
24
|
}) => void;
|
|
22
25
|
validate?: 'blur' | 'submit' | 'change';
|
|
23
26
|
value?: T;
|
|
@@ -5,6 +5,9 @@ exports["default"] = exports.AggregateValidation = void 0;
|
|
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
6
|
var _grommet = require("grommet");
|
|
7
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
|
|
8
11
|
// This example shows a way to perform validation across multiple fields.
|
|
9
12
|
var AggregateValidation = exports.AggregateValidation = function AggregateValidation() {
|
|
10
13
|
var _React$useState = _react["default"].useState({
|
|
@@ -47,18 +50,13 @@ var AggregateValidation = exports.AggregateValidation = function AggregateValida
|
|
|
47
50
|
htmlFor: "email",
|
|
48
51
|
label: "Email",
|
|
49
52
|
name: "email",
|
|
50
|
-
required: true
|
|
53
|
+
required: true,
|
|
54
|
+
error: message
|
|
51
55
|
}, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
52
56
|
id: "email",
|
|
53
57
|
name: "email",
|
|
54
58
|
type: "email"
|
|
55
|
-
})),
|
|
56
|
-
pad: {
|
|
57
|
-
horizontal: 'small'
|
|
58
|
-
}
|
|
59
|
-
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
60
|
-
color: "status-error"
|
|
61
|
-
}, message)), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
59
|
+
})), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
62
60
|
direction: "row",
|
|
63
61
|
justify: "between",
|
|
64
62
|
margin: {
|