@moda/om 16.2.1 → 17.1.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/CHANGELOG.md +26 -0
- package/dist/index.cjs.js +46 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +46 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Expandable/Expandable.d.ts +2 -0
- package/dist/src/components/Select/Select.d.ts +1 -0
- package/dist/src/components/Select/SelectOption.d.ts +1 -0
- package/dist/src/components/Select/SelectOptions.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Expandable/Expandable.tsx +15 -4
- package/src/components/Select/Select.tsx +4 -0
- package/src/components/Select/SelectOption.tsx +4 -1
- package/src/components/Select/SelectOptions.tsx +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [17.1.0](https://github.com/ModaOperandi/om/compare/v17.0.0...v17.1.0) (2022-08-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **expandable:** onToggle ([4a63534](https://github.com/ModaOperandi/om/commit/4a635341fab096716b343fbac498f804dc5eed4c))
|
|
12
|
+
|
|
13
|
+
# [17.0.0](https://github.com/ModaOperandi/om/compare/v16.3.0...v17.0.0) (2022-08-17)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **expandable:** allow it to be controlled ([#2848](https://github.com/ModaOperandi/om/issues/2848)) ([d7128b6](https://github.com/ModaOperandi/om/commit/d7128b60276da6f155acd4cb5abb910648a3a904))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### BREAKING CHANGES
|
|
22
|
+
|
|
23
|
+
* **expandable:** 'expanded' will now control the component completely
|
|
24
|
+
|
|
25
|
+
# [16.3.0](https://github.com/ModaOperandi/om/compare/v16.2.1...v16.3.0) (2022-07-06)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* **select:** adds data-test-id to Select component ([#2790](https://github.com/ModaOperandi/om/issues/2790)) ([2ba14ed](https://github.com/ModaOperandi/om/commit/2ba14ed15c7d588bf735fbb4202e09495d58e341))
|
|
31
|
+
|
|
6
32
|
## [16.2.1](https://github.com/ModaOperandi/om/compare/v16.2.0...v16.2.1) (2022-07-01)
|
|
7
33
|
|
|
8
34
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1000,20 +1000,20 @@ var typography_1 = typography;
|
|
|
1000
1000
|
|
|
1001
1001
|
var text = function text(name, font) {
|
|
1002
1002
|
if (font === void 0) {
|
|
1003
|
-
font =
|
|
1003
|
+
font = 'sans';
|
|
1004
1004
|
}
|
|
1005
1005
|
|
|
1006
|
-
var treatment = typography_1.typography[
|
|
1006
|
+
var treatment = typography_1.typography['text-treatments'][name];
|
|
1007
1007
|
return __assign$b(__assign$b({}, treatment), {
|
|
1008
|
-
|
|
1009
|
-
|
|
1008
|
+
'font-family': typography_1.typography.fonts[font].join(','),
|
|
1009
|
+
'line-height': "".concat(treatment['line-height'])
|
|
1010
1010
|
});
|
|
1011
1011
|
};
|
|
1012
1012
|
|
|
1013
1013
|
helpers.text = text;
|
|
1014
1014
|
|
|
1015
1015
|
var remToUnitlessPx = function remToUnitlessPx(value) {
|
|
1016
|
-
return parseFloat(value) * parseInt(typography_1.typography[
|
|
1016
|
+
return parseFloat(value) * parseInt(typography_1.typography['root-font-size'], 10);
|
|
1017
1017
|
};
|
|
1018
1018
|
|
|
1019
1019
|
helpers.remToUnitlessPx = remToUnitlessPx;
|
|
@@ -1022,18 +1022,19 @@ var color = function color(name, alpha) {
|
|
|
1022
1022
|
var _a;
|
|
1023
1023
|
|
|
1024
1024
|
var color = colors_1.colors.all[name];
|
|
1025
|
-
return alpha != null ?
|
|
1025
|
+
return alpha != null ? // eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
1026
|
+
colorString.to.rgb(__spreadArray$1(__spreadArray$1([], ((_a = colorString.get.rgb(color)) === null || _a === void 0 ? void 0 : _a.slice(0, 3)) || [], true), [alpha], false)) : color;
|
|
1026
1027
|
};
|
|
1027
1028
|
|
|
1028
1029
|
helpers.color = color;
|
|
1029
1030
|
|
|
1030
|
-
var spacing = function spacing(
|
|
1031
|
-
return [
|
|
1031
|
+
var spacing = function spacing(topY, rightX, bottom, left) {
|
|
1032
|
+
return [topY, rightX, bottom, left].reduce(function (acc, value) {
|
|
1032
1033
|
var _a;
|
|
1033
1034
|
|
|
1034
|
-
if (
|
|
1035
|
-
return [acc, (_a = space_1.space.scale[
|
|
1036
|
-
},
|
|
1035
|
+
if (value === undefined) return acc;
|
|
1036
|
+
return [acc, (_a = space_1.space.scale[value]) !== null && _a !== void 0 ? _a : value].join(' ');
|
|
1037
|
+
}, '');
|
|
1037
1038
|
};
|
|
1038
1039
|
|
|
1039
1040
|
helpers.spacing = spacing;
|
|
@@ -1042,12 +1043,18 @@ helpers.spacing = spacing;
|
|
|
1042
1043
|
|
|
1043
1044
|
var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
1044
1045
|
if (k2 === undefined) k2 = k;
|
|
1045
|
-
Object.
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1046
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1047
|
+
|
|
1048
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1049
|
+
desc = {
|
|
1050
|
+
enumerable: true,
|
|
1051
|
+
get: function get() {
|
|
1052
|
+
return m[k];
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
Object.defineProperty(o, k2, desc);
|
|
1051
1058
|
} : function (o, m, k, k2) {
|
|
1052
1059
|
if (k2 === undefined) k2 = k;
|
|
1053
1060
|
o[k2] = m[k];
|
|
@@ -9213,7 +9220,8 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
9213
9220
|
selected = _ref.selected,
|
|
9214
9221
|
option = _ref.option,
|
|
9215
9222
|
onClick = _ref.onClick,
|
|
9216
|
-
className = _ref.className
|
|
9223
|
+
className = _ref.className,
|
|
9224
|
+
dataTestId = _ref.dataTestId;
|
|
9217
9225
|
var ref = React.useRef(null);
|
|
9218
9226
|
var handleClick = React.useCallback(function (event) {
|
|
9219
9227
|
event.preventDefault();
|
|
@@ -9235,13 +9243,14 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
9235
9243
|
'SelectOption--disabled': option.disabled
|
|
9236
9244
|
}),
|
|
9237
9245
|
onClick: handleClick,
|
|
9246
|
+
"data-test-id": dataTestId ? "".concat(dataTestId, "--").concat(option.label.replace(' ', '-')) : undefined,
|
|
9238
9247
|
"aria-label": option.label,
|
|
9239
9248
|
"aria-selected": selected,
|
|
9240
9249
|
role: "option"
|
|
9241
9250
|
}, option.label);
|
|
9242
9251
|
};
|
|
9243
9252
|
|
|
9244
|
-
var _excluded$m = ["idRef", "searchable", "autoFocus", "options", "selectedOption", "onSelect", "onFocus", "className"];
|
|
9253
|
+
var _excluded$m = ["idRef", "searchable", "autoFocus", "options", "selectedOption", "onSelect", "onFocus", "className", "dataTestId"];
|
|
9245
9254
|
var SelectOptions = function SelectOptions(_ref) {
|
|
9246
9255
|
var idRef = _ref.idRef,
|
|
9247
9256
|
searchable = _ref.searchable,
|
|
@@ -9252,6 +9261,7 @@ var SelectOptions = function SelectOptions(_ref) {
|
|
|
9252
9261
|
onSelect = _ref.onSelect,
|
|
9253
9262
|
onFocus = _ref.onFocus,
|
|
9254
9263
|
className = _ref.className,
|
|
9264
|
+
dataTestId = _ref.dataTestId,
|
|
9255
9265
|
rest = _objectWithoutProperties(_ref, _excluded$m);
|
|
9256
9266
|
|
|
9257
9267
|
var _useState = React.useState(''),
|
|
@@ -9309,6 +9319,7 @@ var SelectOptions = function SelectOptions(_ref) {
|
|
|
9309
9319
|
id: "SelectOption--".concat(option.value, "-").concat(idRef),
|
|
9310
9320
|
key: option.value,
|
|
9311
9321
|
option: option,
|
|
9322
|
+
dataTestId: dataTestId,
|
|
9312
9323
|
active: (activeOption === null || activeOption === void 0 ? void 0 : activeOption.value) === option.value,
|
|
9313
9324
|
selected: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value,
|
|
9314
9325
|
onClick: onSelect
|
|
@@ -9430,7 +9441,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
9430
9441
|
};
|
|
9431
9442
|
};
|
|
9432
9443
|
|
|
9433
|
-
var _excluded$l = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value"];
|
|
9444
|
+
var _excluded$l = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId"];
|
|
9434
9445
|
var Select = function Select(_ref) {
|
|
9435
9446
|
var _ref2;
|
|
9436
9447
|
|
|
@@ -9456,6 +9467,7 @@ var Select = function Select(_ref) {
|
|
|
9456
9467
|
_ref$shiftIconLeftwar = _ref.shiftIconLeftwards,
|
|
9457
9468
|
shiftIconLeftwards = _ref$shiftIconLeftwar === void 0 ? false : _ref$shiftIconLeftwar,
|
|
9458
9469
|
value = _ref.value,
|
|
9470
|
+
dataTestId = _ref.dataTestId,
|
|
9459
9471
|
rest = _objectWithoutProperties(_ref, _excluded$l);
|
|
9460
9472
|
|
|
9461
9473
|
var _useSelect = useSelect({
|
|
@@ -9524,6 +9536,7 @@ var Select = function Select(_ref) {
|
|
|
9524
9536
|
className: "Select__value",
|
|
9525
9537
|
disabled: disabled,
|
|
9526
9538
|
onClick: handleToggle,
|
|
9539
|
+
"data-test-id": dataTestId,
|
|
9527
9540
|
"aria-haspopup": "listbox",
|
|
9528
9541
|
"aria-expanded": state.mode === Mode.Open,
|
|
9529
9542
|
"aria-labelledby": "Select__label--".concat(idRef, " Select__value--").concat(idRef),
|
|
@@ -9543,6 +9556,7 @@ var Select = function Select(_ref) {
|
|
|
9543
9556
|
'Select__options--up': dropDirection === 'up',
|
|
9544
9557
|
'Select__options--down': dropDirection === 'down'
|
|
9545
9558
|
}),
|
|
9559
|
+
dataTestId: dataTestId,
|
|
9546
9560
|
searchable: searchable,
|
|
9547
9561
|
options: options,
|
|
9548
9562
|
onSelect: handleSelect,
|
|
@@ -11356,7 +11370,7 @@ var DefinitionList = function DefinitionList(_ref) {
|
|
|
11356
11370
|
}, rest), /*#__PURE__*/React__default["default"].createElement("dt", null, term), /*#__PURE__*/React__default["default"].createElement("dd", null, children));
|
|
11357
11371
|
};
|
|
11358
11372
|
|
|
11359
|
-
var _excluded$f = ["name", "children", "className", "virtual", "icon", "data-testid", "expanded"];
|
|
11373
|
+
var _excluded$f = ["name", "children", "className", "virtual", "icon", "data-testid", "defaultExpanded", "expanded", "onToggle"];
|
|
11360
11374
|
var Expandable = function Expandable(_ref) {
|
|
11361
11375
|
var name = _ref.name,
|
|
11362
11376
|
children = _ref.children,
|
|
@@ -11366,20 +11380,26 @@ var Expandable = function Expandable(_ref) {
|
|
|
11366
11380
|
_ref$icon = _ref.icon,
|
|
11367
11381
|
icon = _ref$icon === void 0 ? 'plus-minus' : _ref$icon,
|
|
11368
11382
|
dataTestId = _ref['data-testid'],
|
|
11369
|
-
_ref$
|
|
11370
|
-
|
|
11383
|
+
_ref$defaultExpanded = _ref.defaultExpanded,
|
|
11384
|
+
defaultExpanded = _ref$defaultExpanded === void 0 ? false : _ref$defaultExpanded,
|
|
11385
|
+
__expanded__ = _ref.expanded,
|
|
11386
|
+
onToggle = _ref.onToggle,
|
|
11371
11387
|
rest = _objectWithoutProperties(_ref, _excluded$f);
|
|
11372
11388
|
|
|
11373
|
-
var _useState = React.useState(
|
|
11389
|
+
var _useState = React.useState(defaultExpanded),
|
|
11374
11390
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11375
11391
|
expanded = _useState2[0],
|
|
11376
11392
|
setExpanded = _useState2[1];
|
|
11377
11393
|
|
|
11394
|
+
React.useEffect(function () {
|
|
11395
|
+
if (__expanded__ != null && __expanded__ !== expanded) setExpanded(__expanded__);
|
|
11396
|
+
}, [expanded, __expanded__]);
|
|
11378
11397
|
var handleClick = React.useCallback(function () {
|
|
11379
|
-
|
|
11398
|
+
setExpanded(function (expanded) {
|
|
11380
11399
|
return !expanded;
|
|
11381
11400
|
});
|
|
11382
|
-
|
|
11401
|
+
onToggle === null || onToggle === void 0 ? void 0 : onToggle();
|
|
11402
|
+
}, [onToggle]);
|
|
11383
11403
|
return /*#__PURE__*/React__default["default"].createElement("div", _extends$1({
|
|
11384
11404
|
className: classNames('Expandable', {
|
|
11385
11405
|
'Expandable--expanded': expanded
|