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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Search } from 'grommet-icons';
|
|
4
|
-
import { Box, Grommet, Image, Text, TextInput } from 'grommet';
|
|
5
|
-
import { grommet, ThemeType } from 'grommet/themes';
|
|
6
|
-
import { deepMerge } from 'grommet/utils';
|
|
7
|
-
|
|
8
|
-
// Type annotations can only be used in TypeScript files.
|
|
9
|
-
// Remove ': ThemeType' if you are not using Typescript.
|
|
10
|
-
const myCustomTheme: ThemeType = deepMerge(grommet, {
|
|
11
|
-
global: {
|
|
12
|
-
drop: {
|
|
13
|
-
background: '#444444',
|
|
14
|
-
shadowSize: 'medium',
|
|
15
|
-
extend: `
|
|
16
|
-
border-bottom-left-radius: 12px;
|
|
17
|
-
border-bottom-right-radius: 12px;
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
elevation: {
|
|
22
|
-
dark: {
|
|
23
|
-
medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
|
|
24
|
-
},
|
|
25
|
-
light: {
|
|
26
|
-
medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
font: {
|
|
30
|
-
size: '14px',
|
|
31
|
-
family: 'Arial',
|
|
32
|
-
},
|
|
33
|
-
input: {
|
|
34
|
-
weight: 400,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const folks = [
|
|
40
|
-
{
|
|
41
|
-
name: 'Alan Souza',
|
|
42
|
-
imageUrl:
|
|
43
|
-
'https://s.gravatar.com/avatar/b226da5c619b18b44eb95c30be393953?s=80',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'Bryan Jacquot',
|
|
47
|
-
imageUrl:
|
|
48
|
-
'https://s.gravatar.com/avatar/10d15019166606cfed23846a7f902660?s=80',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'Chris Carlozzi',
|
|
52
|
-
imageUrl:
|
|
53
|
-
'https://s.gravatar.com/avatar/56ea1e2ecd0d3cc85479b2d09e31d071?s=80',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'Eric Soderberg',
|
|
57
|
-
imageUrl:
|
|
58
|
-
'https://s.gravatar.com/avatar/99020cae7ff399a4fbea19c0634f77c3?s=80',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'Marlon Parizzotto',
|
|
62
|
-
imageUrl:
|
|
63
|
-
'https://s.gravatar.com/avatar/e6684969375a4dcc0aa99f0bfae544c3?s=80',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'Tales Chaves',
|
|
67
|
-
imageUrl:
|
|
68
|
-
'https://s.gravatar.com/avatar/1f80adca55d9f5d97932ff97f631a4e8?s=80',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: 'Tracy Barmore',
|
|
72
|
-
imageUrl:
|
|
73
|
-
'https://s.gravatar.com/avatar/4ec9c3a91da89f278e4482811caad7f3?s=80',
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
const formatSuggestions = (suggestedFolks, value) =>
|
|
78
|
-
suggestedFolks
|
|
79
|
-
.filter(({ name }) => name.toLowerCase().indexOf(value.toLowerCase()) >= 0)
|
|
80
|
-
.map(({ name, imageUrl }, index, list) => ({
|
|
81
|
-
label: (
|
|
82
|
-
<Box
|
|
83
|
-
direction="row"
|
|
84
|
-
align="center"
|
|
85
|
-
gap="small"
|
|
86
|
-
border={index < list.length - 1 ? 'bottom' : undefined}
|
|
87
|
-
pad="small"
|
|
88
|
-
>
|
|
89
|
-
<Image width="48px" src={imageUrl} style={{ borderRadius: '100%' }} />
|
|
90
|
-
<Text>
|
|
91
|
-
<strong>{name}</strong>
|
|
92
|
-
</Text>
|
|
93
|
-
</Box>
|
|
94
|
-
),
|
|
95
|
-
value: name,
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
export const CustomSuggestions = () => {
|
|
99
|
-
const [value, setValue] = useState('');
|
|
100
|
-
const [suggestionOpen, setSuggestionOpen] = useState(false);
|
|
101
|
-
const [suggestions, setSuggestions] = useState([]);
|
|
102
|
-
const boxRef = useRef(undefined);
|
|
103
|
-
|
|
104
|
-
const onChange = useCallback((event) => {
|
|
105
|
-
const { value: newValue } = event.target;
|
|
106
|
-
setValue(newValue);
|
|
107
|
-
|
|
108
|
-
if (!newValue.trim()) {
|
|
109
|
-
setSuggestions([]);
|
|
110
|
-
} else {
|
|
111
|
-
// simulate an async call to the backend
|
|
112
|
-
setTimeout(() => {
|
|
113
|
-
setSuggestions(formatSuggestions(folks, newValue));
|
|
114
|
-
}, 300);
|
|
115
|
-
}
|
|
116
|
-
}, []);
|
|
117
|
-
|
|
118
|
-
const onSuggestionSelect = useCallback(
|
|
119
|
-
(event) => setValue(event.suggestion.value),
|
|
120
|
-
[],
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const onSuggestionsOpen = useCallback(() => {
|
|
124
|
-
setSuggestions(formatSuggestions(folks, value));
|
|
125
|
-
setSuggestionOpen(true);
|
|
126
|
-
}, [value]);
|
|
127
|
-
|
|
128
|
-
const onSuggestionsClose = useCallback(() => {
|
|
129
|
-
setSuggestions([]);
|
|
130
|
-
setSuggestionOpen(false);
|
|
131
|
-
}, []);
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<Grommet full theme={myCustomTheme}>
|
|
135
|
-
<Box background="dark-1" fill align="center" pad={{ top: 'large' }}>
|
|
136
|
-
<Box
|
|
137
|
-
ref={boxRef}
|
|
138
|
-
width="large"
|
|
139
|
-
direction="row"
|
|
140
|
-
align="center"
|
|
141
|
-
pad={{ horizontal: 'small', vertical: 'xsmall' }}
|
|
142
|
-
round="small"
|
|
143
|
-
elevation={suggestionOpen ? 'medium' : undefined}
|
|
144
|
-
border={{
|
|
145
|
-
side: 'all',
|
|
146
|
-
color: suggestionOpen ? 'transparent' : 'border',
|
|
147
|
-
}}
|
|
148
|
-
style={
|
|
149
|
-
suggestionOpen
|
|
150
|
-
? {
|
|
151
|
-
borderBottomLeftRadius: '0px',
|
|
152
|
-
borderBottomRightRadius: '0px',
|
|
153
|
-
}
|
|
154
|
-
: undefined
|
|
155
|
-
}
|
|
156
|
-
>
|
|
157
|
-
<Search color="brand" />
|
|
158
|
-
<TextInput
|
|
159
|
-
id="grommet-custom-suggestions"
|
|
160
|
-
dropTarget={boxRef.current}
|
|
161
|
-
placeholder="Enter your name..."
|
|
162
|
-
plain
|
|
163
|
-
suggestions={suggestions}
|
|
164
|
-
value={value}
|
|
165
|
-
onChange={onChange}
|
|
166
|
-
onSuggestionsOpen={onSuggestionsOpen}
|
|
167
|
-
onSuggestionsClose={onSuggestionsClose}
|
|
168
|
-
onSuggestionSelect={onSuggestionSelect}
|
|
169
|
-
/>
|
|
170
|
-
</Box>
|
|
171
|
-
</Box>
|
|
172
|
-
</Grommet>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
CustomSuggestions.storyName = 'Custom suggestions';
|
|
177
|
-
|
|
178
|
-
export default {
|
|
179
|
-
title: 'Input/TextInput/Custom Themed/Custom suggestions',
|
|
180
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.Themed = void 0;
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
var _grommet = require("grommet");
|
|
7
|
-
var _themes = require("grommet/themes");
|
|
8
|
-
var _utils = require("grommet/utils");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
var suggestions = Array(100).fill().map(function (_, i) {
|
|
11
|
-
return "suggestion " + (i + 1);
|
|
12
|
-
});
|
|
13
|
-
var customTheme = (0, _utils.deepMerge)(_themes.grommet, {
|
|
14
|
-
global: {
|
|
15
|
-
input: {
|
|
16
|
-
padding: {
|
|
17
|
-
horizontal: 'small',
|
|
18
|
-
vertical: 'medium'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
textInput: {
|
|
23
|
-
extend: function extend() {
|
|
24
|
-
return "\n font-size: 20px;\n background: #c9c19f;\n width: 300px;\n margin: 0 auto;\n\n &:focus {\n box-shadow: none;\n border-color: initial;\n }\n ";
|
|
25
|
-
},
|
|
26
|
-
container: {
|
|
27
|
-
extend: function extend() {
|
|
28
|
-
return "\n background: #edf7d2;\n height: 100px;\n width: 400px;\n display: flex;\n flex-flow: column;\n justify-content: center;\n border-radius: 10px;\n ";
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
placeholder: {
|
|
32
|
-
extend: function extend() {
|
|
33
|
-
return "\n width: 100%;\n color: #1e1a11;\n ";
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
suggestions: {
|
|
37
|
-
extend: function extend() {
|
|
38
|
-
return "\n background: #c9c19f;\n color: #3d3522;\n li {\n border-bottom: 1px solid rgba(0, 0, 0, 0.2);\n }\n ";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
var Themed = exports.Themed = function Themed() {
|
|
44
|
-
var _React$useState = _react["default"].useState(''),
|
|
45
|
-
value = _React$useState[0],
|
|
46
|
-
setValue = _React$useState[1];
|
|
47
|
-
var onChange = function onChange(event) {
|
|
48
|
-
return setValue(event.target.value);
|
|
49
|
-
};
|
|
50
|
-
var onSelect = function onSelect(event) {
|
|
51
|
-
return setValue(event.suggestion);
|
|
52
|
-
};
|
|
53
|
-
return /*#__PURE__*/_react["default"].createElement(_grommet.Grommet, {
|
|
54
|
-
full: true,
|
|
55
|
-
theme: customTheme
|
|
56
|
-
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
57
|
-
fill: true,
|
|
58
|
-
align: "center",
|
|
59
|
-
justify: "start",
|
|
60
|
-
pad: "large"
|
|
61
|
-
}, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
62
|
-
width: "medium"
|
|
63
|
-
}, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
|
|
64
|
-
id: "grommet-password",
|
|
65
|
-
type: "password",
|
|
66
|
-
value: value,
|
|
67
|
-
dropProps: {
|
|
68
|
-
height: 'small'
|
|
69
|
-
},
|
|
70
|
-
onChange: onChange,
|
|
71
|
-
onSelect: onSelect,
|
|
72
|
-
suggestions: suggestions,
|
|
73
|
-
placeholder: /*#__PURE__*/_react["default"].createElement("span", null, "Enter something..."),
|
|
74
|
-
"aria-label": "Input Text"
|
|
75
|
-
}))));
|
|
76
|
-
};
|
|
77
|
-
var _default = exports["default"] = {
|
|
78
|
-
title: 'Input/TextInput/Custom Themed/Themed'
|
|
79
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Search } from 'grommet-icons';
|
|
4
|
-
import { Box, Grommet, Image, Text, TextInput } from 'grommet';
|
|
5
|
-
import { grommet, ThemeType } from 'grommet/themes';
|
|
6
|
-
import { deepMerge } from 'grommet/utils';
|
|
7
|
-
|
|
8
|
-
// Type annotations can only be used in TypeScript files.
|
|
9
|
-
// Remove ': ThemeType' if you are not using Typescript.
|
|
10
|
-
const myCustomTheme: ThemeType = deepMerge(grommet, {
|
|
11
|
-
global: {
|
|
12
|
-
drop: {
|
|
13
|
-
background: '#444444',
|
|
14
|
-
shadowSize: 'medium',
|
|
15
|
-
extend: `
|
|
16
|
-
border-bottom-left-radius: 12px;
|
|
17
|
-
border-bottom-right-radius: 12px;
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
elevation: {
|
|
22
|
-
dark: {
|
|
23
|
-
medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
|
|
24
|
-
},
|
|
25
|
-
light: {
|
|
26
|
-
medium: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
font: {
|
|
30
|
-
size: '14px',
|
|
31
|
-
family: 'Arial',
|
|
32
|
-
},
|
|
33
|
-
input: {
|
|
34
|
-
weight: 400,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const folks = [
|
|
40
|
-
{
|
|
41
|
-
name: 'Alan Souza',
|
|
42
|
-
imageUrl:
|
|
43
|
-
'https://s.gravatar.com/avatar/b226da5c619b18b44eb95c30be393953?s=80',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'Bryan Jacquot',
|
|
47
|
-
imageUrl:
|
|
48
|
-
'https://s.gravatar.com/avatar/10d15019166606cfed23846a7f902660?s=80',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'Chris Carlozzi',
|
|
52
|
-
imageUrl:
|
|
53
|
-
'https://s.gravatar.com/avatar/56ea1e2ecd0d3cc85479b2d09e31d071?s=80',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'Eric Soderberg',
|
|
57
|
-
imageUrl:
|
|
58
|
-
'https://s.gravatar.com/avatar/99020cae7ff399a4fbea19c0634f77c3?s=80',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'Marlon Parizzotto',
|
|
62
|
-
imageUrl:
|
|
63
|
-
'https://s.gravatar.com/avatar/e6684969375a4dcc0aa99f0bfae544c3?s=80',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'Tales Chaves',
|
|
67
|
-
imageUrl:
|
|
68
|
-
'https://s.gravatar.com/avatar/1f80adca55d9f5d97932ff97f631a4e8?s=80',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: 'Tracy Barmore',
|
|
72
|
-
imageUrl:
|
|
73
|
-
'https://s.gravatar.com/avatar/4ec9c3a91da89f278e4482811caad7f3?s=80',
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
const formatSuggestions = (suggestedFolks, value) =>
|
|
78
|
-
suggestedFolks
|
|
79
|
-
.filter(({ name }) => name.toLowerCase().indexOf(value.toLowerCase()) >= 0)
|
|
80
|
-
.map(({ name, imageUrl }, index, list) => ({
|
|
81
|
-
label: (
|
|
82
|
-
<Box
|
|
83
|
-
direction="row"
|
|
84
|
-
align="center"
|
|
85
|
-
gap="small"
|
|
86
|
-
border={index < list.length - 1 ? 'bottom' : undefined}
|
|
87
|
-
pad="small"
|
|
88
|
-
>
|
|
89
|
-
<Image width="48px" src={imageUrl} style={{ borderRadius: '100%' }} />
|
|
90
|
-
<Text>
|
|
91
|
-
<strong>{name}</strong>
|
|
92
|
-
</Text>
|
|
93
|
-
</Box>
|
|
94
|
-
),
|
|
95
|
-
value: name,
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
export const CustomSuggestions = () => {
|
|
99
|
-
const [value, setValue] = useState('');
|
|
100
|
-
const [suggestionOpen, setSuggestionOpen] = useState(false);
|
|
101
|
-
const [suggestions, setSuggestions] = useState([]);
|
|
102
|
-
const boxRef = useRef(undefined);
|
|
103
|
-
|
|
104
|
-
const onChange = useCallback((event) => {
|
|
105
|
-
const { value: newValue } = event.target;
|
|
106
|
-
setValue(newValue);
|
|
107
|
-
|
|
108
|
-
if (!newValue.trim()) {
|
|
109
|
-
setSuggestions([]);
|
|
110
|
-
} else {
|
|
111
|
-
// simulate an async call to the backend
|
|
112
|
-
setTimeout(() => {
|
|
113
|
-
setSuggestions(formatSuggestions(folks, newValue));
|
|
114
|
-
}, 300);
|
|
115
|
-
}
|
|
116
|
-
}, []);
|
|
117
|
-
|
|
118
|
-
const onSuggestionSelect = useCallback(
|
|
119
|
-
(event) => setValue(event.suggestion.value),
|
|
120
|
-
[],
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const onSuggestionsOpen = useCallback(() => {
|
|
124
|
-
setSuggestions(formatSuggestions(folks, value));
|
|
125
|
-
setSuggestionOpen(true);
|
|
126
|
-
}, [value]);
|
|
127
|
-
|
|
128
|
-
const onSuggestionsClose = useCallback(() => {
|
|
129
|
-
setSuggestions([]);
|
|
130
|
-
setSuggestionOpen(false);
|
|
131
|
-
}, []);
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<Grommet full theme={myCustomTheme}>
|
|
135
|
-
<Box background="dark-1" fill align="center" pad={{ top: 'large' }}>
|
|
136
|
-
<Box
|
|
137
|
-
ref={boxRef}
|
|
138
|
-
width="large"
|
|
139
|
-
direction="row"
|
|
140
|
-
align="center"
|
|
141
|
-
pad={{ horizontal: 'small', vertical: 'xsmall' }}
|
|
142
|
-
round="small"
|
|
143
|
-
elevation={suggestionOpen ? 'medium' : undefined}
|
|
144
|
-
border={{
|
|
145
|
-
side: 'all',
|
|
146
|
-
color: suggestionOpen ? 'transparent' : 'border',
|
|
147
|
-
}}
|
|
148
|
-
style={
|
|
149
|
-
suggestionOpen
|
|
150
|
-
? {
|
|
151
|
-
borderBottomLeftRadius: '0px',
|
|
152
|
-
borderBottomRightRadius: '0px',
|
|
153
|
-
}
|
|
154
|
-
: undefined
|
|
155
|
-
}
|
|
156
|
-
>
|
|
157
|
-
<Search color="brand" />
|
|
158
|
-
<TextInput
|
|
159
|
-
id="grommet-custom-suggestions"
|
|
160
|
-
dropTarget={boxRef.current}
|
|
161
|
-
placeholder="Enter your name..."
|
|
162
|
-
plain
|
|
163
|
-
suggestions={suggestions}
|
|
164
|
-
value={value}
|
|
165
|
-
onChange={onChange}
|
|
166
|
-
onSuggestionsOpen={onSuggestionsOpen}
|
|
167
|
-
onSuggestionsClose={onSuggestionsClose}
|
|
168
|
-
onSuggestionSelect={onSuggestionSelect}
|
|
169
|
-
/>
|
|
170
|
-
</Box>
|
|
171
|
-
</Box>
|
|
172
|
-
</Grommet>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
CustomSuggestions.storyName = 'Custom suggestions';
|
|
177
|
-
|
|
178
|
-
export default {
|
|
179
|
-
title: 'Input/TextInput/Custom Themed/Custom suggestions',
|
|
180
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Grommet, TextInput } from 'grommet';
|
|
3
|
-
import { grommet } from 'grommet/themes';
|
|
4
|
-
import { deepMerge } from 'grommet/utils';
|
|
5
|
-
var suggestions = Array(100).fill().map(function (_, i) {
|
|
6
|
-
return "suggestion " + (i + 1);
|
|
7
|
-
});
|
|
8
|
-
var customTheme = deepMerge(grommet, {
|
|
9
|
-
global: {
|
|
10
|
-
input: {
|
|
11
|
-
padding: {
|
|
12
|
-
horizontal: 'small',
|
|
13
|
-
vertical: 'medium'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
textInput: {
|
|
18
|
-
extend: function extend() {
|
|
19
|
-
return "\n font-size: 20px;\n background: #c9c19f;\n width: 300px;\n margin: 0 auto;\n\n &:focus {\n box-shadow: none;\n border-color: initial;\n }\n ";
|
|
20
|
-
},
|
|
21
|
-
container: {
|
|
22
|
-
extend: function extend() {
|
|
23
|
-
return "\n background: #edf7d2;\n height: 100px;\n width: 400px;\n display: flex;\n flex-flow: column;\n justify-content: center;\n border-radius: 10px;\n ";
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
placeholder: {
|
|
27
|
-
extend: function extend() {
|
|
28
|
-
return "\n width: 100%;\n color: #1e1a11;\n ";
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
suggestions: {
|
|
32
|
-
extend: function extend() {
|
|
33
|
-
return "\n background: #c9c19f;\n color: #3d3522;\n li {\n border-bottom: 1px solid rgba(0, 0, 0, 0.2);\n }\n ";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
export var Themed = function Themed() {
|
|
39
|
-
var _React$useState = React.useState(''),
|
|
40
|
-
value = _React$useState[0],
|
|
41
|
-
setValue = _React$useState[1];
|
|
42
|
-
var onChange = function onChange(event) {
|
|
43
|
-
return setValue(event.target.value);
|
|
44
|
-
};
|
|
45
|
-
var onSelect = function onSelect(event) {
|
|
46
|
-
return setValue(event.suggestion);
|
|
47
|
-
};
|
|
48
|
-
return /*#__PURE__*/React.createElement(Grommet, {
|
|
49
|
-
full: true,
|
|
50
|
-
theme: customTheme
|
|
51
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
52
|
-
fill: true,
|
|
53
|
-
align: "center",
|
|
54
|
-
justify: "start",
|
|
55
|
-
pad: "large"
|
|
56
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
57
|
-
width: "medium"
|
|
58
|
-
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
59
|
-
id: "grommet-password",
|
|
60
|
-
type: "password",
|
|
61
|
-
value: value,
|
|
62
|
-
dropProps: {
|
|
63
|
-
height: 'small'
|
|
64
|
-
},
|
|
65
|
-
onChange: onChange,
|
|
66
|
-
onSelect: onSelect,
|
|
67
|
-
suggestions: suggestions,
|
|
68
|
-
placeholder: /*#__PURE__*/React.createElement("span", null, "Enter something..."),
|
|
69
|
-
"aria-label": "Input Text"
|
|
70
|
-
}))));
|
|
71
|
-
};
|
|
72
|
-
export default {
|
|
73
|
-
title: 'Input/TextInput/Custom Themed/Themed'
|
|
74
|
-
};
|