@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/dist/index.esm.js
CHANGED
|
@@ -2798,7 +2798,9 @@ var mediumFocus = createMedium({}, function (_ref) {
|
|
|
2798
2798
|
var mediumBlur = createMedium();
|
|
2799
2799
|
var mediumEffect = createMedium();
|
|
2800
2800
|
var mediumSidecar = createSidecarMedium({
|
|
2801
|
-
async: true
|
|
2801
|
+
async: true // focus-lock sidecar is not required on the server
|
|
2802
|
+
// however, it might be required for JSDOM tests
|
|
2803
|
+
// ssr: true,
|
|
2802
2804
|
});
|
|
2803
2805
|
|
|
2804
2806
|
var emptyArray = [];
|
|
@@ -2895,7 +2897,8 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2895
2897
|
console.warn('React-Focus-Lock: allowTextSelection is deprecated and enabled by default');
|
|
2896
2898
|
}
|
|
2897
2899
|
React.useEffect(function () {
|
|
2898
|
-
|
|
2900
|
+
// report incorrect integration - https://github.com/theKashey/react-focus-lock/issues/123
|
|
2901
|
+
if (!observed.current && typeof Container !== 'string') {
|
|
2899
2902
|
// eslint-disable-next-line no-console
|
|
2900
2903
|
console.error('FocusLock: could not obtain ref to internal node');
|
|
2901
2904
|
}
|
|
@@ -3022,9 +3025,10 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3022
3025
|
sideCar = props.sideCar,
|
|
3023
3026
|
className = props.className,
|
|
3024
3027
|
shouldIgnore = props.shouldIgnore,
|
|
3028
|
+
preventScrollOnFocus = props.preventScrollOnFocus,
|
|
3025
3029
|
style = props.style,
|
|
3026
3030
|
as = props.as,
|
|
3027
|
-
rest = __rest$a(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "style", "as"]);
|
|
3031
|
+
rest = __rest$a(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as"]);
|
|
3028
3032
|
var SideCar = sideCar;
|
|
3029
3033
|
var onActivation = lockProps.onActivation,
|
|
3030
3034
|
onDeactivation = lockProps.onDeactivation,
|
|
@@ -3050,6 +3054,9 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3050
3054
|
className: className,
|
|
3051
3055
|
whiteList: shouldIgnore,
|
|
3052
3056
|
lockProps: appliedLockProps,
|
|
3057
|
+
focusOptions: preventScrollOnFocus ? {
|
|
3058
|
+
preventScroll: true
|
|
3059
|
+
} : undefined,
|
|
3053
3060
|
as: RemoveScroll
|
|
3054
3061
|
}, children), enabled && /*#__PURE__*/React.createElement(SideCar, _assign({}, rest, {
|
|
3055
3062
|
sideCar: effectCar,
|
|
@@ -4161,22 +4168,25 @@ var nonPassive = passiveSupported ? {
|
|
|
4161
4168
|
passive: false
|
|
4162
4169
|
} : false;
|
|
4163
4170
|
|
|
4164
|
-
var
|
|
4171
|
+
var alwaysContainsScroll = function alwaysContainsScroll(node) {
|
|
4172
|
+
// textarea will always _contain_ scroll inside self. It only can be hidden
|
|
4173
|
+
return node.tagName === 'TEXTAREA';
|
|
4174
|
+
};
|
|
4175
|
+
var elementCanBeScrolled = function elementCanBeScrolled(node, overflow) {
|
|
4165
4176
|
var styles = window.getComputedStyle(node);
|
|
4166
|
-
return
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4177
|
+
return (
|
|
4178
|
+
// not-not-scrollable
|
|
4179
|
+
styles[overflow] !== 'hidden' &&
|
|
4180
|
+
// contains scroll inside self
|
|
4181
|
+
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible')
|
|
4182
|
+
);
|
|
4183
|
+
};
|
|
4184
|
+
var elementCouldBeVScrolled = function elementCouldBeVScrolled(node) {
|
|
4185
|
+
return elementCanBeScrolled(node, 'overflowY');
|
|
4170
4186
|
};
|
|
4171
|
-
|
|
4172
4187
|
var elementCouldBeHScrolled = function elementCouldBeHScrolled(node) {
|
|
4173
|
-
|
|
4174
|
-
return styles.overflowX !== 'hidden' &&
|
|
4175
|
-
// not-not-scrollable
|
|
4176
|
-
!(styles.overflowY === styles.overflowX && styles.overflowX === 'visible') // scrollable
|
|
4177
|
-
;
|
|
4188
|
+
return elementCanBeScrolled(node, 'overflowX');
|
|
4178
4189
|
};
|
|
4179
|
-
|
|
4180
4190
|
var locationCouldBeScrolled = function locationCouldBeScrolled(axis, node) {
|
|
4181
4191
|
var current = node;
|
|
4182
4192
|
do {
|
|
@@ -4355,7 +4365,9 @@ function RemoveScrollSideCar(props) {
|
|
|
4355
4365
|
})[0];
|
|
4356
4366
|
// self event, and should be canceled
|
|
4357
4367
|
if (sourceEvent && sourceEvent.should) {
|
|
4358
|
-
event.
|
|
4368
|
+
if (event.cancelable) {
|
|
4369
|
+
event.preventDefault();
|
|
4370
|
+
}
|
|
4359
4371
|
return;
|
|
4360
4372
|
}
|
|
4361
4373
|
// outside or shard event
|
|
@@ -4365,7 +4377,9 @@ function RemoveScrollSideCar(props) {
|
|
|
4365
4377
|
});
|
|
4366
4378
|
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
4367
4379
|
if (shouldStop) {
|
|
4368
|
-
event.
|
|
4380
|
+
if (event.cancelable) {
|
|
4381
|
+
event.preventDefault();
|
|
4382
|
+
}
|
|
4369
4383
|
}
|
|
4370
4384
|
}
|
|
4371
4385
|
}, []);
|
|
@@ -4434,20 +4448,41 @@ var counterMap = new WeakMap();
|
|
|
4434
4448
|
var uncontrolledNodes = new WeakMap();
|
|
4435
4449
|
var markerMap = {};
|
|
4436
4450
|
var lockCount = 0;
|
|
4437
|
-
var
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4451
|
+
var unwrapHost = function unwrapHost(node) {
|
|
4452
|
+
return node && (node.host || unwrapHost(node.parentNode));
|
|
4453
|
+
};
|
|
4454
|
+
var correctTargets = function correctTargets(parent, targets) {
|
|
4455
|
+
return targets.map(function (target) {
|
|
4456
|
+
if (parent.contains(target)) {
|
|
4457
|
+
return target;
|
|
4458
|
+
}
|
|
4459
|
+
var correctedTarget = unwrapHost(target);
|
|
4460
|
+
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
4461
|
+
return correctedTarget;
|
|
4462
|
+
}
|
|
4463
|
+
console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
|
|
4464
|
+
return null;
|
|
4465
|
+
}).filter(function (x) {
|
|
4466
|
+
return Boolean(x);
|
|
4467
|
+
});
|
|
4468
|
+
};
|
|
4469
|
+
/**
|
|
4470
|
+
* Marks everything except given node(or nodes) as aria-hidden
|
|
4471
|
+
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
4472
|
+
* @param [parentNode] - top element, defaults to document.body
|
|
4473
|
+
* @param {String} [markerName] - a special attribute to mark every node
|
|
4474
|
+
* @param {String} [controlAttribute] - html Attribute to control
|
|
4475
|
+
* @return {Undo} undo command
|
|
4476
|
+
*/
|
|
4477
|
+
var applyAttributeToOthers = function applyAttributeToOthers(originalTarget, parentNode, markerName, controlAttribute) {
|
|
4478
|
+
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
4445
4479
|
if (!markerMap[markerName]) {
|
|
4446
4480
|
markerMap[markerName] = new WeakMap();
|
|
4447
4481
|
}
|
|
4448
4482
|
var markerCounter = markerMap[markerName];
|
|
4449
4483
|
var hiddenNodes = [];
|
|
4450
4484
|
var elementsToKeep = new Set();
|
|
4485
|
+
var elementsToStop = new Set(targets);
|
|
4451
4486
|
var keep = function keep(el) {
|
|
4452
4487
|
if (!el || elementsToKeep.has(el)) {
|
|
4453
4488
|
return;
|
|
@@ -4457,14 +4492,14 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4457
4492
|
};
|
|
4458
4493
|
targets.forEach(keep);
|
|
4459
4494
|
var deep = function deep(parent) {
|
|
4460
|
-
if (!parent ||
|
|
4495
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
4461
4496
|
return;
|
|
4462
4497
|
}
|
|
4463
4498
|
Array.prototype.forEach.call(parent.children, function (node) {
|
|
4464
4499
|
if (elementsToKeep.has(node)) {
|
|
4465
4500
|
deep(node);
|
|
4466
4501
|
} else {
|
|
4467
|
-
var attr = node.getAttribute(
|
|
4502
|
+
var attr = node.getAttribute(controlAttribute);
|
|
4468
4503
|
var alreadyHidden = attr !== null && attr !== 'false';
|
|
4469
4504
|
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
4470
4505
|
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
@@ -4478,7 +4513,7 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4478
4513
|
node.setAttribute(markerName, 'true');
|
|
4479
4514
|
}
|
|
4480
4515
|
if (!alreadyHidden) {
|
|
4481
|
-
node.setAttribute(
|
|
4516
|
+
node.setAttribute(controlAttribute, 'true');
|
|
4482
4517
|
}
|
|
4483
4518
|
}
|
|
4484
4519
|
});
|
|
@@ -4494,7 +4529,7 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4494
4529
|
markerCounter.set(node, markerValue);
|
|
4495
4530
|
if (!counterValue) {
|
|
4496
4531
|
if (!uncontrolledNodes.has(node)) {
|
|
4497
|
-
node.removeAttribute(
|
|
4532
|
+
node.removeAttribute(controlAttribute);
|
|
4498
4533
|
}
|
|
4499
4534
|
uncontrolledNodes["delete"](node);
|
|
4500
4535
|
}
|
|
@@ -4504,6 +4539,7 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4504
4539
|
});
|
|
4505
4540
|
lockCount--;
|
|
4506
4541
|
if (!lockCount) {
|
|
4542
|
+
// clear
|
|
4507
4543
|
counterMap = new WeakMap();
|
|
4508
4544
|
counterMap = new WeakMap();
|
|
4509
4545
|
uncontrolledNodes = new WeakMap();
|
|
@@ -4511,6 +4547,28 @@ var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
|
4511
4547
|
}
|
|
4512
4548
|
};
|
|
4513
4549
|
};
|
|
4550
|
+
/**
|
|
4551
|
+
* Marks everything except given node(or nodes) as aria-hidden
|
|
4552
|
+
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
4553
|
+
* @param [parentNode] - top element, defaults to document.body
|
|
4554
|
+
* @param {String} [markerName] - a special attribute to mark every node
|
|
4555
|
+
* @return {Undo} undo command
|
|
4556
|
+
*/
|
|
4557
|
+
var hideOthers = function hideOthers(originalTarget, parentNode, markerName) {
|
|
4558
|
+
if (markerName === void 0) {
|
|
4559
|
+
markerName = 'data-aria-hidden';
|
|
4560
|
+
}
|
|
4561
|
+
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
4562
|
+
var activeParentNode = parentNode || getDefaultParent(originalTarget);
|
|
4563
|
+
if (!activeParentNode) {
|
|
4564
|
+
return function () {
|
|
4565
|
+
return null;
|
|
4566
|
+
};
|
|
4567
|
+
}
|
|
4568
|
+
// we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
|
|
4569
|
+
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
|
|
4570
|
+
return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
|
|
4571
|
+
};
|
|
4514
4572
|
|
|
4515
4573
|
var Style = styleSingleton();
|
|
4516
4574
|
var styles = "\n [" + focusHiddenMarker + "] {\n pointer-events: none !important;\n }\n";
|
|
@@ -6387,9 +6445,11 @@ var Breakpoint = function Breakpoint(_ref) {
|
|
|
6387
6445
|
}, omit$1(['at', 'gt', 'lt'], rest)), children) : null;
|
|
6388
6446
|
};
|
|
6389
6447
|
|
|
6390
|
-
var _excluded$v = ["secondary", "chip", "hover", "focus", "disabled", "className"];
|
|
6448
|
+
var _excluded$v = ["secondary", "tertiary", "elevated", "chip", "hover", "focus", "disabled", "className"];
|
|
6391
6449
|
var Button = function Button(_ref) {
|
|
6392
6450
|
var secondary = _ref.secondary,
|
|
6451
|
+
tertiary = _ref.tertiary,
|
|
6452
|
+
elevated = _ref.elevated,
|
|
6393
6453
|
chip = _ref.chip,
|
|
6394
6454
|
hover = _ref.hover,
|
|
6395
6455
|
focus = _ref.focus,
|
|
@@ -6400,6 +6460,8 @@ var Button = function Button(_ref) {
|
|
|
6400
6460
|
className: classNames('Button', {
|
|
6401
6461
|
'Button--chip': chip,
|
|
6402
6462
|
'Button--secondary': secondary,
|
|
6463
|
+
'Button--tertiary': tertiary,
|
|
6464
|
+
'Button--elevated': elevated,
|
|
6403
6465
|
'Button--hover': hover,
|
|
6404
6466
|
'Button--focus': focus,
|
|
6405
6467
|
'Button--disabled': disabled
|