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,68 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { disabledStyle, edgeStyle, focusStyle, inputStyle, normalizeColor, parseMetricToNum, plainInputStyle, readOnlyStyle, styledComponentsConfig } from '../../utils';
|
|
5
|
+
import { Box } from '../Box';
|
|
6
|
+
var getActiveTokens = function getActiveTokens(theme) {
|
|
7
|
+
var _theme$dateTimeInput, _theme$timeInput;
|
|
8
|
+
return ((_theme$dateTimeInput = theme.dateTimeInput) == null ? void 0 : _theme$dateTimeInput.active) || ((_theme$timeInput = theme.timeInput) == null ? void 0 : _theme$timeInput.active);
|
|
9
|
+
};
|
|
10
|
+
export var StyledDateTimeInputContainer = styled(Box).withConfig({
|
|
11
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
12
|
+
return prop !== 'disabled' && prop !== 'readOnlyProp';
|
|
13
|
+
}
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputContainer",
|
|
16
|
+
componentId: "sc-d6m1ya-0"
|
|
17
|
+
})(["", " ", " ", ""], function (props) {
|
|
18
|
+
return props.disabled && disabledStyle();
|
|
19
|
+
}, function (props) {
|
|
20
|
+
return props.readOnlyProp && readOnlyStyle(props.theme);
|
|
21
|
+
}, function (props) {
|
|
22
|
+
return props.focusIndicator !== false && css(["&:focus-within:not(:has(button:focus-visible)){", "}"], focusStyle());
|
|
23
|
+
});
|
|
24
|
+
export var StyledDateTimeInput = styled.input.withConfig(styledComponentsConfig).withConfig({
|
|
25
|
+
displayName: "StyledDateTimeInput",
|
|
26
|
+
componentId: "sc-d6m1ya-1"
|
|
27
|
+
})(["", " ", " position:relative;pointer-events:none;color:transparent;caret-color:transparent;text-shadow:none;&::selection{background:transparent;color:transparent;}&::placeholder{color:transparent;}"], inputStyle, plainInputStyle);
|
|
28
|
+
export var StyledDateTimeInputField = styled.div.withConfig(styledComponentsConfig).withConfig({
|
|
29
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputField",
|
|
30
|
+
componentId: "sc-d6m1ya-2"
|
|
31
|
+
})(["position:relative;flex:1 1 auto;min-width:0;"]);
|
|
32
|
+
export var StyledDateTimeInputDisplay = styled.div.withConfig(styledComponentsConfig).withConfig({
|
|
33
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputDisplay",
|
|
34
|
+
componentId: "sc-d6m1ya-3"
|
|
35
|
+
})(["position:absolute;inset:0;display:flex;align-items:center;overflow:hidden;", ""], function (props) {
|
|
36
|
+
return props.theme.global.input.padding && (typeof props.theme.global.input.padding !== 'object' ? "padding: " + (parseMetricToNum(props.theme.global.edgeSize[props.theme.global.input.padding] || props.theme.global.input.padding) - parseMetricToNum(props.theme.global.control.border.width)) + "px;" : edgeStyle('padding', props.theme.global.input.padding, props.responsive, props.theme.box.responsiveBreakpoint, props.theme));
|
|
37
|
+
});
|
|
38
|
+
export var StyledDateTimeInputSeparator = styled.span.withConfig(styledComponentsConfig).withConfig({
|
|
39
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputSeparator",
|
|
40
|
+
componentId: "sc-d6m1ya-4"
|
|
41
|
+
})(["display:inline-flex;align-items:center;line-height:inherit;color:", ";padding-inline:", ";", ""], function (props) {
|
|
42
|
+
return normalizeColor(props.$filled ? 'text' : props.theme.global.colors.placeholder, props.theme);
|
|
43
|
+
}, function (props) {
|
|
44
|
+
return props.$paddingInline;
|
|
45
|
+
}, function (props) {
|
|
46
|
+
var weight = props.theme.global.input.weight || props.theme.global.input.font.weight;
|
|
47
|
+
return weight && "font-weight: " + weight + ";";
|
|
48
|
+
});
|
|
49
|
+
export var StyledDateTimeInputSegment = styled.span.withConfig(styledComponentsConfig).withConfig({
|
|
50
|
+
displayName: "StyledDateTimeInput__StyledDateTimeInputSegment",
|
|
51
|
+
componentId: "sc-d6m1ya-5"
|
|
52
|
+
})(["&:focus{outline:none;}display:inline-flex;align-items:center;position:relative;line-height:inherit;color:", ";", " ", ""], function (props) {
|
|
53
|
+
return normalizeColor(props.$filled ? 'text' : props.theme.global.colors.placeholder, props.theme);
|
|
54
|
+
}, function (props) {
|
|
55
|
+
var weight = props.theme.global.input.weight || props.theme.global.input.font.weight;
|
|
56
|
+
return weight && "font-weight: " + weight + ";";
|
|
57
|
+
}, function (props) {
|
|
58
|
+
var _props$theme$global$e, _activeTokens$indicat, _props$theme$global$b, _props$theme$global$e2, _activeTokens$indicat2;
|
|
59
|
+
if (!props.$active) return '';
|
|
60
|
+
var activeTokens = getActiveTokens(props.theme);
|
|
61
|
+
var activeRound = (_props$theme$global$e = props.theme.global.edgeSize) == null ? void 0 : _props$theme$global$e.hair;
|
|
62
|
+
var activeBorderToken = activeTokens == null || (_activeTokens$indicat = activeTokens.indicator) == null ? void 0 : _activeTokens$indicat.size;
|
|
63
|
+
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;
|
|
64
|
+
return 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:", ";}"], normalizeColor(activeTokens == null ? void 0 : activeTokens.background, props.theme), activeRound, activeRound, activeBorderSize, normalizeColor((activeTokens == null || (_activeTokens$indicat2 = activeTokens.indicator) == null ? void 0 : _activeTokens$indicat2.color) || {
|
|
65
|
+
dark: 'white',
|
|
66
|
+
light: 'black'
|
|
67
|
+
}, props.theme), activeRound, activeRound);
|
|
68
|
+
});
|
|
@@ -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,36 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
var PropType = {};
|
|
5
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6
|
+
PropType = {
|
|
7
|
+
defaultValue: PropTypes.string,
|
|
8
|
+
disabled: PropTypes.bool,
|
|
9
|
+
format: PropTypes.oneOf(['12', '24']),
|
|
10
|
+
id: PropTypes.string,
|
|
11
|
+
locale: PropTypes.string,
|
|
12
|
+
inline: PropTypes.bool,
|
|
13
|
+
messages: PropTypes.shape({
|
|
14
|
+
activeSection: PropTypes.string,
|
|
15
|
+
activeSectionValue: PropTypes.string,
|
|
16
|
+
chooseDateTime: PropTypes.string,
|
|
17
|
+
inputLabel: PropTypes.string,
|
|
18
|
+
invalidDateTime: PropTypes.string,
|
|
19
|
+
openDrop: PropTypes.string,
|
|
20
|
+
sectionDay: PropTypes.string,
|
|
21
|
+
sectionHours: PropTypes.string,
|
|
22
|
+
sectionMeridiem: PropTypes.string,
|
|
23
|
+
sectionMinutes: PropTypes.string,
|
|
24
|
+
sectionMonth: PropTypes.string,
|
|
25
|
+
sectionSeconds: PropTypes.string,
|
|
26
|
+
sectionYear: PropTypes.string
|
|
27
|
+
}),
|
|
28
|
+
minuteStep: PropTypes.number,
|
|
29
|
+
name: PropTypes.string,
|
|
30
|
+
onChange: PropTypes.func,
|
|
31
|
+
readOnly: PropTypes.bool,
|
|
32
|
+
showSeconds: PropTypes.bool,
|
|
33
|
+
value: PropTypes.string
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export var 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
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var _excluded = ["children", "errors", "infos", "messages", "kind", "onChange", "onReset", "onSubmit", "onValidate", "validate", "value"];
|
|
2
2
|
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; }
|
|
3
3
|
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); }
|
|
4
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
6
|
import React, { forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
7
|
import { useAnalytics } from '../../contexts';
|
|
6
8
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
@@ -506,8 +508,8 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
506
508
|
useValue = componentValue;else if (valueProp && name && formValue !== undefined)
|
|
507
509
|
// form drives, pattern #1
|
|
508
510
|
useValue = formValue;else if (formValue === undefined && name)
|
|
509
|
-
// form
|
|
510
|
-
useValue = initialValue;else useValue = inputValue;
|
|
511
|
+
// controlled form: keep input controlled; uncontrolled: reset
|
|
512
|
+
useValue = valueProp !== undefined ? initialValue != null ? initialValue : '' : initialValue;else useValue = inputValue;
|
|
511
513
|
return [useValue, function (nextComponentValue) {
|
|
512
514
|
if (name) {
|
|
513
515
|
// we have somewhere to put this
|
|
@@ -672,7 +674,9 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
672
674
|
// Show form's validity when clicking on Submit
|
|
673
675
|
valid: buildValid(nextErrors)
|
|
674
676
|
};
|
|
675
|
-
if (onValidate) onValidate(
|
|
677
|
+
if (onValidate) onValidate(_extends({
|
|
678
|
+
submitting: true
|
|
679
|
+
}, nextValidationResults));
|
|
676
680
|
validationResultsRef.current = nextValidationResults;
|
|
677
681
|
updateAnalytics();
|
|
678
682
|
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;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
import React from 'react';
|
|
2
|
-
import { Box, Button, Form, FormField,
|
|
4
|
+
import { Box, Button, Form, FormField, TextInput } from 'grommet';
|
|
3
5
|
|
|
4
6
|
// This example shows a way to perform validation across multiple fields.
|
|
5
7
|
export var AggregateValidation = function AggregateValidation() {
|
|
@@ -43,18 +45,13 @@ export var AggregateValidation = function AggregateValidation() {
|
|
|
43
45
|
htmlFor: "email",
|
|
44
46
|
label: "Email",
|
|
45
47
|
name: "email",
|
|
46
|
-
required: true
|
|
48
|
+
required: true,
|
|
49
|
+
error: message
|
|
47
50
|
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
48
51
|
id: "email",
|
|
49
52
|
name: "email",
|
|
50
53
|
type: "email"
|
|
51
|
-
})),
|
|
52
|
-
pad: {
|
|
53
|
-
horizontal: 'small'
|
|
54
|
-
}
|
|
55
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
56
|
-
color: "status-error"
|
|
57
|
-
}, message)), /*#__PURE__*/React.createElement(Box, {
|
|
54
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
58
55
|
direction: "row",
|
|
59
56
|
justify: "between",
|
|
60
57
|
margin: {
|