grommet 2.25.3 → 2.26.0
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/components/Box/stories/BackgroundThemed.js +54 -0
- package/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
- package/components/Calendar/Calendar.js +2 -1
- package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/components/CheckBoxGroup/index.d.ts +2 -1
- package/components/CheckBoxGroup/propTypes.js +1 -0
- package/components/FormField/FormField.js +1 -1
- package/components/Heading/Heading.js +31 -2
- package/components/Heading/StyledHeading.js +1 -1
- package/components/Heading/index.d.ts +1 -0
- package/components/Heading/propTypes.js +1 -0
- package/components/Heading/stories/All.js +4 -1
- package/components/List/List.js +114 -33
- package/components/List/index.d.ts +1 -0
- package/components/List/propTypes.js +1 -0
- package/components/List/stories/Pinned.js +36 -0
- package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/components/Select/DefaultSelectTextInput.js +43 -0
- package/components/Select/EmptySearchOption.js +34 -0
- package/components/Select/Select.js +30 -95
- package/components/Select/SelectContainer.js +19 -59
- package/components/Select/StyledSelect.js +58 -2
- package/components/Select/index.d.ts +11 -9
- package/components/Select/propTypes.js +44 -40
- package/components/Select/utils.js +103 -3
- package/components/SelectMultiple/README.md +2 -0
- package/components/SelectMultiple/SelectMultiple.js +476 -0
- package/components/SelectMultiple/SelectMultipleContainer.js +481 -0
- package/components/SelectMultiple/SelectMultipleValue.js +166 -0
- package/components/SelectMultiple/SelectionSummary.js +104 -0
- package/components/SelectMultiple/index.d.ts +21 -0
- package/components/SelectMultiple/index.js +8 -0
- package/components/SelectMultiple/propTypes.js +28 -0
- package/components/SelectMultiple/stories/Default.js +76 -0
- package/components/SelectMultiple/stories/Disabled.js +84 -0
- package/components/SelectMultiple/stories/FormField.js +66 -0
- package/components/SelectMultiple/stories/Limited.js +68 -0
- package/components/SelectMultiple/stories/LongList.js +76 -0
- package/components/SelectMultiple/stories/ObjectOptions.js +80 -0
- package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
- package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +8 -0
- package/es6/components/Box/stories/BackgroundThemed.js +39 -0
- package/es6/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
- package/es6/components/Calendar/Calendar.js +2 -1
- package/es6/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/es6/components/CheckBoxGroup/index.d.ts +2 -1
- package/es6/components/CheckBoxGroup/propTypes.js +1 -0
- package/es6/components/FormField/FormField.js +1 -1
- package/es6/components/Heading/Heading.js +30 -3
- package/es6/components/Heading/StyledHeading.js +1 -1
- package/es6/components/Heading/index.d.ts +1 -0
- package/es6/components/Heading/propTypes.js +1 -0
- package/es6/components/Heading/stories/All.js +4 -1
- package/es6/components/List/List.js +115 -34
- package/es6/components/List/index.d.ts +1 -0
- package/es6/components/List/propTypes.js +1 -0
- package/es6/components/List/stories/Pinned.js +21 -0
- package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/es6/components/Select/DefaultSelectTextInput.js +31 -0
- package/es6/components/Select/EmptySearchOption.js +21 -0
- package/es6/components/Select/Select.js +26 -89
- package/es6/components/Select/SelectContainer.js +19 -58
- package/es6/components/Select/StyledSelect.js +45 -1
- package/es6/components/Select/index.d.ts +11 -9
- package/es6/components/Select/propTypes.js +41 -39
- package/es6/components/Select/utils.js +75 -1
- package/es6/components/SelectMultiple/README.md +2 -0
- package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +453 -0
- package/es6/components/SelectMultiple/SelectMultipleValue.js +152 -0
- package/es6/components/SelectMultiple/SelectionSummary.js +91 -0
- package/es6/components/SelectMultiple/index.d.ts +21 -0
- package/es6/components/SelectMultiple/index.js +1 -0
- package/es6/components/SelectMultiple/propTypes.js +18 -0
- package/es6/components/SelectMultiple/stories/Default.js +60 -0
- package/es6/components/SelectMultiple/stories/Disabled.js +68 -0
- package/es6/components/SelectMultiple/stories/FormField.js +50 -0
- package/es6/components/SelectMultiple/stories/Limited.js +53 -0
- package/es6/components/SelectMultiple/stories/LongList.js +63 -0
- package/es6/components/SelectMultiple/stories/ObjectOptions.js +64 -0
- package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
- package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/index.d.ts +1 -0
- package/es6/themes/base.d.ts +8 -2
- package/es6/themes/base.js +54 -38
- package/es6/themes/grommet.js +15 -0
- package/es6/utils/background.js +65 -12
- package/es6/utils/general-prop-types.js +2 -0
- package/es6/utils/index.d.ts +2 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +4 -3
- package/themes/base.d.ts +8 -2
- package/themes/base.js +55 -38
- package/themes/grommet.js +15 -0
- package/utils/background.js +64 -12
- package/utils/general-prop-types.js +2 -0
- package/utils/index.d.ts +2 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.BackgroundThemed = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _grommet = require("grommet");
|
|
9
|
+
|
|
10
|
+
var _Grid = require("../../Grid");
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
16
|
+
var BackgroundThemed = function BackgroundThemed() {
|
|
17
|
+
var theme = (0, _react.useContext)(_grommet.ThemeContext);
|
|
18
|
+
var backgrounds = theme.global.backgrounds;
|
|
19
|
+
return (// Uncomment <Grommet> lines when using outside of storybook
|
|
20
|
+
// <Grommet>
|
|
21
|
+
backgrounds ? /*#__PURE__*/_react["default"].createElement(_Grid.Grid, {
|
|
22
|
+
columns: "small",
|
|
23
|
+
rows: "small",
|
|
24
|
+
gap: "small",
|
|
25
|
+
pad: "large"
|
|
26
|
+
}, Object.entries(backgrounds).map(function (_ref) {
|
|
27
|
+
var key = _ref[0],
|
|
28
|
+
background = _ref[1];
|
|
29
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
30
|
+
key: key,
|
|
31
|
+
background: background,
|
|
32
|
+
fill: true,
|
|
33
|
+
pad: "medium",
|
|
34
|
+
justify: "center",
|
|
35
|
+
round: "small"
|
|
36
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
|
|
37
|
+
weight: "bold",
|
|
38
|
+
size: "large"
|
|
39
|
+
}, key));
|
|
40
|
+
})) : /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
41
|
+
pad: "large"
|
|
42
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, {
|
|
43
|
+
size: "large"
|
|
44
|
+
}, "There are no backgrounds defined at `theme.global.backgrounds` for the currently selected theme. Selecting \"grommet\" from the Theme menu above is a good place to start.")) // </Grommet>
|
|
45
|
+
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.BackgroundThemed = BackgroundThemed;
|
|
50
|
+
BackgroundThemed.storyName = 'Background from theme';
|
|
51
|
+
var _default = {
|
|
52
|
+
title: 'Layout/Box/Background from theme'
|
|
53
|
+
};
|
|
54
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Grommet, Box, Grid, Text } from 'grommet';
|
|
4
|
+
import { ThemeType } from 'grommet/themes';
|
|
5
|
+
|
|
6
|
+
const myTheme: ThemeType = {
|
|
7
|
+
global: {
|
|
8
|
+
backgrounds: {
|
|
9
|
+
hex: '#555555',
|
|
10
|
+
themeColor: 'accent-1',
|
|
11
|
+
image: `url(https://images.unsplash.com/photo-1583530015497-6cf9ef9c6f0f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80)`,
|
|
12
|
+
'dark-light-image': {
|
|
13
|
+
dark: `url(https://images.unsplash.com/photo-1620744209976-74accdabd814?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=687&q=80)`,
|
|
14
|
+
light: `url(https://images.unsplash.com/photo-1646723504943-4b55a30ed655?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1471&q=80)`,
|
|
15
|
+
},
|
|
16
|
+
gradient: `linear-gradient(
|
|
17
|
+
80deg,
|
|
18
|
+
hsl(41deg 100% 67%) 0%,
|
|
19
|
+
hsl(333deg 100% 70%) 33%,
|
|
20
|
+
hsl(257deg 99% 73%) 67%,
|
|
21
|
+
hsl(173deg 95% 75%) 100%
|
|
22
|
+
);`,
|
|
23
|
+
object: {
|
|
24
|
+
color: 'white',
|
|
25
|
+
image: `url(https://images.unsplash.com/photo-1464820453369-31d2c0b651af?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=80&q=80)`,
|
|
26
|
+
repeat: 'repeat',
|
|
27
|
+
size: '24px',
|
|
28
|
+
opacity: true,
|
|
29
|
+
},
|
|
30
|
+
stack: {
|
|
31
|
+
color: 'light-1',
|
|
32
|
+
image: `url(https://v2.grommet.io/img/stak-hurrah.svg)`,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const backgroundSamples = [
|
|
39
|
+
{
|
|
40
|
+
background: '#F8F8F8',
|
|
41
|
+
label: { value: 'hex value', context: 'prop string' },
|
|
42
|
+
},
|
|
43
|
+
{ background: 'hex', label: { value: 'hex value', context: 'theme string' } },
|
|
44
|
+
{
|
|
45
|
+
background: 'accent-4',
|
|
46
|
+
label: { value: 'color name', context: 'prop string' },
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
background: 'themeColor',
|
|
50
|
+
label: { value: 'color name', context: 'theme string' },
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
background: `url(https://images.unsplash.com/photo-1493552832879-f61d5dce6c9e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80)`,
|
|
54
|
+
label: { value: 'image', context: 'prop string' },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
background: 'image',
|
|
58
|
+
label: { value: 'image', context: 'theme string' },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
background: {
|
|
62
|
+
color: 'light-1',
|
|
63
|
+
},
|
|
64
|
+
label: { value: 'hover', context: 'over me' },
|
|
65
|
+
onClick: () => {},
|
|
66
|
+
hoverIndicator: 'stack',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
background: `linear-gradient(
|
|
70
|
+
155deg,
|
|
71
|
+
hsl(147deg 100% 72%) 0%,
|
|
72
|
+
hsl(223deg 100% 72%) 50%,
|
|
73
|
+
hsl(299deg 100% 72%) 100%
|
|
74
|
+
);`,
|
|
75
|
+
label: { value: 'gradient', context: 'prop string' },
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
background: 'gradient',
|
|
79
|
+
label: { value: 'gradient', context: 'theme string' },
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
background: { dark: 'accent-2', light: 'accent-3' },
|
|
83
|
+
label: { value: 'dark-light object', context: 'prop object' },
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
background: 'dark-light-image',
|
|
87
|
+
label: { value: 'dark-light object', context: 'theme object' },
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
background: {
|
|
91
|
+
image: 'dark-light-image',
|
|
92
|
+
dark: true,
|
|
93
|
+
color: { dark: 'black', light: 'gold' },
|
|
94
|
+
},
|
|
95
|
+
label: { value: 'dark-light object force dark', context: 'theme object' },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
background: {
|
|
99
|
+
color: 'neutral-2',
|
|
100
|
+
image: `url(https://images.unsplash.com/photo-1653023500770-3a3b64a1b4c4?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1632&q=80)`,
|
|
101
|
+
position: 'top-left',
|
|
102
|
+
},
|
|
103
|
+
label: { value: 'object', context: 'prop object' },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
background: 'object',
|
|
107
|
+
label: { value: 'object', context: 'theme object' },
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
background: { image: 'gradient', rotate: 180 },
|
|
111
|
+
label: { value: 'rotate', context: 'prop object' },
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
background: {
|
|
115
|
+
image: 'gradient',
|
|
116
|
+
rotate: -90,
|
|
117
|
+
clip: 'text',
|
|
118
|
+
},
|
|
119
|
+
label: {
|
|
120
|
+
value: <Text size="xxlarge">clip text</Text>,
|
|
121
|
+
context: <Text size="medium">prop object</Text>,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
background: {
|
|
126
|
+
image: 'image',
|
|
127
|
+
rotate: -90,
|
|
128
|
+
clip: 'text',
|
|
129
|
+
},
|
|
130
|
+
label: {
|
|
131
|
+
value: <Text size="xxlarge">clip text</Text>,
|
|
132
|
+
context: <Text size="medium">prop object</Text>,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
const Swatch = ({ label, ...rest }) => (
|
|
138
|
+
<Box fill pad="medium" justify="center" round="small" {...rest}>
|
|
139
|
+
<Text weight="bold" size="large">
|
|
140
|
+
{label.value}
|
|
141
|
+
</Text>
|
|
142
|
+
<Text size="small">{label.context}</Text>
|
|
143
|
+
</Box>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
export const ThemedBackgrounds = () => (
|
|
147
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
148
|
+
<Grommet
|
|
149
|
+
theme={myTheme}
|
|
150
|
+
full
|
|
151
|
+
background={`linear-gradient(
|
|
152
|
+
155deg,
|
|
153
|
+
hsl(0deg 0% 51%) 0%,
|
|
154
|
+
hsl(0deg 0% 76%) 50%,
|
|
155
|
+
hsl(0deg 0% 100%) 100%
|
|
156
|
+
)`}
|
|
157
|
+
>
|
|
158
|
+
<Grid columns="small" rows="small" gap="small" pad="large">
|
|
159
|
+
{backgroundSamples.map((sample, index) => (
|
|
160
|
+
<Swatch
|
|
161
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
162
|
+
key={index}
|
|
163
|
+
background={sample.background}
|
|
164
|
+
label={sample.label}
|
|
165
|
+
{...sample}
|
|
166
|
+
/>
|
|
167
|
+
))}
|
|
168
|
+
</Grid>
|
|
169
|
+
</Grommet>
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
ThemedBackgrounds.storyName = 'Themed Background';
|
|
173
|
+
|
|
174
|
+
export default {
|
|
175
|
+
title: 'Layout/Box/Custom Themed/Themed Background',
|
|
176
|
+
};
|
|
@@ -569,7 +569,8 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
569
569
|
}, /*#__PURE__*/_react["default"].createElement(_Heading.Heading, {
|
|
570
570
|
level: size === 'small' ? theme.calendar.heading && theme.calendar.heading.level || 4 : (theme.calendar.heading && theme.calendar.heading.level || 4) - 1,
|
|
571
571
|
size: size,
|
|
572
|
-
margin: "none"
|
|
572
|
+
margin: "none",
|
|
573
|
+
overflowWrap: "normal"
|
|
573
574
|
}, reference.toLocaleDateString(locale, {
|
|
574
575
|
month: 'long',
|
|
575
576
|
year: 'numeric'
|
|
@@ -15,7 +15,7 @@ var _StyledCheckBoxGroup = require("./StyledCheckBoxGroup");
|
|
|
15
15
|
|
|
16
16
|
var _propTypes = require("./propTypes");
|
|
17
17
|
|
|
18
|
-
var _excluded = ["children", "value", "disabled", "focusIndicator", "gap", "labelKey", "valueKey", "onChange", "options", "name"],
|
|
18
|
+
var _excluded = ["children", "defaultValue", "value", "disabled", "focusIndicator", "gap", "labelKey", "valueKey", "onChange", "options", "name"],
|
|
19
19
|
_excluded2 = ["value"];
|
|
20
20
|
|
|
21
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -28,6 +28,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
28
28
|
|
|
29
29
|
var CheckBoxGroup = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
30
30
|
var children = _ref.children,
|
|
31
|
+
defaultValue = _ref.defaultValue,
|
|
31
32
|
valueProp = _ref.value,
|
|
32
33
|
disabledProp = _ref.disabled,
|
|
33
34
|
_ref$focusIndicator = _ref.focusIndicator,
|
|
@@ -54,7 +55,7 @@ var CheckBoxGroup = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
54
55
|
var _formContext$useFormI = formContext.useFormInput({
|
|
55
56
|
name: name,
|
|
56
57
|
value: valueProp,
|
|
57
|
-
initialValue: []
|
|
58
|
+
initialValue: defaultValue || []
|
|
58
59
|
}),
|
|
59
60
|
value = _formContext$useFormI[0],
|
|
60
61
|
setValue = _formContext$useFormI[1]; // Logic is necessary to maintain a proper data structure for Form logic
|
|
@@ -15,6 +15,7 @@ export interface CheckBoxType
|
|
|
15
15
|
|
|
16
16
|
export interface CheckBoxGroupProps {
|
|
17
17
|
value?: (number | string)[];
|
|
18
|
+
defaultValue?: (number | string)[];
|
|
18
19
|
disabled?: boolean;
|
|
19
20
|
labelKey?: string;
|
|
20
21
|
name?: string;
|
|
@@ -26,7 +27,7 @@ export interface CheckBoxGroupProps {
|
|
|
26
27
|
export interface CheckBoxGroupExtendedProps
|
|
27
28
|
extends CheckBoxGroupProps,
|
|
28
29
|
BoxProps,
|
|
29
|
-
Omit<JSX.IntrinsicElements['div'], 'onClick' |
|
|
30
|
+
Omit<JSX.IntrinsicElements['div'], 'onClick' | keyof CheckBoxGroupProps> {}
|
|
30
31
|
|
|
31
32
|
declare const CheckBoxGroup: React.FC<CheckBoxGroupExtendedProps>;
|
|
32
33
|
|
|
@@ -12,6 +12,7 @@ var PropType = {};
|
|
|
12
12
|
if (process.env.NODE_ENV !== 'production') {
|
|
13
13
|
PropType = {
|
|
14
14
|
value: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string])),
|
|
15
|
+
defaultValue: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])),
|
|
15
16
|
disabled: _propTypes["default"].bool,
|
|
16
17
|
labelKey: _propTypes["default"].string,
|
|
17
18
|
name: _propTypes["default"].string,
|
|
@@ -45,7 +45,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
45
45
|
|
|
46
46
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
47
|
|
|
48
|
-
var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'TextArea', 'DateInput', 'FileInput', 'RadioButtonGroup', 'RangeInput'];
|
|
48
|
+
var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'FileInput', 'RadioButtonGroup', 'RangeInput'];
|
|
49
49
|
var grommetInputPadNames = ['CheckBox', 'CheckBoxGroup', 'RadioButtonGroup', 'RangeInput'];
|
|
50
50
|
|
|
51
51
|
var isGrommetInput = function isGrommetInput(comp) {
|
|
@@ -5,11 +5,15 @@ exports.Heading = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
|
+
var _useIsomorphicLayoutEffect = require("../../utils/use-isomorphic-layout-effect");
|
|
9
|
+
|
|
8
10
|
var _StyledHeading = require("./StyledHeading");
|
|
9
11
|
|
|
10
12
|
var _propTypes = require("./propTypes");
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
|
|
16
|
+
var _excluded = ["color", "fill", "level", "overflowWrap", "weight"];
|
|
13
17
|
|
|
14
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
19
|
|
|
@@ -24,9 +28,33 @@ var Heading = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref // munged
|
|
|
24
28
|
var color = _ref.color,
|
|
25
29
|
fill = _ref.fill,
|
|
26
30
|
level = _ref.level,
|
|
31
|
+
overflowWrapProp = _ref.overflowWrap,
|
|
27
32
|
weight = _ref.weight,
|
|
28
33
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
34
|
|
|
35
|
+
var headingRef = (0, _utils.useForwardedRef)(ref);
|
|
36
|
+
|
|
37
|
+
var _useState = (0, _react.useState)(overflowWrapProp || 'break-word'),
|
|
38
|
+
overflowWrap = _useState[0],
|
|
39
|
+
setOverflowWrap = _useState[1]; // handle overflowWrap of heading
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(function () {
|
|
43
|
+
var updateOverflowWrap = function updateOverflowWrap() {
|
|
44
|
+
var wrap;
|
|
45
|
+
|
|
46
|
+
if (!overflowWrapProp && headingRef.current) {
|
|
47
|
+
wrap = headingRef.current.scrollWidth > headingRef.current.offsetWidth ? 'anywhere' : 'break-word';
|
|
48
|
+
setOverflowWrap(wrap);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
window.addEventListener('resize', updateOverflowWrap);
|
|
53
|
+
updateOverflowWrap();
|
|
54
|
+
return function () {
|
|
55
|
+
return window.removeEventListener('resize', updateOverflowWrap);
|
|
56
|
+
};
|
|
57
|
+
}, [headingRef, overflowWrapProp]);
|
|
30
58
|
return (
|
|
31
59
|
/*#__PURE__*/
|
|
32
60
|
// enforce level to be a number
|
|
@@ -35,9 +63,10 @@ var Heading = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref // munged
|
|
|
35
63
|
colorProp: color,
|
|
36
64
|
fillProp: fill,
|
|
37
65
|
level: +level,
|
|
66
|
+
overflowWrap: overflowWrap,
|
|
38
67
|
weight: weight
|
|
39
68
|
}, rest, {
|
|
40
|
-
ref:
|
|
69
|
+
ref: headingRef
|
|
41
70
|
}))
|
|
42
71
|
);
|
|
43
72
|
});
|
|
@@ -21,7 +21,7 @@ var sizeStyle = function sizeStyle(props) {
|
|
|
21
21
|
|
|
22
22
|
if (levelStyle) {
|
|
23
23
|
var data = levelStyle[size];
|
|
24
|
-
var styles = [(0, _styledComponents.css)(["font-size:", ";line-height:", ";max-width:", ";font-weight:", ";"], data ? data.size : size, data ? data.height : 'normal', props.fillProp && 'none' || data && data.maxWidth || levelStyle.medium.maxWidth, props.weight || levelStyle.font.weight || headingTheme.weight)];
|
|
24
|
+
var styles = [(0, _styledComponents.css)(["font-size:", ";line-height:", ";max-width:", ";font-weight:", ";overflow-wrap:", ";"], data ? data.size : size, data ? data.height : 'normal', props.fillProp && 'none' || data && data.maxWidth || levelStyle.medium.maxWidth, props.weight || levelStyle.font.weight || headingTheme.weight, props.overflowWrap)];
|
|
25
25
|
|
|
26
26
|
if (props.responsive && headingTheme.responsiveBreakpoint) {
|
|
27
27
|
var breakpoint = props.theme.global.breakpoints[headingTheme.responsiveBreakpoint];
|
|
@@ -19,6 +19,7 @@ export interface HeadingProps {
|
|
|
19
19
|
fill?: boolean;
|
|
20
20
|
level?: '1' | '2' | '3' | '4' | '5' | '6' | 1 | 2 | 3 | 4 | 5 | 6;
|
|
21
21
|
margin?: MarginType;
|
|
22
|
+
overflowWrap?: 'normal' | 'break-word' | 'anywhere' | string;
|
|
22
23
|
responsive?: boolean;
|
|
23
24
|
size?: 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
24
25
|
textAlign?: TextAlignType;
|
|
@@ -18,6 +18,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
18
18
|
color: _generalPropTypes.colorPropType,
|
|
19
19
|
fill: _propTypes["default"].bool,
|
|
20
20
|
level: _propTypes["default"].oneOf([1, 2, 3, 4, 5, 6, '1', '2', '3', '4', '5', '6']),
|
|
21
|
+
overflowWrap: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['normal', 'break-word', 'anywhere']), _propTypes["default"].string]),
|
|
21
22
|
responsive: _propTypes["default"].bool,
|
|
22
23
|
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['small', 'medium', 'large', 'xlarge']), _propTypes["default"].string]),
|
|
23
24
|
textAlign: _propTypes["default"].oneOf(['start', 'center', 'end', 'justify']),
|
|
@@ -12,6 +12,7 @@ var _grommet = require("grommet");
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
14
|
var headingFiller = "\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua.\n";
|
|
15
|
+
var longWord = 'Supercalifragilisticexpialidocious';
|
|
15
16
|
|
|
16
17
|
var H = function H(_ref) {
|
|
17
18
|
var level = _ref.level,
|
|
@@ -60,7 +61,9 @@ var All = function All() {
|
|
|
60
61
|
size: "xlarge"
|
|
61
62
|
})), /*#__PURE__*/_react["default"].createElement(_grommet.Heading, {
|
|
62
63
|
fill: true
|
|
63
|
-
}, headingFiller)
|
|
64
|
+
}, headingFiller), /*#__PURE__*/_react["default"].createElement(_grommet.Heading, {
|
|
65
|
+
fill: true
|
|
66
|
+
}, longWord)) // </Grommet>
|
|
64
67
|
|
|
65
68
|
);
|
|
66
69
|
};
|