grommet 2.56.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.
Files changed (118) hide show
  1. package/COPYRIGHT.md +3 -1
  2. package/components/Calendar/Calendar.js +2 -1
  3. package/components/Cards/Cards.js +1 -2
  4. package/components/DateTimeInput/DateTimeInput.js +1093 -0
  5. package/components/DateTimeInput/README.md +2 -0
  6. package/components/DateTimeInput/StyledDateTimeInput.js +74 -0
  7. package/components/DateTimeInput/index.d.ts +47 -0
  8. package/components/DateTimeInput/index.js +6 -0
  9. package/components/DateTimeInput/propTypes.js +42 -0
  10. package/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
  11. package/components/DateTimeInput/stories/Form.stories.tsx +44 -0
  12. package/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
  13. package/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
  14. package/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
  15. package/components/Form/Form.js +7 -4
  16. package/components/Form/index.d.ts +3 -0
  17. package/components/Form/stories/AggregateValidation.stories.js +6 -8
  18. package/components/FormField/FormField.js +164 -91
  19. package/components/Stepper/StepConnector.js +19 -49
  20. package/components/Stepper/Stepper.js +5 -11
  21. package/components/Stepper/StepperStep.js +14 -4
  22. package/components/Stepper/StyledStepper.js +59 -21
  23. package/components/TimeInput/TimeInput.js +50 -47
  24. package/components/TimeInput/TimeInputPopup.js +172 -76
  25. package/components/TimeInput/index.d.ts +3 -0
  26. package/components/TimeInput/propTypes.js +4 -0
  27. package/components/TimeInput/useSectionedTimeField.js +33 -34
  28. package/components/TimeInput/utils.js +31 -26
  29. package/components/Wizard/StyledWizard.js +16 -0
  30. package/components/Wizard/Wizard.js +770 -0
  31. package/components/Wizard/WizardContent.js +90 -0
  32. package/components/Wizard/WizardContext.js +35 -0
  33. package/components/Wizard/WizardFooter.js +123 -0
  34. package/components/Wizard/WizardHeader.js +63 -0
  35. package/components/Wizard/WizardProgress.js +84 -0
  36. package/components/Wizard/WizardStepHeader.js +55 -0
  37. package/components/Wizard/index.d.ts +171 -0
  38. package/components/Wizard/index.js +19 -0
  39. package/components/Wizard/propTypes.js +56 -0
  40. package/components/Wizard/stories/BasicLinear.stories.js +71 -0
  41. package/components/Wizard/stories/Branching.stories.js +96 -0
  42. package/components/Wizard/stories/Composable.stories.js +75 -0
  43. package/components/Wizard/stories/Controlled.stories.js +136 -0
  44. package/components/Wizard/stories/LongContent.stories.js +118 -0
  45. package/components/Wizard/stories/Modal.stories.js +143 -0
  46. package/components/Wizard/stories/NestedSubSteps.stories.js +79 -0
  47. package/components/Wizard/stories/Validation.stories.js +123 -0
  48. package/components/index.d.ts +4 -0
  49. package/components/index.js +12 -0
  50. package/es6/components/Calendar/Calendar.js +2 -0
  51. package/es6/components/Cards/Cards.js +1 -2
  52. package/es6/components/DateTimeInput/DateTimeInput.js +1090 -0
  53. package/es6/components/DateTimeInput/README.md +2 -0
  54. package/es6/components/DateTimeInput/StyledDateTimeInput.js +68 -0
  55. package/es6/components/DateTimeInput/index.d.ts +47 -0
  56. package/es6/components/DateTimeInput/index.js +3 -0
  57. package/es6/components/DateTimeInput/propTypes.js +36 -0
  58. package/es6/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
  59. package/es6/components/DateTimeInput/stories/Form.stories.tsx +44 -0
  60. package/es6/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
  61. package/es6/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
  62. package/es6/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
  63. package/es6/components/Form/Form.js +7 -3
  64. package/es6/components/Form/index.d.ts +3 -0
  65. package/es6/components/Form/stories/AggregateValidation.stories.js +6 -9
  66. package/es6/components/FormField/FormField.js +165 -91
  67. package/es6/components/Stepper/StepConnector.js +18 -48
  68. package/es6/components/Stepper/Stepper.js +5 -10
  69. package/es6/components/Stepper/StepperStep.js +15 -4
  70. package/es6/components/Stepper/StyledStepper.js +57 -21
  71. package/es6/components/TimeInput/TimeInput.js +50 -46
  72. package/es6/components/TimeInput/TimeInputPopup.js +172 -76
  73. package/es6/components/TimeInput/index.d.ts +3 -0
  74. package/es6/components/TimeInput/propTypes.js +3 -0
  75. package/es6/components/TimeInput/useSectionedTimeField.js +34 -35
  76. package/es6/components/TimeInput/utils.js +25 -21
  77. package/es6/components/Wizard/StyledWizard.js +11 -0
  78. package/es6/components/Wizard/Wizard.js +768 -0
  79. package/es6/components/Wizard/WizardContent.js +87 -0
  80. package/es6/components/Wizard/WizardContext.js +31 -0
  81. package/es6/components/Wizard/WizardFooter.js +120 -0
  82. package/es6/components/Wizard/WizardHeader.js +60 -0
  83. package/es6/components/Wizard/WizardProgress.js +80 -0
  84. package/es6/components/Wizard/WizardStepHeader.js +51 -0
  85. package/es6/components/Wizard/index.d.ts +171 -0
  86. package/es6/components/Wizard/index.js +7 -0
  87. package/es6/components/Wizard/propTypes.js +51 -0
  88. package/es6/components/Wizard/stories/BasicLinear.stories.js +67 -0
  89. package/es6/components/Wizard/stories/Branching.stories.js +93 -0
  90. package/es6/components/Wizard/stories/Composable.stories.js +72 -0
  91. package/es6/components/Wizard/stories/Controlled.stories.js +133 -0
  92. package/es6/components/Wizard/stories/LongContent.stories.js +115 -0
  93. package/es6/components/Wizard/stories/Modal.stories.js +141 -0
  94. package/es6/components/Wizard/stories/NestedSubSteps.stories.js +76 -0
  95. package/es6/components/Wizard/stories/Validation.stories.js +118 -0
  96. package/es6/components/index.d.ts +4 -0
  97. package/es6/components/index.js +4 -0
  98. package/es6/index.d.ts +4 -0
  99. package/es6/languages/default.json +28 -0
  100. package/es6/themes/base.d.ts +115 -0
  101. package/es6/themes/base.js +158 -0
  102. package/es6/utils/DOM.js +11 -2
  103. package/es6/utils/dates.js +10 -0
  104. package/es6/utils/sectionHelpers.js +57 -0
  105. package/es6/utils/useSectionedField.js +45 -0
  106. package/grommet.min.js +2 -1
  107. package/grommet.min.js.LICENSE.txt +1 -0
  108. package/grommet.min.js.map +1 -1
  109. package/index.d.ts +4 -0
  110. package/languages/default.json +28 -0
  111. package/package.json +35 -31
  112. package/themes/base.d.ts +115 -0
  113. package/themes/base.js +158 -1
  114. package/tools/license-header.js +2 -0
  115. package/utils/DOM.js +11 -2
  116. package/utils/dates.js +11 -1
  117. package/utils/sectionHelpers.js +61 -0
  118. package/utils/useSectionedField.js +50 -0
@@ -0,0 +1,2 @@
1
+ ## DateTimeInput
2
+ Documentation for this component: https://v2.grommet.io/datetimeinput
@@ -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,6 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.DateTimeInput = void 0;
5
+ var _DateTimeInput = require("./DateTimeInput");
6
+ exports.DateTimeInput = _DateTimeInput.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
+ };
@@ -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 has reset, so reset input value as well
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(nextValidationResults);
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
- })), message && /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
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: {