@pingux/astro 2.52.0-alpha.0 → 2.52.0-alpha.2
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/lib/cjs/components/AccordionGroup/Accordion.styles.d.ts +3 -3
- package/lib/cjs/components/Breadcrumbs/Breadcrumb.styles.d.ts +3 -3
- package/lib/cjs/components/Button/Buttons.styles.d.ts +51 -51
- package/lib/cjs/components/CheckboxField/CheckboxField.stories.js +135 -13
- package/lib/cjs/components/FieldHelperText/FieldHelperText.styles.d.ts +3 -3
- package/lib/cjs/components/Label/Label.d.ts +13 -0
- package/lib/cjs/components/Label/Label.js +8 -26
- package/lib/cjs/components/Label/Label.stories.d.ts +7 -0
- package/lib/cjs/components/Label/Label.stories.js +3 -3
- package/lib/cjs/components/Label/Label.styles.d.ts +2 -0
- package/lib/cjs/components/Label/Label.test.d.ts +1 -0
- package/lib/cjs/components/Label/index.d.ts +1 -0
- package/lib/cjs/components/SelectField/SelectField.stories.js +3 -3
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +3 -3
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.test.js +2 -2
- package/lib/cjs/components/Table/Table.styles.d.ts +6 -6
- package/lib/cjs/components/Text/Text.styles.d.ts +91 -90
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +3 -3
- package/lib/cjs/components/TextField/TextField.stories.js +3 -3
- package/lib/cjs/hooks/useColumnStyles/useColumnStyles.d.ts +2 -2
- package/lib/cjs/hooks/useField/useField.d.ts +22 -21
- package/lib/cjs/hooks/useField/useField.js +3 -5
- package/lib/cjs/hooks/useField/useField.test.js +4 -4
- package/lib/cjs/hooks/useSelectField/useSelectField.d.ts +2 -3
- package/lib/cjs/hooks/useSelectField/useSelectField.js +2 -2
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +29 -18
- package/lib/cjs/types/label.d.ts +25 -0
- package/lib/cjs/types/label.js +6 -0
- package/lib/cjs/types/shared/style.d.ts +3 -0
- package/lib/cjs/utils/devUtils/constants/labelModes.d.ts +5 -0
- package/lib/components/CheckboxField/CheckboxField.stories.js +134 -13
- package/lib/components/Label/Label.js +6 -24
- package/lib/components/Label/Label.stories.js +1 -1
- package/lib/components/Label/Label.styles.js +1 -0
- package/lib/components/SelectField/SelectField.stories.js +1 -1
- package/lib/components/SelectFieldBase/SelectFieldBase.js +1 -1
- package/lib/components/SelectFieldBase/SelectFieldBase.test.js +1 -1
- package/lib/components/TextAreaField/TextAreaField.stories.js +1 -1
- package/lib/components/TextField/TextField.stories.js +1 -1
- package/lib/hooks/useField/useField.js +1 -3
- package/lib/hooks/useField/useField.test.js +1 -1
- package/lib/hooks/useSelectField/useSelectField.js +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/label.js +1 -0
- package/package.json +1 -1
- /package/lib/cjs/{components/Label/constants.js → utils/devUtils/constants/labelModes.js} +0 -0
- /package/lib/{components/Label/constants.js → utils/devUtils/constants/labelModes.js} +0 -0
@@ -51,10 +51,10 @@ declare const _default: {
|
|
51
51
|
};
|
52
52
|
fontSize: string;
|
53
53
|
fontFamily: string;
|
54
|
-
overflowWrap:
|
54
|
+
overflowWrap: import("../..").overflowWrap;
|
55
55
|
maxWidth: string;
|
56
|
-
wordWrap:
|
57
|
-
wordBreak:
|
56
|
+
wordWrap: import("../..").wordWrap;
|
57
|
+
wordBreak: import("../..").wordBreak;
|
58
58
|
cursor: string;
|
59
59
|
height: string;
|
60
60
|
lineHeight: string;
|
@@ -44,10 +44,10 @@ declare const _default: {
|
|
44
44
|
fontSize: string;
|
45
45
|
fontWeight: number;
|
46
46
|
fontFamily: string;
|
47
|
-
overflowWrap:
|
47
|
+
overflowWrap: import("../..").overflowWrap;
|
48
48
|
maxWidth: string;
|
49
|
-
wordWrap:
|
50
|
-
wordBreak:
|
49
|
+
wordWrap: import("../..").wordWrap;
|
50
|
+
wordBreak: import("../..").wordBreak;
|
51
51
|
cursor: string;
|
52
52
|
outline: string;
|
53
53
|
alignItems: string;
|
@@ -4,10 +4,10 @@ export declare const base: {
|
|
4
4
|
color: string;
|
5
5
|
fontFamily: string;
|
6
6
|
display: string;
|
7
|
-
overflowWrap:
|
7
|
+
overflowWrap: import("../..").overflowWrap;
|
8
8
|
maxWidth: string;
|
9
|
-
wordWrap:
|
10
|
-
wordBreak:
|
9
|
+
wordWrap: import("../..").wordWrap;
|
10
|
+
wordBreak: import("../..").wordBreak;
|
11
11
|
cursor: string;
|
12
12
|
height: string;
|
13
13
|
lineHeight: string;
|
@@ -52,10 +52,10 @@ export declare const text: {
|
|
52
52
|
fontSize: string;
|
53
53
|
fontWeight: number;
|
54
54
|
fontFamily: string;
|
55
|
-
overflowWrap:
|
55
|
+
overflowWrap: import("../..").overflowWrap;
|
56
56
|
maxWidth: string;
|
57
|
-
wordWrap:
|
58
|
-
wordBreak:
|
57
|
+
wordWrap: import("../..").wordWrap;
|
58
|
+
wordBreak: import("../..").wordBreak;
|
59
59
|
cursor: string;
|
60
60
|
minWidth: string;
|
61
61
|
outline: string;
|
@@ -97,10 +97,10 @@ export declare const link: {
|
|
97
97
|
fontSize: string;
|
98
98
|
fontWeight: number;
|
99
99
|
fontFamily: string;
|
100
|
-
overflowWrap:
|
100
|
+
overflowWrap: import("../..").overflowWrap;
|
101
101
|
maxWidth: string;
|
102
|
-
wordWrap:
|
103
|
-
wordBreak:
|
102
|
+
wordWrap: import("../..").wordWrap;
|
103
|
+
wordBreak: import("../..").wordBreak;
|
104
104
|
cursor: string;
|
105
105
|
minWidth: string;
|
106
106
|
outline: string;
|
@@ -270,10 +270,10 @@ declare const _default: {
|
|
270
270
|
fontSize: string;
|
271
271
|
fontWeight: number;
|
272
272
|
fontFamily: string;
|
273
|
-
overflowWrap:
|
273
|
+
overflowWrap: import("../..").overflowWrap;
|
274
274
|
maxWidth: string;
|
275
|
-
wordWrap:
|
276
|
-
wordBreak:
|
275
|
+
wordWrap: import("../..").wordWrap;
|
276
|
+
wordBreak: import("../..").wordBreak;
|
277
277
|
cursor: string;
|
278
278
|
height: string;
|
279
279
|
lineHeight: string;
|
@@ -317,10 +317,10 @@ declare const _default: {
|
|
317
317
|
color: string;
|
318
318
|
fontFamily: string;
|
319
319
|
display: string;
|
320
|
-
overflowWrap:
|
320
|
+
overflowWrap: import("../..").overflowWrap;
|
321
321
|
maxWidth: string;
|
322
|
-
wordWrap:
|
323
|
-
wordBreak:
|
322
|
+
wordWrap: import("../..").wordWrap;
|
323
|
+
wordBreak: import("../..").wordBreak;
|
324
324
|
cursor: string;
|
325
325
|
height: string;
|
326
326
|
lineHeight: string;
|
@@ -348,10 +348,10 @@ declare const _default: {
|
|
348
348
|
color: string;
|
349
349
|
fontFamily: string;
|
350
350
|
display: string;
|
351
|
-
overflowWrap:
|
351
|
+
overflowWrap: import("../..").overflowWrap;
|
352
352
|
maxWidth: string;
|
353
|
-
wordWrap:
|
354
|
-
wordBreak:
|
353
|
+
wordWrap: import("../..").wordWrap;
|
354
|
+
wordBreak: import("../..").wordBreak;
|
355
355
|
cursor: string;
|
356
356
|
height: string;
|
357
357
|
lineHeight: string;
|
@@ -397,10 +397,10 @@ declare const _default: {
|
|
397
397
|
fontSize: string;
|
398
398
|
fontWeight: number;
|
399
399
|
fontFamily: string;
|
400
|
-
overflowWrap:
|
400
|
+
overflowWrap: import("../..").overflowWrap;
|
401
401
|
maxWidth: string;
|
402
|
-
wordWrap:
|
403
|
-
wordBreak:
|
402
|
+
wordWrap: import("../..").wordWrap;
|
403
|
+
wordBreak: import("../..").wordBreak;
|
404
404
|
cursor: string;
|
405
405
|
lineHeight: string;
|
406
406
|
minWidth: string;
|
@@ -444,10 +444,10 @@ declare const _default: {
|
|
444
444
|
color: string;
|
445
445
|
fontFamily: string;
|
446
446
|
display: string;
|
447
|
-
overflowWrap:
|
447
|
+
overflowWrap: import("../..").overflowWrap;
|
448
448
|
maxWidth: string;
|
449
|
-
wordWrap:
|
450
|
-
wordBreak:
|
449
|
+
wordWrap: import("../..").wordWrap;
|
450
|
+
wordBreak: import("../..").wordBreak;
|
451
451
|
cursor: string;
|
452
452
|
height: string;
|
453
453
|
lineHeight: string;
|
@@ -497,10 +497,10 @@ declare const _default: {
|
|
497
497
|
fontWeight: number;
|
498
498
|
color: string;
|
499
499
|
fontFamily: string;
|
500
|
-
overflowWrap:
|
500
|
+
overflowWrap: import("../..").overflowWrap;
|
501
501
|
maxWidth: string;
|
502
|
-
wordWrap:
|
503
|
-
wordBreak:
|
502
|
+
wordWrap: import("../..").wordWrap;
|
503
|
+
wordBreak: import("../..").wordBreak;
|
504
504
|
cursor: string;
|
505
505
|
minWidth: string;
|
506
506
|
padding: string;
|
@@ -553,10 +553,10 @@ declare const _default: {
|
|
553
553
|
};
|
554
554
|
fontWeight: number;
|
555
555
|
fontFamily: string;
|
556
|
-
overflowWrap:
|
556
|
+
overflowWrap: import("../..").overflowWrap;
|
557
557
|
maxWidth: string;
|
558
|
-
wordWrap:
|
559
|
-
wordBreak:
|
558
|
+
wordWrap: import("../..").wordWrap;
|
559
|
+
wordBreak: import("../..").wordBreak;
|
560
560
|
cursor: string;
|
561
561
|
minWidth: string;
|
562
562
|
padding: string;
|
@@ -610,10 +610,10 @@ declare const _default: {
|
|
610
610
|
};
|
611
611
|
fontWeight: number;
|
612
612
|
fontFamily: string;
|
613
|
-
overflowWrap:
|
613
|
+
overflowWrap: import("../..").overflowWrap;
|
614
614
|
maxWidth: string;
|
615
|
-
wordWrap:
|
616
|
-
wordBreak:
|
615
|
+
wordWrap: import("../..").wordWrap;
|
616
|
+
wordBreak: import("../..").wordBreak;
|
617
617
|
cursor: string;
|
618
618
|
minWidth: string;
|
619
619
|
outline: string;
|
@@ -660,10 +660,10 @@ declare const _default: {
|
|
660
660
|
fontWeight: number;
|
661
661
|
color: string;
|
662
662
|
fontFamily: string;
|
663
|
-
overflowWrap:
|
663
|
+
overflowWrap: import("../..").overflowWrap;
|
664
664
|
maxWidth: string;
|
665
|
-
wordWrap:
|
666
|
-
wordBreak:
|
665
|
+
wordWrap: import("../..").wordWrap;
|
666
|
+
wordBreak: import("../..").wordBreak;
|
667
667
|
cursor: string;
|
668
668
|
minWidth: string;
|
669
669
|
outline: string;
|
@@ -700,10 +700,10 @@ declare const _default: {
|
|
700
700
|
fontSize: string;
|
701
701
|
fontWeight: number;
|
702
702
|
fontFamily: string;
|
703
|
-
overflowWrap:
|
703
|
+
overflowWrap: import("../..").overflowWrap;
|
704
704
|
maxWidth: string;
|
705
|
-
wordWrap:
|
706
|
-
wordBreak:
|
705
|
+
wordWrap: import("../..").wordWrap;
|
706
|
+
wordBreak: import("../..").wordBreak;
|
707
707
|
cursor: string;
|
708
708
|
minWidth: string;
|
709
709
|
outline: string;
|
@@ -740,10 +740,10 @@ declare const _default: {
|
|
740
740
|
fontSize: string;
|
741
741
|
fontWeight: number;
|
742
742
|
fontFamily: string;
|
743
|
-
overflowWrap:
|
743
|
+
overflowWrap: import("../..").overflowWrap;
|
744
744
|
maxWidth: string;
|
745
|
-
wordWrap:
|
746
|
-
wordBreak:
|
745
|
+
wordWrap: import("../..").wordWrap;
|
746
|
+
wordBreak: import("../..").wordBreak;
|
747
747
|
cursor: string;
|
748
748
|
height: string;
|
749
749
|
lineHeight: string;
|
@@ -785,10 +785,10 @@ declare const _default: {
|
|
785
785
|
fontSize: string;
|
786
786
|
fontWeight: number;
|
787
787
|
fontFamily: string;
|
788
|
-
overflowWrap:
|
788
|
+
overflowWrap: import("../..").overflowWrap;
|
789
789
|
maxWidth: string;
|
790
|
-
wordWrap:
|
791
|
-
wordBreak:
|
790
|
+
wordWrap: import("../..").wordWrap;
|
791
|
+
wordBreak: import("../..").wordBreak;
|
792
792
|
cursor: string;
|
793
793
|
height: string;
|
794
794
|
lineHeight: string;
|
@@ -818,10 +818,10 @@ declare const _default: {
|
|
818
818
|
fontSize: string;
|
819
819
|
fontWeight: number;
|
820
820
|
fontFamily: string;
|
821
|
-
overflowWrap:
|
821
|
+
overflowWrap: import("../..").overflowWrap;
|
822
822
|
maxWidth: string;
|
823
|
-
wordWrap:
|
824
|
-
wordBreak:
|
823
|
+
wordWrap: import("../..").wordWrap;
|
824
|
+
wordBreak: import("../..").wordBreak;
|
825
825
|
cursor: string;
|
826
826
|
height: string;
|
827
827
|
lineHeight: string;
|
@@ -866,10 +866,10 @@ declare const _default: {
|
|
866
866
|
fontWeight: number;
|
867
867
|
color: string;
|
868
868
|
fontFamily: string;
|
869
|
-
overflowWrap:
|
869
|
+
overflowWrap: import("../..").overflowWrap;
|
870
870
|
maxWidth: string;
|
871
|
-
wordWrap:
|
872
|
-
wordBreak:
|
871
|
+
wordWrap: import("../..").wordWrap;
|
872
|
+
wordBreak: import("../..").wordBreak;
|
873
873
|
cursor: string;
|
874
874
|
height: string;
|
875
875
|
lineHeight: string;
|
@@ -14,12 +14,14 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
14
14
|
_Object$defineProperty(exports, "__esModule", {
|
15
15
|
value: true
|
16
16
|
});
|
17
|
-
exports["default"] = exports.Required = exports.Indeterminate = exports.HelperText = exports.DefaultSelected = exports.Default = exports.Controlled = void 0;
|
17
|
+
exports["default"] = exports.Required = exports.Indeterminate = exports.HelperText = exports.ExpandableAndToggleableIndeterminate = exports.DefaultSelected = exports.Default = exports.Controlled = void 0;
|
18
18
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
19
19
|
var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
|
20
20
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
21
21
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
22
22
|
var _react = _interopRequireWildcard(require("react"));
|
23
|
+
var _MenuDownIcon = _interopRequireDefault(require("@pingux/mdi-react/MenuDownIcon"));
|
24
|
+
var _MenuRightIcon = _interopRequireDefault(require("@pingux/mdi-react/MenuRightIcon"));
|
23
25
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
24
26
|
var _index = require("../../index");
|
25
27
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
@@ -121,19 +123,139 @@ var HelperText = function HelperText() {
|
|
121
123
|
});
|
122
124
|
};
|
123
125
|
exports.HelperText = HelperText;
|
126
|
+
var ExpandableAndToggleableIndeterminate = function ExpandableAndToggleableIndeterminate() {
|
127
|
+
var _useState = (0, _react.useState)(false),
|
128
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
129
|
+
isReadOnly = _useState2[0],
|
130
|
+
setIsReadOnly = _useState2[1];
|
131
|
+
var _useState3 = (0, _react.useState)(true),
|
132
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
133
|
+
isExpanded = _useState4[0],
|
134
|
+
setIsExpanded = _useState4[1];
|
135
|
+
// Whether the parent checkbox is indeterminate (default is true for our example)
|
136
|
+
var _useState5 = (0, _react.useState)(true),
|
137
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
138
|
+
isIndeterminate = _useState6[0],
|
139
|
+
setIsIndeterminate = _useState6[1];
|
140
|
+
// Whether the parent checkbox should be checked, this is set independently from indeterminism
|
141
|
+
var _useState7 = (0, _react.useState)(false),
|
142
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
143
|
+
isCompleted = _useState8[0],
|
144
|
+
setIsCompleted = _useState8[1];
|
145
|
+
// The state of the sub-checkboxes
|
146
|
+
var _useState9 = (0, _react.useState)([{
|
147
|
+
label: 'Apple Chunks',
|
148
|
+
isSelected: true
|
149
|
+
}, {
|
150
|
+
label: 'Blueberries',
|
151
|
+
isSelected: false
|
152
|
+
}, {
|
153
|
+
label: 'Grapes',
|
154
|
+
isSelected: false
|
155
|
+
}, {
|
156
|
+
label: 'Strawberry Slices',
|
157
|
+
isSelected: true
|
158
|
+
}]),
|
159
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
160
|
+
subCheckboxes = _useState10[0],
|
161
|
+
setSubCheckboxes = _useState10[1];
|
162
|
+
|
163
|
+
// Determine which checkbox needs its state updated
|
164
|
+
var handleSubCheckboxChange = function handleSubCheckboxChange(isSelected, changedIndex) {
|
165
|
+
var changeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
166
|
+
var newSubCheckboxes = (0, _map["default"])(subCheckboxes).call(subCheckboxes, function (checkbox, index) {
|
167
|
+
if (changeAll || index === changedIndex) return _objectSpread(_objectSpread({}, checkbox), {}, {
|
168
|
+
isSelected: isSelected
|
169
|
+
});
|
170
|
+
return checkbox;
|
171
|
+
});
|
172
|
+
setSubCheckboxes(newSubCheckboxes);
|
173
|
+
};
|
174
|
+
|
175
|
+
// Update all sub-checkbox states when the parent checkbox is pressed
|
176
|
+
var handleParentCheckboxChange = function handleParentCheckboxChange(isSelected) {
|
177
|
+
handleSubCheckboxChange(isSelected, null, true);
|
178
|
+
};
|
179
|
+
(0, _react.useEffect)(function () {
|
180
|
+
// Determine if all sub-checkboxes are selected / unselected or if there is a mix
|
181
|
+
// and update the parent checkbox
|
182
|
+
if ((0, _every["default"])(subCheckboxes).call(subCheckboxes, function (item) {
|
183
|
+
return item.isSelected;
|
184
|
+
})) {
|
185
|
+
setIsIndeterminate(false);
|
186
|
+
setIsCompleted(true);
|
187
|
+
} else if ((0, _every["default"])(subCheckboxes).call(subCheckboxes, function (item) {
|
188
|
+
return !item.isSelected;
|
189
|
+
})) {
|
190
|
+
setIsIndeterminate(false);
|
191
|
+
setIsCompleted(false);
|
192
|
+
} else {
|
193
|
+
setIsIndeterminate(true);
|
194
|
+
setIsCompleted(false);
|
195
|
+
}
|
196
|
+
}, [isIndeterminate, subCheckboxes]);
|
197
|
+
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_index.SwitchField, {
|
198
|
+
isSelected: isReadOnly,
|
199
|
+
label: "Is Read Only",
|
200
|
+
onChange: setIsReadOnly,
|
201
|
+
value: "my-switch"
|
202
|
+
}), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Box, {
|
203
|
+
isRow: true,
|
204
|
+
alignItems: "center"
|
205
|
+
}, (0, _react2.jsx)(_index.IconButtonToggle, {
|
206
|
+
toggledIcon: _MenuDownIcon["default"],
|
207
|
+
defaultIcon: _MenuRightIcon["default"],
|
208
|
+
onToggle: setIsExpanded,
|
209
|
+
isToggled: isExpanded,
|
210
|
+
buttonProps: {
|
211
|
+
'aria-label': isExpanded ? 'menu down' : 'menu up',
|
212
|
+
'aria-controls': 'expanded-checkboxes',
|
213
|
+
'aria-expanded': isExpanded
|
214
|
+
},
|
215
|
+
iconProps: {
|
216
|
+
size: 'sm'
|
217
|
+
}
|
218
|
+
}), isReadOnly ? (0, _react2.jsx)(_index.Text, null, "Fruit Salad Recipe") : (0, _react2.jsx)(_index.CheckboxField, {
|
219
|
+
label: "Fruit Salad Recipe",
|
220
|
+
isIndeterminate: isIndeterminate,
|
221
|
+
isSelected: isCompleted,
|
222
|
+
onChange: handleParentCheckboxChange
|
223
|
+
}), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Badge, {
|
224
|
+
ml: "sm",
|
225
|
+
label: subCheckboxes.length,
|
226
|
+
variant: "countNeutral"
|
227
|
+
}))), (0, _react2.jsx)(_index.Box, {
|
228
|
+
ml: "50px",
|
229
|
+
id: "expanded-checkboxes"
|
230
|
+
}, isExpanded && (0, _map["default"])(subCheckboxes).call(subCheckboxes, function (checkbox, index) {
|
231
|
+
return (0, _react2.jsx)(_index.Box, {
|
232
|
+
isRow: true,
|
233
|
+
alignItems: "center",
|
234
|
+
height: "24px"
|
235
|
+
}, isReadOnly ? (0, _react2.jsx)(_index.Text, null, checkbox.label) : (0, _react2.jsx)(_index.CheckboxField, {
|
236
|
+
key: checkbox.label,
|
237
|
+
label: checkbox.label,
|
238
|
+
isSelected: checkbox.isSelected,
|
239
|
+
onChange: function onChange(isSelected) {
|
240
|
+
return handleSubCheckboxChange(isSelected, index);
|
241
|
+
}
|
242
|
+
}));
|
243
|
+
})));
|
244
|
+
};
|
245
|
+
exports.ExpandableAndToggleableIndeterminate = ExpandableAndToggleableIndeterminate;
|
124
246
|
var Indeterminate = function Indeterminate() {
|
125
247
|
// Whether the parent checkbox is indeterminate (default is true for our example)
|
126
|
-
var
|
127
|
-
|
128
|
-
isIndeterminate =
|
129
|
-
setIsIndeterminate =
|
248
|
+
var _useState11 = (0, _react.useState)(true),
|
249
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
250
|
+
isIndeterminate = _useState12[0],
|
251
|
+
setIsIndeterminate = _useState12[1];
|
130
252
|
// Whether the parent checkbox should be checked, this is set independently from indeterminism
|
131
|
-
var
|
132
|
-
|
133
|
-
isCompleted =
|
134
|
-
setIsCompleted =
|
253
|
+
var _useState13 = (0, _react.useState)(false),
|
254
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
255
|
+
isCompleted = _useState14[0],
|
256
|
+
setIsCompleted = _useState14[1];
|
135
257
|
// The state of the sub-checkboxes
|
136
|
-
var
|
258
|
+
var _useState15 = (0, _react.useState)([{
|
137
259
|
label: 'Apple Chunks',
|
138
260
|
isSelected: true
|
139
261
|
}, {
|
@@ -146,9 +268,9 @@ var Indeterminate = function Indeterminate() {
|
|
146
268
|
label: 'Strawberry Slices',
|
147
269
|
isSelected: true
|
148
270
|
}]),
|
149
|
-
|
150
|
-
subCheckboxes =
|
151
|
-
setSubCheckboxes =
|
271
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
272
|
+
subCheckboxes = _useState16[0],
|
273
|
+
setSubCheckboxes = _useState16[1];
|
152
274
|
|
153
275
|
// Determine which checkbox needs its state updated
|
154
276
|
var handleSubCheckboxChange = function handleSubCheckboxChange(isSelected, changedIndex) {
|
@@ -18,10 +18,10 @@ declare const _default: {
|
|
18
18
|
gridColumnEnd: number;
|
19
19
|
};
|
20
20
|
display: string;
|
21
|
-
overflowWrap:
|
21
|
+
overflowWrap: import("../..").overflowWrap;
|
22
22
|
maxWidth: string;
|
23
|
-
wordWrap:
|
24
|
-
wordBreak:
|
23
|
+
wordWrap: import("../..").wordWrap;
|
24
|
+
wordBreak: import("../..").wordBreak;
|
25
25
|
grid?: import("theme-ui").StylePropertyValue<import("csstype").Property.Grid | undefined>;
|
26
26
|
accentColor?: import("theme-ui").StylePropertyValue<import("csstype").Property.AccentColor | undefined>;
|
27
27
|
alignContent?: import("theme-ui").StylePropertyValue<import("csstype").Property.AlignContent | undefined>;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { LabelProps } from '../../types';
|
3
|
+
/**
|
4
|
+
* Base label for an input.
|
5
|
+
*
|
6
|
+
* Accepts most of the styling props from [styled-system](https://styled-system.com/table).
|
7
|
+
* Built on top of the [Label from Theme-UI](https://theme-ui.com/components/label).
|
8
|
+
*
|
9
|
+
* **NOTE**: Specialized field components contain built-in support for labels. It's
|
10
|
+
* recommended to use those instead of a standalone `Label`.
|
11
|
+
*/
|
12
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelProps, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
13
|
+
export default Label;
|
@@ -9,28 +9,26 @@ _Object$defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
10
10
|
});
|
11
11
|
exports["default"] = void 0;
|
12
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
13
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
14
13
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
15
14
|
var _base = _interopRequireDefault(require("@emotion/styled/base"));
|
16
15
|
var _react = _interopRequireWildcard(require("react"));
|
17
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
18
16
|
var _styledSystem = require("styled-system");
|
19
17
|
var _themeUi = require("theme-ui");
|
20
18
|
var _hooks = require("../../hooks");
|
19
|
+
var _labelModes = require("../../utils/devUtils/constants/labelModes");
|
21
20
|
var _Box = _interopRequireDefault(require("../Box"));
|
22
21
|
var _HelpHint = _interopRequireDefault(require("../HelpHint"));
|
23
|
-
var _constants = require("./constants");
|
24
22
|
var _react2 = require("@emotion/react");
|
25
23
|
var _excluded = ["children", "className", "isDisabled", "isRequired", "mode", "requiredIndicator", "hintText", "helpHintProps"];
|
26
24
|
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); }
|
27
25
|
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; }
|
28
26
|
var ExtendedLabel = /*#__PURE__*/(0, _base["default"])(_themeUi.Label, process.env.NODE_ENV === "production" ? {
|
29
|
-
target: "
|
27
|
+
target: "e19mxf30"
|
30
28
|
} : {
|
31
|
-
target: "
|
29
|
+
target: "e19mxf30",
|
32
30
|
label: "ExtendedLabel"
|
33
|
-
})(_styledSystem.layout, _styledSystem.flexbox, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
31
|
+
})(_styledSystem.layout, _styledSystem.flexbox, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0xhYmVsL0xhYmVsLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFXc0IiLCJmaWxlIjoiLi4vLi4vLi4vLi4vc3JjL2NvbXBvbmVudHMvTGFiZWwvTGFiZWwudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IGZvcndhcmRSZWYgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBmbGV4Ym94LCBsYXlvdXQgfSBmcm9tICdzdHlsZWQtc3lzdGVtJztcbmltcG9ydCB7IExhYmVsIGFzIFRoZW1lVUlMYWJlbCB9IGZyb20gJ3RoZW1lLXVpJztcblxuaW1wb3J0IHsgdXNlUHJvcFdhcm5pbmcsIHVzZVN0YXR1c0NsYXNzZXMgfSBmcm9tICcuLi8uLi9ob29rcyc7XG5pbXBvcnQgeyBMYWJlbE1vZGVQcm9wcywgTGFiZWxQcm9wcyB9IGZyb20gJy4uLy4uL3R5cGVzJztcbmltcG9ydCB7IG1vZGVzIH0gZnJvbSAnLi4vLi4vdXRpbHMvZGV2VXRpbHMvY29uc3RhbnRzL2xhYmVsTW9kZXMnO1xuaW1wb3J0IEJveCBmcm9tICcuLi9Cb3gnO1xuaW1wb3J0IEhlbHBIaW50IGZyb20gJy4uL0hlbHBIaW50JztcblxuY29uc3QgRXh0ZW5kZWRMYWJlbCA9IHN0eWxlZChUaGVtZVVJTGFiZWwpKGxheW91dCwgZmxleGJveCk7XG5cbmNvbnN0IGRlZmF1bHRJbmRpY2F0b3IgPSAoXG4gIDxCb3ggdmFyaWFudD1cImZvcm1zLmxhYmVsLmluZGljYXRvclwiPlxuICAgICpcbiAgPC9Cb3g+XG4pO1xuXG4vKipcbiAqIEJhc2UgbGFiZWwgZm9yIGFuIGlucHV0LlxuICpcbiAqIEFjY2VwdHMgbW9zdCBvZiB0aGUgc3R5bGluZyBwcm9wcyBmcm9tIFtzdHlsZWQtc3lzdGVtXShodHRwczovL3N0eWxlZC1zeXN0ZW0uY29tL3RhYmxlKS5cbiAqIEJ1aWx0IG9uIHRvcCBvZiB0aGUgW0xhYmVsIGZyb20gVGhlbWUtVUldKGh0dHBzOi8vdGhlbWUtdWkuY29tL2NvbXBvbmVudHMvbGFiZWwpLlxuICpcbiAqICoqTk9URSoqOiBTcGVjaWFsaXplZCBmaWVsZCBjb21wb25lbnRzIGNvbnRhaW4gYnVpbHQtaW4gc3VwcG9ydCBmb3IgbGFiZWxzLiBJdCdzXG4gKiByZWNvbW1lbmRlZCB0byB1c2UgdGhvc2UgaW5zdGVhZCBvZiBhIHN0YW5kYWxvbmUgYExhYmVsYC5cbiAqL1xuXG5jb25zdCBMYWJlbCA9IGZvcndhcmRSZWY8SFRNTExhYmVsRWxlbWVudCwgTGFiZWxQcm9wcz4oKHByb3BzLCByZWYpID0+IHtcbiAgY29uc3Qge1xuICAgIGNoaWxkcmVuLFxuICAgIGNsYXNzTmFtZSxcbiAgICBpc0Rpc2FibGVkLFxuICAgIGlzUmVxdWlyZWQsXG4gICAgbW9kZSA9IG1vZGVzLkRFRkFVTFQgYXMgTGFiZWxNb2RlUHJvcHMsXG4gICAgcmVxdWlyZWRJbmRpY2F0b3IsXG4gICAgaGludFRleHQsXG4gICAgaGVscEhpbnRQcm9wcyxcbiAgICAuLi5vdGhlcnNcbiAgfSA9IHByb3BzO1xuXG4gIHVzZVByb3BXYXJuaW5nKHByb3BzLCAnZGlzYWJsZWQnLCAnaXNEaXNhYmxlZCcpO1xuXG4gIGNvbnN0IHsgY2xhc3NOYW1lcyB9ID0gdXNlU3RhdHVzQ2xhc3NlcyhjbGFzc05hbWUsIHtcbiAgICBpc0Rpc2FibGVkLFxuICAgIGlzUmVxdWlyZWQsXG4gICAgaXNGbG9hdExhYmVsOiBtb2RlID09PSBtb2Rlcy5GTE9BVCxcbiAgICBpc0xlZnRMYWJlbDogbW9kZSA9PT0gbW9kZXMuTEVGVCxcbiAgfSk7XG5cbiAgcmV0dXJuIChcbiAgICA8RXh0ZW5kZWRMYWJlbFxuICAgICAgcmVmPXtyZWZ9XG4gICAgICBkaXNwbGF5PVwiZmxleFwiXG4gICAgICBjbGFzc05hbWU9e2NsYXNzTmFtZXN9XG4gICAgICB7Li4ub3RoZXJzfVxuICAgID5cbiAgICAgIHtjaGlsZHJlbn1cbiAgICAgIHtcbiAgICAgICAgaXNSZXF1aXJlZFxuICAgICAgICAmJiAocmVxdWlyZWRJbmRpY2F0b3IgfHwgZGVmYXVsdEluZGljYXRvcilcbiAgICAgIH1cbiAgICAgIHtcbiAgICAgICAgaGludFRleHRcbiAgICAgICAgJiYgPEhlbHBIaW50IHsuLi5oZWxwSGludFByb3BzfT57aGludFRleHR9PC9IZWxwSGludD5cbiAgICAgIH1cbiAgICA8L0V4dGVuZGVkTGFiZWw+XG4gICk7XG59KTtcblxuTGFiZWwuZGlzcGxheU5hbWUgPSAnTGFiZWwnO1xuZXhwb3J0IGRlZmF1bHQgTGFiZWw7XG4iXX0= */");
|
34
32
|
var defaultIndicator = (0, _react2.jsx)(_Box["default"], {
|
35
33
|
variant: "forms.label.indicator"
|
36
34
|
}, "*");
|
@@ -50,7 +48,8 @@ var Label = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
50
48
|
className = props.className,
|
51
49
|
isDisabled = props.isDisabled,
|
52
50
|
isRequired = props.isRequired,
|
53
|
-
mode = props.mode,
|
51
|
+
_props$mode = props.mode,
|
52
|
+
mode = _props$mode === void 0 ? _labelModes.modes.DEFAULT : _props$mode,
|
54
53
|
requiredIndicator = props.requiredIndicator,
|
55
54
|
hintText = props.hintText,
|
56
55
|
helpHintProps = props.helpHintProps,
|
@@ -59,8 +58,8 @@ var Label = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
59
58
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
60
59
|
isDisabled: isDisabled,
|
61
60
|
isRequired: isRequired,
|
62
|
-
isFloatLabel: mode ===
|
63
|
-
isLeftLabel: mode ===
|
61
|
+
isFloatLabel: mode === _labelModes.modes.FLOAT,
|
62
|
+
isLeftLabel: mode === _labelModes.modes.LEFT
|
64
63
|
}),
|
65
64
|
classNames = _useStatusClasses.classNames;
|
66
65
|
return (0, _react2.jsx)(ExtendedLabel, (0, _extends2["default"])({
|
@@ -69,23 +68,6 @@ var Label = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
69
68
|
className: classNames
|
70
69
|
}, others), children, isRequired && (requiredIndicator || defaultIndicator), hintText && (0, _react2.jsx)(_HelpHint["default"], helpHintProps, hintText));
|
71
70
|
});
|
72
|
-
Label.propTypes = {
|
73
|
-
/** Whether the label has disabled styling applied. */
|
74
|
-
isDisabled: _propTypes["default"].bool,
|
75
|
-
/** Whether the label has required indicator styling applied. */
|
76
|
-
isRequired: _propTypes["default"].bool,
|
77
|
-
/** Determines the behavior pattern for the label. */
|
78
|
-
mode: _propTypes["default"].oneOf((0, _values["default"])(_constants.modes)),
|
79
|
-
/** The visual component used to mark an input as required within the label. */
|
80
|
-
requiredIndicator: _propTypes["default"].node,
|
81
|
-
/** If present this prop will cause a help hint to render in the label. */
|
82
|
-
hintText: _propTypes["default"].string,
|
83
|
-
/** Props object that is spread directly into the helphint element. */
|
84
|
-
helpHintProps: _propTypes["default"].shape({})
|
85
|
-
};
|
86
|
-
Label.defaultProps = {
|
87
|
-
mode: _constants.modes.DEFAULT
|
88
|
-
};
|
89
71
|
Label.displayName = 'Label';
|
90
72
|
var _default = Label;
|
91
73
|
exports["default"] = _default;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { StoryFn } from '@storybook/react';
|
2
|
+
import { LabelProps } from '../../types';
|
3
|
+
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
4
|
+
export default _default;
|
5
|
+
export declare const Default: StoryFn<LabelProps>;
|
6
|
+
export declare const Float: StoryFn;
|
7
|
+
export declare const WithHelpHint: StoryFn<LabelProps>;
|
@@ -9,7 +9,7 @@ exports["default"] = exports.WithHelpHint = exports.Float = exports.Default = vo
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
11
11
|
var _index = require("../../index");
|
12
|
-
var
|
12
|
+
var _labelModes = require("../../utils/devUtils/constants/labelModes");
|
13
13
|
var _react2 = require("@emotion/react");
|
14
14
|
var _default = {
|
15
15
|
title: 'Form/Base Components/Label',
|
@@ -18,7 +18,7 @@ var _default = {
|
|
18
18
|
mode: {
|
19
19
|
control: {
|
20
20
|
type: 'select',
|
21
|
-
options:
|
21
|
+
options: _labelModes.modes
|
22
22
|
}
|
23
23
|
},
|
24
24
|
isDisabled: {},
|
@@ -28,7 +28,7 @@ var _default = {
|
|
28
28
|
}
|
29
29
|
},
|
30
30
|
args: {
|
31
|
-
mode:
|
31
|
+
mode: _labelModes.modes.DEFAULT
|
32
32
|
}
|
33
33
|
};
|
34
34
|
exports["default"] = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Label';
|
@@ -36,10 +36,10 @@ var _reactAria = require("react-aria");
|
|
36
36
|
var _reactStately = require("react-stately");
|
37
37
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
38
38
|
var _index = require("../../index");
|
39
|
+
var _labelModes = require("../../utils/devUtils/constants/labelModes");
|
39
40
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
40
41
|
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
41
42
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
42
|
-
var _constants = require("../Label/constants");
|
43
43
|
var _SelectField = _interopRequireDefault(require("./SelectField.mdx"));
|
44
44
|
var _react2 = require("@emotion/react");
|
45
45
|
var _context, _context2;
|
@@ -159,7 +159,7 @@ var _default = {
|
|
159
159
|
labelMode: {
|
160
160
|
control: {
|
161
161
|
type: 'select',
|
162
|
-
options: (0, _values["default"])(
|
162
|
+
options: (0, _values["default"])(_labelModes.modes)
|
163
163
|
}
|
164
164
|
},
|
165
165
|
defaultSelectedKey: {},
|
@@ -180,7 +180,7 @@ var _default = {
|
|
180
180
|
}, _statusProp.statusArgTypes), _ariaAttributes.ariaAttributeBaseArgTypes), _fieldAttributes.inputFieldAttributeBaseArgTypes),
|
181
181
|
args: {
|
182
182
|
label: 'Example Label',
|
183
|
-
labelMode: (0, _values["default"])(
|
183
|
+
labelMode: (0, _values["default"])(_labelModes.modes)[0]
|
184
184
|
}
|
185
185
|
};
|
186
186
|
exports["default"] = _default;
|