@moda/om 17.12.0 → 17.13.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 +7 -0
- package/dist/index.cjs.js +92 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +92 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Button/Button.d.ts +2 -0
- package/dist/src/components/Button/Button.stories.d.ts +2 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/components/Button/Button.scss +38 -0
- package/src/components/Button/Button.stories.tsx +16 -0
- package/src/components/Button/Button.tsx +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
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.13.0](https://github.com/ModaOperandi/om/compare/v17.12.0...v17.13.0) (2022-11-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **button:** adds tertiary and elevated ([#3050](https://github.com/ModaOperandi/om/issues/3050)) ([6f1030d](https://github.com/ModaOperandi/om/commit/6f1030d5768aaf80ecbdf2866e90b3e993656f4d))
|
|
12
|
+
|
|
6
13
|
# [17.12.0](https://github.com/ModaOperandi/om/compare/v17.11.0...v17.12.0) (2022-11-09)
|
|
7
14
|
|
|
8
15
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -2818,7 +2818,9 @@ var mediumFocus = createMedium({}, function (_ref) {
|
|
|
2818
2818
|
var mediumBlur = createMedium();
|
|
2819
2819
|
var mediumEffect = createMedium();
|
|
2820
2820
|
var mediumSidecar = createSidecarMedium({
|
|
2821
|
-
async: true
|
|
2821
|
+
async: true // focus-lock sidecar is not required on the server
|
|
2822
|
+
// however, it might be required for JSDOM tests
|
|
2823
|
+
// ssr: true,
|
|
2822
2824
|
});
|
|
2823
2825
|
|
|
2824
2826
|
var emptyArray = [];
|
|
@@ -2915,7 +2917,8 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2915
2917
|
console.warn('React-Focus-Lock: allowTextSelection is deprecated and enabled by default');
|
|
2916
2918
|
}
|
|
2917
2919
|
React__namespace.useEffect(function () {
|
|
2918
|
-
|
|
2920
|
+
// report incorrect integration - https://github.com/theKashey/react-focus-lock/issues/123
|
|
2921
|
+
if (!observed.current && typeof Container !== 'string') {
|
|
2919
2922
|
// eslint-disable-next-line no-console
|
|
2920
2923
|
console.error('FocusLock: could not obtain ref to internal node');
|
|
2921
2924
|
}
|
|
@@ -3042,9 +3045,10 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3042
3045
|
sideCar = props.sideCar,
|
|
3043
3046
|
className = props.className,
|
|
3044
3047
|
shouldIgnore = props.shouldIgnore,
|
|
3048
|
+
preventScrollOnFocus = props.preventScrollOnFocus,
|
|
3045
3049
|
style = props.style,
|
|
3046
3050
|
as = props.as,
|
|
3047
|
-
rest = __rest$a(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "style", "as"]);
|
|
3051
|
+
rest = __rest$a(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as"]);
|
|
3048
3052
|
var SideCar = sideCar;
|
|
3049
3053
|
var onActivation = lockProps.onActivation,
|
|
3050
3054
|
onDeactivation = lockProps.onDeactivation,
|
|
@@ -3070,6 +3074,9 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3070
3074
|
className: className,
|
|
3071
3075
|
whiteList: shouldIgnore,
|
|
3072
3076
|
lockProps: appliedLockProps,
|
|
3077
|
+
focusOptions: preventScrollOnFocus ? {
|
|
3078
|
+
preventScroll: true
|
|
3079
|
+
} : undefined,
|
|
3073
3080
|
as: RemoveScroll
|
|
3074
3081
|
}, children), enabled && /*#__PURE__*/React__namespace.createElement(SideCar, _assign({}, rest, {
|
|
3075
3082
|
sideCar: effectCar,
|
|
@@ -4181,22 +4188,25 @@ var nonPassive = passiveSupported ? {
|
|
|
4181
4188
|
passive: false
|
|
4182
4189
|
} : false;
|
|
4183
4190
|
|
|
4184
|
-
var
|
|
4191
|
+
var alwaysContainsScroll = function alwaysContainsScroll(node) {
|
|
4192
|
+
// textarea will always _contain_ scroll inside self. It only can be hidden
|
|
4193
|
+
return node.tagName === 'TEXTAREA';
|
|
4194
|
+
};
|
|
4195
|
+
var elementCanBeScrolled = function elementCanBeScrolled(node, overflow) {
|
|
4185
4196
|
var styles = window.getComputedStyle(node);
|
|
4186
|
-
return
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4197
|
+
return (
|
|
4198
|
+
// not-not-scrollable
|
|
4199
|
+
styles[overflow] !== 'hidden' &&
|
|
4200
|
+
// contains scroll inside self
|
|
4201
|
+
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible')
|
|
4202
|
+
);
|
|
4203
|
+
};
|
|
4204
|
+
var elementCouldBeVScrolled = function elementCouldBeVScrolled(node) {
|
|
4205
|
+
return elementCanBeScrolled(node, 'overflowY');
|
|
4190
4206
|
};
|
|
4191
|
-
|
|
4192
4207
|
var elementCouldBeHScrolled = function elementCouldBeHScrolled(node) {
|
|
4193
|
-
|
|
4194
|
-
return styles.overflowX !== 'hidden' &&
|
|
4195
|
-
// not-not-scrollable
|
|
4196
|
-
!(styles.overflowY === styles.overflowX && styles.overflowX === 'visible') // scrollable
|
|
4197
|
-
;
|
|
4208
|
+
return elementCanBeScrolled(node, 'overflowX');
|
|
4198
4209
|
};
|
|
4199
|
-
|
|
4200
4210
|
var locationCouldBeScrolled = function locationCouldBeScrolled(axis, node) {
|
|
4201
4211
|
var current = node;
|
|
4202
4212
|
do {
|
|
@@ -4375,7 +4385,9 @@ function RemoveScrollSideCar(props) {
|
|
|
4375
4385
|
})[0];
|
|
4376
4386
|
// self event, and should be canceled
|
|
4377
4387
|
if (sourceEvent && sourceEvent.should) {
|
|
4378
|
-
event.
|
|
4388
|
+
if (event.cancelable) {
|
|
4389
|
+
event.preventDefault();
|
|
4390
|
+
}
|
|
4379
4391
|
return;
|
|
4380
4392
|
}
|
|
4381
4393
|
// outside or shard event
|
|
@@ -4385,7 +4397,9 @@ function RemoveScrollSideCar(props) {
|
|
|
4385
4397
|
});
|
|
4386
4398
|
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
4387
4399
|
if (shouldStop) {
|
|
4388
|
-
event.
|
|
4400
|
+
if (event.cancelable) {
|
|
4401
|
+
event.preventDefault();
|
|
4402
|
+
}
|
|
4389
4403
|
}
|
|
4390
4404
|
}
|
|
4391
4405
|
}, []);
|
|
@@ -4454,20 +4468,41 @@ var counterMap = new WeakMap();
|
|
|
4454
4468
|
var uncontrolledNodes = new WeakMap();
|
|
4455
4469
|
var markerMap = {};
|
|
4456
4470
|
var lockCount = 0;
|
|
4457
|
-
var
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4471
|
+
var unwrapHost = function unwrapHost(node) {
|
|
4472
|
+
return node && (node.host || unwrapHost(node.parentNode));
|
|
4473
|
+
};
|
|
4474
|
+
var correctTargets = function correctTargets(parent, targets) {
|
|
4475
|
+
return targets.map(function (target) {
|
|
4476
|
+
if (parent.contains(target)) {
|
|
4477
|
+
return target;
|
|
4478
|
+
}
|
|
4479
|
+
var correctedTarget = unwrapHost(target);
|
|
4480
|
+
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
4481
|
+
return correctedTarget;
|
|
4482
|
+
}
|
|
4483
|
+
console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
|
|
4484
|
+
return null;
|
|
4485
|
+
}).filter(function (x) {
|
|
4486
|
+
return Boolean(x);
|
|
4487
|
+
});
|
|
4488
|
+
};
|
|
4489
|
+
/**
|
|
4490
|
+
* Marks everything except given node(or nodes) as aria-hidden
|
|
4491
|
+
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
4492
|
+
* @param [parentNode] - top element, defaults to document.body
|
|
4493
|
+
* @param {String} [markerName] - a special attribute to mark every node
|
|
4494
|
+
* @param {String} [controlAttribute] - html Attribute to control
|
|
4495
|
+
* @return {Undo} undo command
|
|
4496
|
+
*/
|
|
4497
|
+
var applyAttributeToOthers = function applyAttributeToOthers(originalTarget, parentNode, markerName, controlAttribute) {
|
|
4498
|
+
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
4465
4499
|
if (!markerMap[markerName]) {
|
|
4466
4500
|
markerMap[markerName] = new WeakMap();
|
|
4467
4501
|
}
|
|
4468
4502
|
var markerCounter = markerMap[markerName];
|
|
4469
4503
|
var hiddenNodes = [];
|
|
4470
4504
|
var elementsToKeep = new Set();
|
|
4505
|
+
var elementsToStop = new Set(targets);
|
|
4471
4506
|
var keep = function keep(el) {
|
|
4472
4507
|
if (!el || elementsToKeep.has(el)) {
|
|
4473
4508
|
return;
|
|
@@ -4477,14 +4512,14 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4477
4512
|
};
|
|
4478
4513
|
targets.forEach(keep);
|
|
4479
4514
|
var deep = function deep(parent) {
|
|
4480
|
-
if (!parent ||
|
|
4515
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
4481
4516
|
return;
|
|
4482
4517
|
}
|
|
4483
4518
|
Array.prototype.forEach.call(parent.children, function (node) {
|
|
4484
4519
|
if (elementsToKeep.has(node)) {
|
|
4485
4520
|
deep(node);
|
|
4486
4521
|
} else {
|
|
4487
|
-
var attr = node.getAttribute(
|
|
4522
|
+
var attr = node.getAttribute(controlAttribute);
|
|
4488
4523
|
var alreadyHidden = attr !== null && attr !== 'false';
|
|
4489
4524
|
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
4490
4525
|
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
@@ -4498,7 +4533,7 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4498
4533
|
node.setAttribute(markerName, 'true');
|
|
4499
4534
|
}
|
|
4500
4535
|
if (!alreadyHidden) {
|
|
4501
|
-
node.setAttribute(
|
|
4536
|
+
node.setAttribute(controlAttribute, 'true');
|
|
4502
4537
|
}
|
|
4503
4538
|
}
|
|
4504
4539
|
});
|
|
@@ -4514,7 +4549,7 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4514
4549
|
markerCounter.set(node, markerValue);
|
|
4515
4550
|
if (!counterValue) {
|
|
4516
4551
|
if (!uncontrolledNodes.has(node)) {
|
|
4517
|
-
node.removeAttribute(
|
|
4552
|
+
node.removeAttribute(controlAttribute);
|
|
4518
4553
|
}
|
|
4519
4554
|
uncontrolledNodes["delete"](node);
|
|
4520
4555
|
}
|
|
@@ -4524,6 +4559,7 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4524
4559
|
});
|
|
4525
4560
|
lockCount--;
|
|
4526
4561
|
if (!lockCount) {
|
|
4562
|
+
// clear
|
|
4527
4563
|
counterMap = new WeakMap();
|
|
4528
4564
|
counterMap = new WeakMap();
|
|
4529
4565
|
uncontrolledNodes = new WeakMap();
|
|
@@ -4531,6 +4567,28 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4531
4567
|
}
|
|
4532
4568
|
};
|
|
4533
4569
|
};
|
|
4570
|
+
/**
|
|
4571
|
+
* Marks everything except given node(or nodes) as aria-hidden
|
|
4572
|
+
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
4573
|
+
* @param [parentNode] - top element, defaults to document.body
|
|
4574
|
+
* @param {String} [markerName] - a special attribute to mark every node
|
|
4575
|
+
* @return {Undo} undo command
|
|
4576
|
+
*/
|
|
4577
|
+
var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
4578
|
+
if (markerName === void 0) {
|
|
4579
|
+
markerName = 'data-aria-hidden';
|
|
4580
|
+
}
|
|
4581
|
+
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
4582
|
+
var activeParentNode = parentNode || getDefaultParent(originalTarget);
|
|
4583
|
+
if (!activeParentNode) {
|
|
4584
|
+
return function () {
|
|
4585
|
+
return null;
|
|
4586
|
+
};
|
|
4587
|
+
}
|
|
4588
|
+
// we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
|
|
4589
|
+
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
|
|
4590
|
+
return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
|
|
4591
|
+
};
|
|
4534
4592
|
|
|
4535
4593
|
var Style = styleSingleton();
|
|
4536
4594
|
var styles = "\n [" + focusHiddenMarker + "] {\n pointer-events: none !important;\n }\n";
|
|
@@ -6407,9 +6465,11 @@ var Breakpoint = function Breakpoint(_ref) {
|
|
|
6407
6465
|
}, omit$1(['at', 'gt', 'lt'], rest)), children) : null;
|
|
6408
6466
|
};
|
|
6409
6467
|
|
|
6410
|
-
var _excluded$v = ["secondary", "chip", "hover", "focus", "disabled", "className"];
|
|
6468
|
+
var _excluded$v = ["secondary", "tertiary", "elevated", "chip", "hover", "focus", "disabled", "className"];
|
|
6411
6469
|
var Button = function Button(_ref) {
|
|
6412
6470
|
var secondary = _ref.secondary,
|
|
6471
|
+
tertiary = _ref.tertiary,
|
|
6472
|
+
elevated = _ref.elevated,
|
|
6413
6473
|
chip = _ref.chip,
|
|
6414
6474
|
hover = _ref.hover,
|
|
6415
6475
|
focus = _ref.focus,
|
|
@@ -6420,6 +6480,8 @@ var Button = function Button(_ref) {
|
|
|
6420
6480
|
className: classNames('Button', {
|
|
6421
6481
|
'Button--chip': chip,
|
|
6422
6482
|
'Button--secondary': secondary,
|
|
6483
|
+
'Button--tertiary': tertiary,
|
|
6484
|
+
'Button--elevated': elevated,
|
|
6423
6485
|
'Button--hover': hover,
|
|
6424
6486
|
'Button--focus': focus,
|
|
6425
6487
|
'Button--disabled': disabled
|