@mackin.com/styleguide 11.0.12 → 11.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/index.d.ts +188 -162
- package/index.esm.js +1170 -1058
- package/index.js +1170 -1057
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1260,6 +1260,128 @@ const styles = {
|
|
|
1260
1260
|
}),
|
|
1261
1261
|
};
|
|
1262
1262
|
|
|
1263
|
+
const defaultMinChars = 3;
|
|
1264
|
+
class AutocompleteController {
|
|
1265
|
+
constructor(getOptions, config) {
|
|
1266
|
+
var _a;
|
|
1267
|
+
this._value = undefined;
|
|
1268
|
+
this._options = [];
|
|
1269
|
+
this._minChars = (_a = config === null || config === void 0 ? void 0 : config.minChars) !== null && _a !== void 0 ? _a : defaultMinChars;
|
|
1270
|
+
if (config === null || config === void 0 ? void 0 : config.debounceMs) {
|
|
1271
|
+
this.getOptions = createDebouncedPromise(getOptions, config === null || config === void 0 ? void 0 : config.debounceMs);
|
|
1272
|
+
}
|
|
1273
|
+
else {
|
|
1274
|
+
this.getOptions = getOptions;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
get value() {
|
|
1278
|
+
return this._value;
|
|
1279
|
+
}
|
|
1280
|
+
get options() {
|
|
1281
|
+
return this._options;
|
|
1282
|
+
}
|
|
1283
|
+
async onChange(newValue) {
|
|
1284
|
+
// don't make getOptions calls if the value hasn't changed.
|
|
1285
|
+
if (newValue === this.value) {
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
// nullish should not make the getOptions call and instead clear everything.
|
|
1289
|
+
if (!newValue) {
|
|
1290
|
+
this._value = newValue;
|
|
1291
|
+
this._options = [];
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
// sub min chars should clear everything and not attempt the getOptions call.
|
|
1295
|
+
if (newValue.length < this._minChars) {
|
|
1296
|
+
this._value = newValue;
|
|
1297
|
+
this._options = [];
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
try {
|
|
1301
|
+
this._value = newValue;
|
|
1302
|
+
this._options = (await this.getOptions(newValue));
|
|
1303
|
+
}
|
|
1304
|
+
catch (err) {
|
|
1305
|
+
// this method will throw errors on debounce rejections. that is to be expected.
|
|
1306
|
+
// for actual getOptions exceptions, the owner of that function will need to handle errors.
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
onPick(newValue) {
|
|
1310
|
+
this._value = newValue;
|
|
1311
|
+
this._options = [];
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
const createDebouncedPromise = (originalFunction, trailingTimeoutMs) => {
|
|
1315
|
+
let timer;
|
|
1316
|
+
let onCancel;
|
|
1317
|
+
return (value) => {
|
|
1318
|
+
if (timer) {
|
|
1319
|
+
clearTimeout(timer);
|
|
1320
|
+
}
|
|
1321
|
+
if (onCancel) {
|
|
1322
|
+
onCancel('Promise cancelled due to in-progress debounce call.');
|
|
1323
|
+
onCancel = undefined;
|
|
1324
|
+
}
|
|
1325
|
+
return new Promise((res, rej) => {
|
|
1326
|
+
onCancel = rej;
|
|
1327
|
+
timer = setTimeout(() => {
|
|
1328
|
+
originalFunction(value)
|
|
1329
|
+
.then(values => {
|
|
1330
|
+
res(values);
|
|
1331
|
+
})
|
|
1332
|
+
.catch(err => {
|
|
1333
|
+
rej(err);
|
|
1334
|
+
})
|
|
1335
|
+
.finally(() => {
|
|
1336
|
+
clearTimeout(timer);
|
|
1337
|
+
});
|
|
1338
|
+
}, trailingTimeoutMs);
|
|
1339
|
+
});
|
|
1340
|
+
};
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
/** Extracted logic around autocomplete functionality for Autocomplete.tsx that supports Entity (id/name) mapping. */
|
|
1344
|
+
class AutocompleteEntityController {
|
|
1345
|
+
constructor(getOptions, config) {
|
|
1346
|
+
this._options = [];
|
|
1347
|
+
const getStringOptions = async (value) => {
|
|
1348
|
+
this._options = await getOptions(value);
|
|
1349
|
+
return this._options.map(o => o.name);
|
|
1350
|
+
};
|
|
1351
|
+
this._ctrl = new AutocompleteController(getStringOptions, config);
|
|
1352
|
+
}
|
|
1353
|
+
get entity() {
|
|
1354
|
+
return this._pickedEntity;
|
|
1355
|
+
}
|
|
1356
|
+
get entities() {
|
|
1357
|
+
return this._options;
|
|
1358
|
+
}
|
|
1359
|
+
get value() {
|
|
1360
|
+
return this._ctrl.value;
|
|
1361
|
+
}
|
|
1362
|
+
get options() {
|
|
1363
|
+
return this._options.map(o => o.name);
|
|
1364
|
+
}
|
|
1365
|
+
async onChange(newValue) {
|
|
1366
|
+
const clearEntity = newValue !== this._ctrl.value;
|
|
1367
|
+
await this._ctrl.onChange(newValue);
|
|
1368
|
+
if (clearEntity) {
|
|
1369
|
+
this._pickedEntity = undefined;
|
|
1370
|
+
}
|
|
1371
|
+
this.trySyncCtrlOptions();
|
|
1372
|
+
}
|
|
1373
|
+
onPick(newValue) {
|
|
1374
|
+
this._ctrl.onPick(newValue);
|
|
1375
|
+
this._pickedEntity = this._options.find(o => o.name === this._ctrl.value);
|
|
1376
|
+
this.trySyncCtrlOptions();
|
|
1377
|
+
}
|
|
1378
|
+
trySyncCtrlOptions() {
|
|
1379
|
+
if (!this._ctrl.options.length) {
|
|
1380
|
+
this._options = [];
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1263
1385
|
/** Returns a UID. Use this instead of a direct call to a library. */
|
|
1264
1386
|
function createUid() {
|
|
1265
1387
|
return lodash.uniqueId();
|
|
@@ -2978,108 +3100,6 @@ const Label = (props) => {
|
|
|
2978
3100
|
return (React__namespace.createElement("label", Object.assign({}, labelProps, { htmlFor: htmlFor, className: css.cx('label', labelStyles, outerClass) }), content));
|
|
2979
3101
|
};
|
|
2980
3102
|
|
|
2981
|
-
const Nav = (props) => {
|
|
2982
|
-
var _a, _b, _c, _d;
|
|
2983
|
-
const nav = React__namespace.useRef(null);
|
|
2984
|
-
const theme = useThemeSafely();
|
|
2985
|
-
const navWidth = (_a = props.navWidth) !== null && _a !== void 0 ? _a : theme.layout.navWidth;
|
|
2986
|
-
const totalNavOffset = `calc(${navWidth} + 20px)`;
|
|
2987
|
-
const backdrop = useBackdropContext();
|
|
2988
|
-
const log = useLogger(`Nav ${(_b = props.id) !== null && _b !== void 0 ? _b : '?'}`, (_c = props.__debug) !== null && _c !== void 0 ? _c : false);
|
|
2989
|
-
const slideMs = (_d = props.slideMs) !== null && _d !== void 0 ? _d : theme.timings.nav.slideMs;
|
|
2990
|
-
const slideRight = css.keyframes `
|
|
2991
|
-
0% {
|
|
2992
|
-
transform: translateX(0);
|
|
2993
|
-
}
|
|
2994
|
-
|
|
2995
|
-
100% {
|
|
2996
|
-
transform: translateX(${totalNavOffset});
|
|
2997
|
-
}
|
|
2998
|
-
`;
|
|
2999
|
-
const slideLeft = css.keyframes `
|
|
3000
|
-
0% {
|
|
3001
|
-
transform: translateX(${totalNavOffset});
|
|
3002
|
-
}
|
|
3003
|
-
|
|
3004
|
-
100% {
|
|
3005
|
-
transform: translateX(0px);
|
|
3006
|
-
}
|
|
3007
|
-
`;
|
|
3008
|
-
const classNavShowing = css.css `
|
|
3009
|
-
animation: ${slideRight} ${slideMs}ms cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
3010
|
-
`;
|
|
3011
|
-
const classNavNotShowing = css.css `
|
|
3012
|
-
animation: ${slideLeft} ${slideMs}ms cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
3013
|
-
`;
|
|
3014
|
-
const zIndex = theme.zIndexes.nav;
|
|
3015
|
-
// the padding-top here is to offset the navs' content from the header. the shadow creeps over it.
|
|
3016
|
-
const navStyles = css.css `
|
|
3017
|
-
label: Nav;
|
|
3018
|
-
position: fixed;
|
|
3019
|
-
top: 0;
|
|
3020
|
-
left: calc(${totalNavOffset} * -1);
|
|
3021
|
-
bottom: 0;
|
|
3022
|
-
background-color: ${theme.colors.nav};
|
|
3023
|
-
color: ${theme.colors.navFont};
|
|
3024
|
-
width: ${navWidth};
|
|
3025
|
-
min-width: ${navWidth};
|
|
3026
|
-
box-shadow: 4px 2px 12px 6px rgba(0, 0, 0, 0.2);
|
|
3027
|
-
z-index: ${zIndex};
|
|
3028
|
-
overflow-y: auto;
|
|
3029
|
-
.omniLink, .omniLink:active, .omniLink:focus, .omniLink:visited {
|
|
3030
|
-
color: ${theme.colors.navFont};
|
|
3031
|
-
}
|
|
3032
|
-
padding-top:0;
|
|
3033
|
-
`;
|
|
3034
|
-
React__namespace.useEffect(() => {
|
|
3035
|
-
if (!backdrop.showing) {
|
|
3036
|
-
props.toggle(false);
|
|
3037
|
-
}
|
|
3038
|
-
}, [backdrop.showing]);
|
|
3039
|
-
useBooleanChanged((current, previous) => {
|
|
3040
|
-
var _a;
|
|
3041
|
-
log('show changed', `${previous !== null && previous !== void 0 ? previous : 'undefined'} > ${current}`);
|
|
3042
|
-
backdrop.setShow(current, { key: (_a = props.id) !== null && _a !== void 0 ? _a : 'Nav', zIndex });
|
|
3043
|
-
if (!props.show && props.onCloseFocusId) {
|
|
3044
|
-
const focusId = props.onCloseFocusId;
|
|
3045
|
-
setTimeout(() => {
|
|
3046
|
-
var _a;
|
|
3047
|
-
(_a = document.getElementById(focusId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3048
|
-
}, 0);
|
|
3049
|
-
}
|
|
3050
|
-
}, props.show);
|
|
3051
|
-
React__namespace.useLayoutEffect(() => {
|
|
3052
|
-
if (nav && nav.current) {
|
|
3053
|
-
if (props.show) {
|
|
3054
|
-
if (!nav.current.classList.contains(classNavShowing)) {
|
|
3055
|
-
nav.current.classList.add(classNavShowing);
|
|
3056
|
-
setTimeout(() => {
|
|
3057
|
-
var _a;
|
|
3058
|
-
(_a = document.getElementById(props.focusContentId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3059
|
-
}, slideMs + 1);
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
else {
|
|
3063
|
-
if (nav.current.classList.contains(classNavShowing)) {
|
|
3064
|
-
nav.current.classList.remove(classNavShowing);
|
|
3065
|
-
nav.current.classList.add(classNavNotShowing);
|
|
3066
|
-
setTimeout(() => {
|
|
3067
|
-
if (nav && nav.current) {
|
|
3068
|
-
nav.current.classList.remove(classNavNotShowing);
|
|
3069
|
-
}
|
|
3070
|
-
}, slideMs);
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
});
|
|
3075
|
-
return (React__namespace.createElement("nav", { role: "dialog", "aria-modal": "true", "aria-label": props.ariaLabel, ref: nav, className: css.cx('nav', navStyles, props.className), onKeyDown: e => {
|
|
3076
|
-
if (e.code === 'Escape') {
|
|
3077
|
-
props.toggle(false);
|
|
3078
|
-
}
|
|
3079
|
-
} },
|
|
3080
|
-
React__namespace.createElement(TabLocker, { className: css.css({ height: '100%' }) }, props.children)));
|
|
3081
|
-
};
|
|
3082
|
-
|
|
3083
3103
|
const LinkContent = (props) => {
|
|
3084
3104
|
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
3085
3105
|
React__namespace.createElement("span", null,
|
|
@@ -3337,6 +3357,29 @@ const generateLinkStyles = (props, theme) => {
|
|
|
3337
3357
|
return linkStyles;
|
|
3338
3358
|
};
|
|
3339
3359
|
|
|
3360
|
+
const Link = (props) => {
|
|
3361
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3362
|
+
const { rightIcon, leftIcon, block, iconBlock, variant, round, small, colorOverride, children, disabled, ref, waiting } = props, linkProps = __rest(props, ["rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "disabled", "ref", "waiting"]);
|
|
3363
|
+
const theme = useThemeSafely();
|
|
3364
|
+
const linkStyles = generateLinkStyles(props, theme);
|
|
3365
|
+
const mainClassName = css.cx('link', linkStyles, props.className);
|
|
3366
|
+
if (variant === 'text') {
|
|
3367
|
+
return React__namespace.createElement(Text, { className: mainClassName, tag: "div" }, props.children);
|
|
3368
|
+
}
|
|
3369
|
+
const isDisabled = props.disabled || props.waiting;
|
|
3370
|
+
return (React__namespace.createElement("a", Object.assign({}, linkProps, { tabIndex: disabled ? -1 : undefined, target: props.target, className: mainClassName, onClick: e => {
|
|
3371
|
+
var _a;
|
|
3372
|
+
if (isDisabled) {
|
|
3373
|
+
e.stopPropagation();
|
|
3374
|
+
e.preventDefault();
|
|
3375
|
+
}
|
|
3376
|
+
else {
|
|
3377
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
3378
|
+
}
|
|
3379
|
+
} }),
|
|
3380
|
+
React__namespace.createElement(LinkContent, Object.assign({}, props))));
|
|
3381
|
+
};
|
|
3382
|
+
|
|
3340
3383
|
const OmniLink = (props) => {
|
|
3341
3384
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3342
3385
|
const { noRouter, rightIcon, leftIcon, block, iconBlock, variant, round, small, colorOverride, children, ref, waiting } = props, linkProps = __rest(props, ["noRouter", "rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "ref", "waiting"]);
|
|
@@ -3363,17 +3406,119 @@ const OmniLink = (props) => {
|
|
|
3363
3406
|
} }), content));
|
|
3364
3407
|
};
|
|
3365
3408
|
|
|
3366
|
-
const
|
|
3367
|
-
|
|
3368
|
-
const
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3409
|
+
const Nav = (props) => {
|
|
3410
|
+
var _a, _b, _c, _d;
|
|
3411
|
+
const nav = React__namespace.useRef(null);
|
|
3412
|
+
const theme = useThemeSafely();
|
|
3413
|
+
const navWidth = (_a = props.navWidth) !== null && _a !== void 0 ? _a : theme.layout.navWidth;
|
|
3414
|
+
const totalNavOffset = `calc(${navWidth} + 20px)`;
|
|
3415
|
+
const backdrop = useBackdropContext();
|
|
3416
|
+
const log = useLogger(`Nav ${(_b = props.id) !== null && _b !== void 0 ? _b : '?'}`, (_c = props.__debug) !== null && _c !== void 0 ? _c : false);
|
|
3417
|
+
const slideMs = (_d = props.slideMs) !== null && _d !== void 0 ? _d : theme.timings.nav.slideMs;
|
|
3418
|
+
const slideRight = css.keyframes `
|
|
3419
|
+
0% {
|
|
3420
|
+
transform: translateX(0);
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
100% {
|
|
3424
|
+
transform: translateX(${totalNavOffset});
|
|
3425
|
+
}
|
|
3426
|
+
`;
|
|
3427
|
+
const slideLeft = css.keyframes `
|
|
3428
|
+
0% {
|
|
3429
|
+
transform: translateX(${totalNavOffset});
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
100% {
|
|
3433
|
+
transform: translateX(0px);
|
|
3434
|
+
}
|
|
3435
|
+
`;
|
|
3436
|
+
const classNavShowing = css.css `
|
|
3437
|
+
animation: ${slideRight} ${slideMs}ms cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
3438
|
+
`;
|
|
3439
|
+
const classNavNotShowing = css.css `
|
|
3440
|
+
animation: ${slideLeft} ${slideMs}ms cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
3441
|
+
`;
|
|
3442
|
+
const zIndex = theme.zIndexes.nav;
|
|
3443
|
+
// the padding-top here is to offset the navs' content from the header. the shadow creeps over it.
|
|
3444
|
+
const navStyles = css.css `
|
|
3445
|
+
label: Nav;
|
|
3446
|
+
position: fixed;
|
|
3447
|
+
top: 0;
|
|
3448
|
+
left: calc(${totalNavOffset} * -1);
|
|
3449
|
+
bottom: 0;
|
|
3450
|
+
background-color: ${theme.colors.nav};
|
|
3451
|
+
color: ${theme.colors.navFont};
|
|
3452
|
+
width: ${navWidth};
|
|
3453
|
+
min-width: ${navWidth};
|
|
3454
|
+
box-shadow: 4px 2px 12px 6px rgba(0, 0, 0, 0.2);
|
|
3455
|
+
z-index: ${zIndex};
|
|
3456
|
+
overflow-y: auto;
|
|
3457
|
+
.omniLink, .omniLink:active, .omniLink:focus, .omniLink:visited {
|
|
3458
|
+
color: ${theme.colors.navFont};
|
|
3459
|
+
}
|
|
3460
|
+
padding-top:0;
|
|
3461
|
+
`;
|
|
3462
|
+
React__namespace.useEffect(() => {
|
|
3463
|
+
if (!backdrop.showing) {
|
|
3464
|
+
props.toggle(false);
|
|
3465
|
+
}
|
|
3466
|
+
}, [backdrop.showing]);
|
|
3467
|
+
useBooleanChanged((current, previous) => {
|
|
3468
|
+
var _a;
|
|
3469
|
+
log('show changed', `${previous !== null && previous !== void 0 ? previous : 'undefined'} > ${current}`);
|
|
3470
|
+
backdrop.setShow(current, { key: (_a = props.id) !== null && _a !== void 0 ? _a : 'Nav', zIndex });
|
|
3471
|
+
if (!props.show && props.onCloseFocusId) {
|
|
3472
|
+
const focusId = props.onCloseFocusId;
|
|
3473
|
+
setTimeout(() => {
|
|
3474
|
+
var _a;
|
|
3475
|
+
(_a = document.getElementById(focusId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3476
|
+
}, 0);
|
|
3477
|
+
}
|
|
3478
|
+
}, props.show);
|
|
3479
|
+
React__namespace.useLayoutEffect(() => {
|
|
3480
|
+
if (nav && nav.current) {
|
|
3481
|
+
if (props.show) {
|
|
3482
|
+
if (!nav.current.classList.contains(classNavShowing)) {
|
|
3483
|
+
nav.current.classList.add(classNavShowing);
|
|
3484
|
+
setTimeout(() => {
|
|
3485
|
+
var _a;
|
|
3486
|
+
(_a = document.getElementById(props.focusContentId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3487
|
+
}, slideMs + 1);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
else {
|
|
3491
|
+
if (nav.current.classList.contains(classNavShowing)) {
|
|
3492
|
+
nav.current.classList.remove(classNavShowing);
|
|
3493
|
+
nav.current.classList.add(classNavNotShowing);
|
|
3494
|
+
setTimeout(() => {
|
|
3495
|
+
if (nav && nav.current) {
|
|
3496
|
+
nav.current.classList.remove(classNavNotShowing);
|
|
3497
|
+
}
|
|
3498
|
+
}, slideMs);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
});
|
|
3503
|
+
return (React__namespace.createElement("nav", { role: "dialog", "aria-modal": "true", "aria-label": props.ariaLabel, ref: nav, className: css.cx('nav', navStyles, props.className), onKeyDown: e => {
|
|
3504
|
+
if (e.code === 'Escape') {
|
|
3505
|
+
props.toggle(false);
|
|
3506
|
+
}
|
|
3507
|
+
} },
|
|
3508
|
+
React__namespace.createElement(TabLocker, { className: css.css({ height: '100%' }) }, props.children)));
|
|
3509
|
+
};
|
|
3510
|
+
|
|
3511
|
+
const roundPxPadding = '4px';
|
|
3512
|
+
const Picker = (props) => {
|
|
3513
|
+
const { value, options, onValueChange, readOnly, round, controlAlign, wrapperClassName, iconClassName, error, optionClassName } = props, selectProps = __rest(props
|
|
3514
|
+
// if we put numbers in, we expect them out
|
|
3515
|
+
, ["value", "options", "onValueChange", "readOnly", "round", "controlAlign", "wrapperClassName", "iconClassName", "error", "optionClassName"]);
|
|
3516
|
+
// if we put numbers in, we expect them out
|
|
3517
|
+
let isNumber = false;
|
|
3518
|
+
if (options && options.length) {
|
|
3519
|
+
const testOption = options[0];
|
|
3520
|
+
if (typeof testOption === 'object') {
|
|
3521
|
+
isNumber = typeof testOption.id === 'number';
|
|
3377
3522
|
}
|
|
3378
3523
|
else {
|
|
3379
3524
|
isNumber = typeof testOption === 'number';
|
|
@@ -3381,6 +3526,7 @@ const Picker = (props) => {
|
|
|
3381
3526
|
}
|
|
3382
3527
|
const theme = useThemeSafely();
|
|
3383
3528
|
const selectStyles = css.css({
|
|
3529
|
+
label: 'Picker',
|
|
3384
3530
|
// fix the arrow so browser all look the same
|
|
3385
3531
|
appearance: 'none',
|
|
3386
3532
|
paddingLeft: theme.controls.padding,
|
|
@@ -3424,8 +3570,7 @@ const Picker = (props) => {
|
|
|
3424
3570
|
const select = (React__namespace.createElement("select", Object.assign({}, selectProps, { tabIndex: readOnly ? -1 : selectProps.tabIndex, className: css.cx('picker', selectStyles, props.className), value: value, onKeyDown: e => {
|
|
3425
3571
|
var _a;
|
|
3426
3572
|
if (readOnly) {
|
|
3427
|
-
if (e.
|
|
3428
|
-
//TAB
|
|
3573
|
+
if (e.code === 'Tab') {
|
|
3429
3574
|
return;
|
|
3430
3575
|
}
|
|
3431
3576
|
e.preventDefault();
|
|
@@ -3466,7 +3611,7 @@ const Picker = (props) => {
|
|
|
3466
3611
|
val = o;
|
|
3467
3612
|
label = o;
|
|
3468
3613
|
}
|
|
3469
|
-
return React__namespace.createElement("option", { key: val, value: val }, label);
|
|
3614
|
+
return React__namespace.createElement("option", { key: val, value: val, className: optionClassName }, label);
|
|
3470
3615
|
})));
|
|
3471
3616
|
return (React__namespace.createElement("span", { className: css.cx(css.css({
|
|
3472
3617
|
label: 'PickerWrapper',
|
|
@@ -3942,6 +4087,118 @@ class ItemPager {
|
|
|
3942
4087
|
}
|
|
3943
4088
|
}
|
|
3944
4089
|
|
|
4090
|
+
const MultiPicker = (props) => {
|
|
4091
|
+
const { value: values, options, onValueChange, readOnly, controlAlign, wrapperClassName, error, optionClassName } = props, selectProps = __rest(props
|
|
4092
|
+
// if we put numbers in, we expect them out
|
|
4093
|
+
, ["value", "options", "onValueChange", "readOnly", "controlAlign", "wrapperClassName", "error", "optionClassName"]);
|
|
4094
|
+
// if we put numbers in, we expect them out
|
|
4095
|
+
let isNumber = false;
|
|
4096
|
+
if (options && options.length) {
|
|
4097
|
+
const testOption = options[0];
|
|
4098
|
+
if (typeof testOption === 'object') {
|
|
4099
|
+
isNumber = typeof testOption.id === 'number';
|
|
4100
|
+
}
|
|
4101
|
+
else {
|
|
4102
|
+
isNumber = typeof testOption === 'number';
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
const theme = useThemeSafely();
|
|
4106
|
+
const selectStyles = css.css({
|
|
4107
|
+
label: 'MultiPicker',
|
|
4108
|
+
padding: theme.controls.padding,
|
|
4109
|
+
minHeight: theme.controls.height,
|
|
4110
|
+
backgroundColor: theme.colors.bg,
|
|
4111
|
+
color: theme.colors.font,
|
|
4112
|
+
fontSize: theme.controls.fontSize,
|
|
4113
|
+
width: '100%',
|
|
4114
|
+
border: theme.controls.border,
|
|
4115
|
+
borderRadius: theme.controls.borderRadius || 0, /* safari fix */
|
|
4116
|
+
transition: theme.controls.transition,
|
|
4117
|
+
'&:disabled': {
|
|
4118
|
+
color: theme.colors.font,
|
|
4119
|
+
opacity: 1,
|
|
4120
|
+
backgroundColor: theme.colors.disabled,
|
|
4121
|
+
cursor: 'not-allowed'
|
|
4122
|
+
},
|
|
4123
|
+
'&:focus': {
|
|
4124
|
+
outline: 'none',
|
|
4125
|
+
boxShadow: theme.controls.focusOutlineShadow
|
|
4126
|
+
}
|
|
4127
|
+
}, error && {
|
|
4128
|
+
borderColor: theme.colors.required,
|
|
4129
|
+
':focus': {
|
|
4130
|
+
boxShadow: theme.controls.focusOutlineRequiredShadow
|
|
4131
|
+
}
|
|
4132
|
+
}, readOnly && {
|
|
4133
|
+
backgroundColor: 'transparent !important',
|
|
4134
|
+
backgroundImage: 'unset',
|
|
4135
|
+
border: 'none',
|
|
4136
|
+
'&:focus': {
|
|
4137
|
+
outline: 'none',
|
|
4138
|
+
boxShadow: 'none'
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
4141
|
+
const select = (React__namespace.createElement("select", Object.assign({}, selectProps, { multiple: true, tabIndex: readOnly ? -1 : selectProps.tabIndex, className: css.cx(selectStyles, props.className), value: values.map(v => v.toString()), onKeyDown: e => {
|
|
4142
|
+
var _a;
|
|
4143
|
+
if (readOnly) {
|
|
4144
|
+
if (e.code === 'Tab') {
|
|
4145
|
+
return;
|
|
4146
|
+
}
|
|
4147
|
+
e.preventDefault();
|
|
4148
|
+
e.stopPropagation();
|
|
4149
|
+
}
|
|
4150
|
+
else {
|
|
4151
|
+
(_a = selectProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(selectProps, e);
|
|
4152
|
+
}
|
|
4153
|
+
}, onMouseDown: e => {
|
|
4154
|
+
var _a;
|
|
4155
|
+
if (readOnly) {
|
|
4156
|
+
e.preventDefault();
|
|
4157
|
+
e.stopPropagation();
|
|
4158
|
+
}
|
|
4159
|
+
else {
|
|
4160
|
+
(_a = selectProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(selectProps, e);
|
|
4161
|
+
}
|
|
4162
|
+
}, onChange: e => {
|
|
4163
|
+
var _a;
|
|
4164
|
+
const values = Array.from(e.target.selectedOptions).map(o => {
|
|
4165
|
+
let val = o.value;
|
|
4166
|
+
if (isNumber) {
|
|
4167
|
+
val = parseInt(val, 10);
|
|
4168
|
+
if (isNaN(val)) {
|
|
4169
|
+
val = '';
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
return val;
|
|
4173
|
+
});
|
|
4174
|
+
onValueChange(values);
|
|
4175
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
4176
|
+
} }), (options || []).map(o => {
|
|
4177
|
+
var _a;
|
|
4178
|
+
let val;
|
|
4179
|
+
let label;
|
|
4180
|
+
if (typeof o === 'object') {
|
|
4181
|
+
val = o.id;
|
|
4182
|
+
label = (_a = o.name) !== null && _a !== void 0 ? _a : o.id;
|
|
4183
|
+
}
|
|
4184
|
+
else {
|
|
4185
|
+
val = o;
|
|
4186
|
+
label = o;
|
|
4187
|
+
}
|
|
4188
|
+
return React__namespace.createElement("option", { key: val, value: val, className: optionClassName }, label);
|
|
4189
|
+
})));
|
|
4190
|
+
return (React__namespace.createElement("span", { className: css.cx(css.css({
|
|
4191
|
+
label: 'MultiPickerWrapper',
|
|
4192
|
+
position: 'relative',
|
|
4193
|
+
display: 'inline-block',
|
|
4194
|
+
width: '100%',
|
|
4195
|
+
}), wrapperClassName) },
|
|
4196
|
+
React__namespace.createElement("div", { className: css.css({
|
|
4197
|
+
position: 'relative'
|
|
4198
|
+
}) }, select),
|
|
4199
|
+
(error || controlAlign) && React__namespace.createElement(InputErrorDisplay, { error: error })));
|
|
4200
|
+
};
|
|
4201
|
+
|
|
3945
4202
|
const ProgressBar = (props) => {
|
|
3946
4203
|
var _a;
|
|
3947
4204
|
const bar = React__namespace.useRef(null);
|
|
@@ -4070,6 +4327,29 @@ const SearchBox = React__namespace.forwardRef((props, ref) => {
|
|
|
4070
4327
|
return (React__namespace.createElement("div", { className: searchBoxWrapperStyles }, input));
|
|
4071
4328
|
});
|
|
4072
4329
|
|
|
4330
|
+
/** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
|
|
4331
|
+
const enumToEntities = (enumObj) => {
|
|
4332
|
+
const entities = [];
|
|
4333
|
+
for (const key in enumObj) {
|
|
4334
|
+
if (isNaN(parseInt(key, 10))) {
|
|
4335
|
+
entities.push({
|
|
4336
|
+
id: enumObj[key],
|
|
4337
|
+
name: key
|
|
4338
|
+
});
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
return entities;
|
|
4342
|
+
};
|
|
4343
|
+
|
|
4344
|
+
/** Displays the value in American dollars. */
|
|
4345
|
+
const getCurrencyDisplay = (value, isCents, denomination = '$') => {
|
|
4346
|
+
let actualValue = value || 0;
|
|
4347
|
+
if (isCents) {
|
|
4348
|
+
actualValue /= 100;
|
|
4349
|
+
}
|
|
4350
|
+
return `${denomination}${actualValue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
4351
|
+
};
|
|
4352
|
+
|
|
4073
4353
|
const GlobalStyles = () => {
|
|
4074
4354
|
const theme = useThemeSafely();
|
|
4075
4355
|
css.injectGlobal({
|
|
@@ -4098,699 +4378,37 @@ const GlobalStyles = () => {
|
|
|
4098
4378
|
return null;
|
|
4099
4379
|
};
|
|
4100
4380
|
|
|
4101
|
-
|
|
4102
|
-
From https://fireship.io/snippets/use-media-query-hook/.
|
|
4103
|
-
Tried using https://www.npmjs.com/package/react-media, but it cause Webpack build issues.
|
|
4104
|
-
*/
|
|
4105
|
-
/** React wrapper around window resizing and window.matchMedia.
|
|
4106
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
|
|
4107
|
-
*/
|
|
4108
|
-
const useMediaQuery = (query) => {
|
|
4109
|
-
const [matches, setMatches] = React.useState(window.matchMedia(query).matches);
|
|
4110
|
-
React.useEffect(() => {
|
|
4111
|
-
const media = window.matchMedia(query);
|
|
4112
|
-
if (media.matches !== matches) {
|
|
4113
|
-
setMatches(media.matches);
|
|
4114
|
-
}
|
|
4115
|
-
const listener = () => setMatches(media.matches);
|
|
4116
|
-
window.addEventListener("resize", listener);
|
|
4117
|
-
return () => window.removeEventListener("resize", listener);
|
|
4118
|
-
}, [matches, query]);
|
|
4119
|
-
return matches;
|
|
4120
|
-
};
|
|
4381
|
+
var decimal=["decimal","décimale"];var place=["lugar","lieu"];var places=["lugares","lieux"];var file=["archivo","fichier"];var selected=["seleccionado","choisi"];var Upload=["Subir","Télécharger"];var Clear=["Cerrar","Fermer"];var Showing=["Mostrando","Affichage de"];var of=["de","sur"];var results=["resultados","résultats"];var Page=["Página","Page"];var Limit=["Límite","Limite"];var Sort=["Ordenar","Trier"];var January=["Enero","Janvier"];var February=["Febrero","Février"];var March=["Marzo","Mars"];var April=["Abril","Avril"];var May=["Mayo","Mai"];var June=["Junio","Juin"];var July=["Julio","Juillet"];var August=["Agosto","Août"];var September=["Septiembre","Septembre"];var October=["Octubre","Octobre"];var November=["Noviembre","Novembre"];var December=["Diciembre","Décembre"];var Sun=["Dom","Dim"];var Mon=["Lun","Lun"];var Tue=["Mar","Mar"];var Wed=["Mié","Mer"];var Thu=["Jue","Jeu"];var Fri=["Vie","Ven"];var Sat=["Sáb","Sam"];var OK=["Aceptar","Accepter"];var Cancel=["Cancelar","Annuler"];var strings = {"Required.":["Requerido.","Requis."],"Must be at least":["Debe ser al menos","Doit être au moins"],"characters in length.":["caracteres de longitud.","caractères de longueur."],"Must be an integer.":["Debe ser un número entero.","Doit être un entier."],"Limited to":["Limitado a","Limité à"],decimal:decimal,place:place,places:places,"Must be greater than or equal to":["Debe ser mayor o igual a","Doit être supérieur ou égal à"],"Must be less than or equal to":["Debe ser menor o igual a","Doit être inférieur ou égal à"],"Invalid email.":["Correo electrónico no válido.","Email invalide."],"Invalid URL.":["URL no válida.","URL non valide."],"Click or drag and drop files.":["Haga clic o arrastre y suelte archivos.","Cliquez ou faites glisser et déposez les fichiers."],file:file,selected:selected,"Upload failed.":["Error en la carga.","Le téléchargement a échoué."],Upload:Upload,"Upload successful.":["Carga exitosa","Téléchargement réussi."],"Invalid files":["Archivos no válidos","Fichiers invalides"],"Max file size exceeded":["Se ha excedido el tamaño máximo de archivo","La taille maximale du fichier a été dépassée"],"Error":["Error","Erreur"],Clear:Clear,Showing:Showing,of:of,results:results,"No Results":["No Hay Resultados","Aucun Résultat"],Page:Page,Limit:Limit,Sort:Sort,January:January,February:February,March:March,April:April,May:May,June:June,July:July,August:August,September:September,October:October,November:November,December:December,Sun:Sun,Mon:Mon,Tue:Tue,Wed:Wed,Thu:Thu,Fri:Fri,Sat:Sat,OK:OK,Cancel:Cancel,"Copied!":["¡Copiado!","Copié!"],"Copy to clipboard":["Copiar al portapapeles","Copier dans le presse-papier"]};
|
|
4121
4382
|
|
|
4122
|
-
const
|
|
4383
|
+
const LocalizationProvider = (p) => {
|
|
4123
4384
|
var _a;
|
|
4124
|
-
const
|
|
4125
|
-
const
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
const [, forceUpdate] = React.useState(Date.now());
|
|
4132
|
-
React.useEffect(() => {
|
|
4133
|
-
if (p.value !== currentValue.current) {
|
|
4134
|
-
currentValue.current = p.value;
|
|
4135
|
-
forceUpdate(Date.now());
|
|
4136
|
-
}
|
|
4137
|
-
}, [p.value]);
|
|
4138
|
-
return (React.createElement("div", { ref: sliderContainer, className: css.cx(css.css({
|
|
4139
|
-
label: 'Slider',
|
|
4140
|
-
width: '100%',
|
|
4141
|
-
height,
|
|
4142
|
-
}), p.className) },
|
|
4143
|
-
React.createElement(ReactSlider, { ariaLabel: p.ariaLabel, step: p.step, min: p.min, max: p.max, value: p.value, onAfterChange: (value) => {
|
|
4144
|
-
p.onChange(value);
|
|
4145
|
-
}, onChange: p.onUpdate || p.showValue ? (value) => {
|
|
4146
|
-
var _a;
|
|
4147
|
-
currentValue.current = value;
|
|
4148
|
-
(_a = p.onUpdate) === null || _a === void 0 ? void 0 : _a.call(p, value);
|
|
4149
|
-
} : undefined, renderTrack: (props) => {
|
|
4150
|
-
const { className } = props, rest = __rest(props, ["className"]);
|
|
4151
|
-
return (React.createElement("div", Object.assign({ className: css.cx(className, p.trackClassName, css.css({
|
|
4152
|
-
display: 'flex',
|
|
4153
|
-
alignItems: 'center',
|
|
4154
|
-
height: sliderHandleSize
|
|
4155
|
-
})) }, rest),
|
|
4156
|
-
React.createElement("div", { className: css.css({
|
|
4157
|
-
backgroundColor: theme.colors.secondary,
|
|
4158
|
-
height: `calc(${sliderHandleSize} / 4)`,
|
|
4159
|
-
borderRadius: theme.controls.roundRadius,
|
|
4160
|
-
width: '100%'
|
|
4161
|
-
}, p.innerTrackClassName && rest.key === 'track-1' && Array.isArray(p.value) ? p.innerTrackClassName : undefined) })));
|
|
4162
|
-
}, renderThumb: (props, state) => {
|
|
4163
|
-
var _a;
|
|
4164
|
-
const { className } = props, rest = __rest(props, ["className"]);
|
|
4165
|
-
let specificThumbStyles;
|
|
4166
|
-
if (p.handle1ClassName && props.key === 'thumb-0') {
|
|
4167
|
-
specificThumbStyles = p.handle1ClassName;
|
|
4168
|
-
}
|
|
4169
|
-
else if (p.handle2ClassName && props.key === 'thumb-1') {
|
|
4170
|
-
specificThumbStyles = p.handle2ClassName;
|
|
4171
|
-
}
|
|
4172
|
-
return (React.createElement("div", Object.assign({ className: css.cx(className, css.css({
|
|
4173
|
-
borderRadius: theme.controls.roundRadius,
|
|
4174
|
-
backgroundColor: 'white',
|
|
4175
|
-
border: theme.controls.border,
|
|
4176
|
-
cursor: 'grab',
|
|
4177
|
-
boxShadow: theme.controls.buttonBoxShadow,
|
|
4178
|
-
transition: theme.controls.transition,
|
|
4179
|
-
'&:focus': {
|
|
4180
|
-
outline: 'none',
|
|
4181
|
-
boxShadow: theme.controls.focusOutlineShadow
|
|
4182
|
-
},
|
|
4183
|
-
'&:active': {
|
|
4184
|
-
boxShadow: 'none',
|
|
4185
|
-
cursor: 'grabbing'
|
|
4186
|
-
},
|
|
4187
|
-
'&:hover': {
|
|
4188
|
-
filter: theme.controls.hoverBrightness
|
|
4189
|
-
}
|
|
4190
|
-
}), specificThumbStyles, p.handleClassName, css.css({
|
|
4191
|
-
width: sliderHandleSize,
|
|
4192
|
-
height: sliderHandleSize,
|
|
4193
|
-
})) }, rest, { tabIndex: (_a = p.tabIndex) !== null && _a !== void 0 ? _a : 0 }), p.showValue && (React.createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
4194
|
-
} })));
|
|
4195
|
-
};
|
|
4196
|
-
const rectsCollideX = (r1, r2) => {
|
|
4197
|
-
if (r1.left >= r2.left && r1.left <= r2.right) {
|
|
4198
|
-
return true;
|
|
4199
|
-
}
|
|
4200
|
-
if (r1.right >= r2.left && r1.right <= r2.right) {
|
|
4201
|
-
return true;
|
|
4202
|
-
}
|
|
4203
|
-
return false;
|
|
4204
|
-
};
|
|
4205
|
-
const HandleText = (p) => {
|
|
4206
|
-
var _a, _b, _c;
|
|
4207
|
-
const displayValue = (_b = (_a = p.renderValue) === null || _a === void 0 ? void 0 : _a.call(p, p.value)) !== null && _b !== void 0 ? _b : p.value;
|
|
4208
|
-
const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c : p.sliderHandleSize;
|
|
4209
|
-
const renderValueLeft = React.useMemo(() => {
|
|
4210
|
-
return `calc(${renderValueWidth} * 0.5 * -1 + (${p.sliderHandleSize} * 0.5))`;
|
|
4211
|
-
}, [p.renderValueWidth, p.sliderHandleSize]);
|
|
4212
|
-
const [flipText, setFlipText] = React.useState(false);
|
|
4213
|
-
const offset = '2px';
|
|
4214
|
-
React.useEffect(() => {
|
|
4215
|
-
// this needs to fire on every render due to the other handle also moving.
|
|
4216
|
-
var _a, _b;
|
|
4217
|
-
if (p.index === 1) {
|
|
4218
|
-
// only do this for the max/right-most handle
|
|
4219
|
-
const [r1, r2] = Array.from((_b = (_a = p.parentElement) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.slider-handle').values()) !== null && _b !== void 0 ? _b : []).map(e => e.getBoundingClientRect());
|
|
4220
|
-
if (r1 && r2) {
|
|
4221
|
-
setFlipText(rectsCollideX(r1, r2));
|
|
4222
|
-
}
|
|
4223
|
-
}
|
|
4224
|
-
});
|
|
4225
|
-
return (React.createElement(Text, { ellipsis: true, className: css.cx('slider-handle', css.css({
|
|
4226
|
-
width: renderValueWidth,
|
|
4227
|
-
left: renderValueLeft,
|
|
4228
|
-
top: flipText ? undefined : `calc(${p.sliderHandleSize} + ${offset})`,
|
|
4229
|
-
bottom: flipText ? `calc(${p.sliderHandleSize} + ${offset})` : undefined,
|
|
4230
|
-
position: 'absolute',
|
|
4231
|
-
overflow: 'hidden',
|
|
4232
|
-
}), p.className), tag: "div", align: "center" }, displayValue));
|
|
4233
|
-
};
|
|
4234
|
-
|
|
4235
|
-
const TabHeader = (p) => {
|
|
4236
|
-
var _a, _b;
|
|
4237
|
-
const [tabIndex, setTabIndex] = React__namespace.useState((_a = p.startingIndex) !== null && _a !== void 0 ? _a : 0);
|
|
4238
|
-
const [tabsChanging, setTabsChanging] = React__namespace.useState(false);
|
|
4239
|
-
const theme = useThemeSafely();
|
|
4240
|
-
const variant = (_b = p.variant) !== null && _b !== void 0 ? _b : 'tab';
|
|
4241
|
-
const menuStyles = css.css({
|
|
4242
|
-
display: 'flex',
|
|
4243
|
-
gap: theme.controls.gap,
|
|
4244
|
-
listStyleType: 'none',
|
|
4245
|
-
margin: 0,
|
|
4246
|
-
padding: 0,
|
|
4247
|
-
flexWrap: variant === 'button' ? 'wrap' : 'nowrap'
|
|
4248
|
-
}, variant === 'button' && {
|
|
4249
|
-
borderBottom: theme.controls.border,
|
|
4250
|
-
paddingBottom: '1rem'
|
|
4251
|
-
});
|
|
4252
|
-
function onTabSelect(index, tabId, focusAfter) {
|
|
4253
|
-
const onChange = () => {
|
|
4254
|
-
var _a;
|
|
4255
|
-
setTabIndex(index);
|
|
4256
|
-
(_a = p.onTabChanged) === null || _a === void 0 ? void 0 : _a.call(p, index);
|
|
4257
|
-
if (focusAfter) {
|
|
4258
|
-
setTimeout(() => {
|
|
4259
|
-
var _a;
|
|
4260
|
-
(_a = document.getElementById(tabId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4261
|
-
}, 0);
|
|
4262
|
-
}
|
|
4263
|
-
};
|
|
4264
|
-
if (p.onBeforeTabChanged) {
|
|
4265
|
-
setTabsChanging(true);
|
|
4266
|
-
p.onBeforeTabChanged(index)
|
|
4267
|
-
.then(() => {
|
|
4268
|
-
onChange();
|
|
4269
|
-
})
|
|
4270
|
-
.catch(() => {
|
|
4271
|
-
/* do nothing */
|
|
4272
|
-
})
|
|
4273
|
-
.finally(() => {
|
|
4274
|
-
setTabsChanging(false);
|
|
4275
|
-
});
|
|
4276
|
-
}
|
|
4277
|
-
else {
|
|
4278
|
-
onChange();
|
|
4279
|
-
}
|
|
4280
|
-
}
|
|
4281
|
-
return (React__namespace.createElement("div", { className: "tabHeader" },
|
|
4282
|
-
React__namespace.createElement("ul", { role: 'tablist', "aria-label": p.ariaLabel, className: css.cx(menuStyles, p.containerClassName) }, p.tabs.map((tab, index) => {
|
|
4283
|
-
var _a, _b;
|
|
4284
|
-
const active = index === tabIndex;
|
|
4285
|
-
let tabStyles;
|
|
4286
|
-
let buttonStyles;
|
|
4287
|
-
let buttonVariant;
|
|
4288
|
-
if (variant === 'tab') {
|
|
4289
|
-
tabStyles = css.css({
|
|
4290
|
-
paddingLeft: '1rem',
|
|
4291
|
-
paddingRight: '1rem',
|
|
4292
|
-
backgroundColor: theme.colors.bg,
|
|
4293
|
-
zIndex: 1,
|
|
4294
|
-
}, active && {
|
|
4295
|
-
border: theme.controls.border,
|
|
4296
|
-
borderRadius: theme.controls.borderRadius,
|
|
4297
|
-
borderBottomLeftRadius: 0,
|
|
4298
|
-
borderBottomRightRadius: 0,
|
|
4299
|
-
borderBottom: 'none',
|
|
4300
|
-
zIndex: 3,
|
|
4301
|
-
});
|
|
4302
|
-
buttonVariant = 'link';
|
|
4303
|
-
buttonStyles = css.css({
|
|
4304
|
-
maxWidth: (_a = p.maxTabWidth) !== null && _a !== void 0 ? _a : '10rem',
|
|
4305
|
-
overflow: 'hidden'
|
|
4306
|
-
});
|
|
4307
|
-
}
|
|
4308
|
-
else {
|
|
4309
|
-
buttonVariant = active ? 'primary' : undefined;
|
|
4310
|
-
buttonStyles = css.css({
|
|
4311
|
-
paddingLeft: '1rem',
|
|
4312
|
-
paddingRight: '1rem',
|
|
4313
|
-
maxWidth: (_b = p.maxTabWidth) !== null && _b !== void 0 ? _b : '10rem',
|
|
4314
|
-
overflow: 'hidden',
|
|
4315
|
-
});
|
|
4316
|
-
}
|
|
4317
|
-
let title = tab.title;
|
|
4318
|
-
let buttonContent;
|
|
4319
|
-
if (typeof tab.name === 'string') {
|
|
4320
|
-
title !== null && title !== void 0 ? title : (title = tab.name);
|
|
4321
|
-
buttonContent = React__namespace.createElement(Text, { tag: "div", align: "center", ellipsis: true }, tab.name);
|
|
4322
|
-
}
|
|
4323
|
-
else {
|
|
4324
|
-
buttonContent = tab.name;
|
|
4325
|
-
}
|
|
4326
|
-
const tabId = getTabHeaderTabId(p.id, index);
|
|
4327
|
-
return (React__namespace.createElement("li", { key: index, className: css.cx(tabStyles, p.tabClassName) },
|
|
4328
|
-
React__namespace.createElement(Button, { id: tabId, tabIndex: active ? 0 : -1, role: "tab", "aria-controls": p.ariaControlsId, "aria-selected": active, disabled: tabsChanging, className: buttonStyles, variant: buttonVariant, title: title, readOnly: active, onClick: () => {
|
|
4329
|
-
onTabSelect(index, tabId, false);
|
|
4330
|
-
}, onKeyDown: e => {
|
|
4331
|
-
e.stopPropagation();
|
|
4332
|
-
let newIndex = index;
|
|
4333
|
-
if (e.code === 'ArrowLeft') {
|
|
4334
|
-
if (index === 0) {
|
|
4335
|
-
newIndex = p.tabs.length - 1;
|
|
4336
|
-
}
|
|
4337
|
-
else {
|
|
4338
|
-
newIndex = index - 1;
|
|
4339
|
-
}
|
|
4340
|
-
}
|
|
4341
|
-
else if (e.code === 'ArrowRight') {
|
|
4342
|
-
if (index === p.tabs.length - 1) {
|
|
4343
|
-
newIndex = 0;
|
|
4344
|
-
}
|
|
4345
|
-
else {
|
|
4346
|
-
newIndex = index + 1;
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
4349
|
-
if (newIndex !== index) {
|
|
4350
|
-
onTabSelect(newIndex, getTabHeaderTabId(p.id, newIndex), true);
|
|
4351
|
-
}
|
|
4352
|
-
} }, buttonContent)));
|
|
4353
|
-
})),
|
|
4354
|
-
variant === 'tab' && (React__namespace.createElement("div", { className: css.cx(css.css({
|
|
4355
|
-
label: 'TabHeaderDivider',
|
|
4356
|
-
borderBottom: theme.controls.border,
|
|
4357
|
-
marginTop: `calc(${theme.controls.borderWidth} * -1)`,
|
|
4358
|
-
zIndex: 2,
|
|
4359
|
-
position: 'relative'
|
|
4360
|
-
}), p.tabHeaderDividerClassName) }))));
|
|
4361
|
-
};
|
|
4362
|
-
function getTabHeaderTabId(tabHeaderId, tabIndex) {
|
|
4363
|
-
return `${tabHeaderId}_tab_${tabIndex}`;
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
|
-
const Table = (props) => {
|
|
4367
|
-
const theme = useThemeSafely();
|
|
4368
|
-
const tableStyles = css.css `
|
|
4369
|
-
label: Table;
|
|
4370
|
-
width: 100%;
|
|
4371
|
-
border-collapse: collapse;
|
|
4372
|
-
${props.noCellBorder && `
|
|
4373
|
-
.table__td {
|
|
4374
|
-
border-left: none;
|
|
4375
|
-
border-right: none;
|
|
4376
|
-
}
|
|
4377
|
-
`}
|
|
4378
|
-
${props.altRows && `
|
|
4379
|
-
.table__tr:nth-of-type(even) {
|
|
4380
|
-
background-color: ${theme.colors.lightBg};
|
|
4381
|
-
}
|
|
4382
|
-
`}
|
|
4383
|
-
`;
|
|
4384
|
-
const wrapperStyles = css.css `
|
|
4385
|
-
label: TableScrollWrapper;
|
|
4386
|
-
width:100%;
|
|
4387
|
-
overflow-y: auto;
|
|
4388
|
-
padding:0 1px; //fixes always showing of the table scroller
|
|
4389
|
-
`;
|
|
4390
|
-
return (React__namespace.createElement("div", { className: css.cx(wrapperStyles, props.wrapperClassName) },
|
|
4391
|
-
React__namespace.createElement("table", { className: css.cx(tableStyles, props.className) },
|
|
4392
|
-
props.caption && React__namespace.createElement("caption", { className: css.css({
|
|
4393
|
-
fontWeight: 'bold',
|
|
4394
|
-
padding: theme.controls.padding
|
|
4395
|
-
}) }, props.caption),
|
|
4396
|
-
props.children)));
|
|
4397
|
-
};
|
|
4398
|
-
const Tr = (props) => {
|
|
4399
|
-
return (React__namespace.createElement("tr", { className: css.cx('table__tr', props.className) }, props.children));
|
|
4400
|
-
};
|
|
4401
|
-
const Th = (props) => {
|
|
4402
|
-
var _a;
|
|
4403
|
-
let style = props.style;
|
|
4404
|
-
if (props.width) {
|
|
4405
|
-
if (style) {
|
|
4406
|
-
style = Object.assign(Object.assign({}, style), { width: props.width, minWidth: props.width });
|
|
4407
|
-
}
|
|
4408
|
-
else {
|
|
4409
|
-
style = { width: props.width, minWidth: props.width };
|
|
4410
|
-
}
|
|
4411
|
-
}
|
|
4412
|
-
const theme = useThemeSafely();
|
|
4413
|
-
const thStyles = css.css `
|
|
4414
|
-
border-bottom: ${theme.controls.border};
|
|
4415
|
-
padding: ${theme.controls.padding};
|
|
4416
|
-
font-weight: bold;
|
|
4417
|
-
text-align: ${(_a = props.align) !== null && _a !== void 0 ? _a : 'center'};
|
|
4418
|
-
> .button {
|
|
4419
|
-
font-weight: bold;
|
|
4420
|
-
}
|
|
4421
|
-
`;
|
|
4422
|
-
return (React__namespace.createElement("th", { className: css.cx(thStyles, props.className), style: style }, props.children));
|
|
4423
|
-
};
|
|
4424
|
-
const Td = (props) => {
|
|
4425
|
-
var _a;
|
|
4426
|
-
const theme = useThemeSafely();
|
|
4427
|
-
const tdStyles = css.css `
|
|
4428
|
-
border: ${theme.controls.border};
|
|
4429
|
-
padding: ${theme.controls.padding};
|
|
4430
|
-
vertical-align: middle;
|
|
4431
|
-
text-align: ${(_a = props.align) !== null && _a !== void 0 ? _a : 'center'};
|
|
4432
|
-
`;
|
|
4433
|
-
return (React__namespace.createElement("td", { colSpan: props.colSpan, style: props.style, className: css.cx('table__td', tdStyles, props.className) }, props.children));
|
|
4434
|
-
};
|
|
4435
|
-
|
|
4436
|
-
const TdCurrency = (props) => {
|
|
4437
|
-
let actualValue = props.value || 0;
|
|
4438
|
-
if (props.cents) {
|
|
4439
|
-
actualValue = actualValue / 100;
|
|
4440
|
-
}
|
|
4441
|
-
const displayValue = actualValue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
4442
|
-
return (React__namespace.createElement(Td, { align: "right" },
|
|
4443
|
-
"$",
|
|
4444
|
-
displayValue));
|
|
4445
|
-
};
|
|
4446
|
-
|
|
4447
|
-
const TdNumber = (props) => {
|
|
4448
|
-
return React__namespace.createElement(Td, { align: "right" }, props.value || props.value === 0 ? props.value.toLocaleString() : '');
|
|
4449
|
-
};
|
|
4450
|
-
|
|
4451
|
-
const ThSort = (props) => {
|
|
4452
|
-
let iconId = '';
|
|
4453
|
-
if (props.direction) {
|
|
4454
|
-
if (props.direction === 'asc') {
|
|
4455
|
-
iconId = 'sortAsc';
|
|
4456
|
-
}
|
|
4457
|
-
else {
|
|
4458
|
-
iconId = 'sortDesc';
|
|
4459
|
-
}
|
|
4460
|
-
}
|
|
4461
|
-
let rightContentSpecialJustify = 'center';
|
|
4462
|
-
switch (props.align) {
|
|
4463
|
-
case 'left':
|
|
4464
|
-
rightContentSpecialJustify = 'flex-start';
|
|
4465
|
-
break;
|
|
4466
|
-
case 'right':
|
|
4467
|
-
rightContentSpecialJustify = 'flex-end';
|
|
4468
|
-
break;
|
|
4469
|
-
}
|
|
4470
|
-
return (React__namespace.createElement(Th, { align: props.align, style: props.style, width: props.width },
|
|
4471
|
-
React__namespace.createElement("div", { className: props.rightContent && css.css({
|
|
4472
|
-
display: 'flex',
|
|
4473
|
-
alignItems: 'center',
|
|
4474
|
-
justifyContent: rightContentSpecialJustify,
|
|
4475
|
-
gap: '0.5rem'
|
|
4476
|
-
}) },
|
|
4477
|
-
React__namespace.createElement(Button, { onClick: props.onClick, variant: "link" },
|
|
4478
|
-
props.text,
|
|
4479
|
-
iconId && React__namespace.createElement(Icon, { className: css.css({
|
|
4480
|
-
marginLeft: '0.5rem'
|
|
4481
|
-
}), id: iconId })),
|
|
4482
|
-
props.rightContent)));
|
|
4483
|
-
};
|
|
4484
|
-
|
|
4485
|
-
const defaultMaxLength = 200;
|
|
4486
|
-
const defaultRows = 10;
|
|
4487
|
-
const TextArea = React__namespace.forwardRef((props, ref) => {
|
|
4488
|
-
var _a, _b;
|
|
4489
|
-
const [localValue, setLocalValue] = React__namespace.useState(props.value);
|
|
4490
|
-
const inputRef = (ref !== null && ref !== void 0 ? ref : React__namespace.useRef(null));
|
|
4491
|
-
const [validationError, updateErrorMessage] = useInputValidationMessage(inputRef, props);
|
|
4492
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4493
|
-
const { onValueChange, customError, reportValueOnError, showErrorDisplay, allowUpdateOnFocus } = props, nativeProps = __rest(props, ["onValueChange", "customError", "reportValueOnError", "showErrorDisplay", "allowUpdateOnFocus"]);
|
|
4494
|
-
const theme = useThemeSafely();
|
|
4495
|
-
React__namespace.useEffect(() => {
|
|
4496
|
-
updateErrorMessage();
|
|
4497
|
-
}, []);
|
|
4498
|
-
useIgnoreMount(() => {
|
|
4499
|
-
var _a;
|
|
4500
|
-
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity()) {
|
|
4501
|
-
onValueChange(localValue);
|
|
4502
|
-
}
|
|
4503
|
-
else {
|
|
4504
|
-
if (reportValueOnError) {
|
|
4505
|
-
onValueChange(localValue);
|
|
4506
|
-
}
|
|
4507
|
-
else {
|
|
4508
|
-
onValueChange(undefined);
|
|
4509
|
-
}
|
|
4510
|
-
}
|
|
4511
|
-
updateErrorMessage();
|
|
4512
|
-
}, [localValue]);
|
|
4513
|
-
useIgnoreMount(() => {
|
|
4514
|
-
if (allowUpdateOnFocus || document.activeElement !== inputRef.current) {
|
|
4515
|
-
setLocalValue(props.value);
|
|
4516
|
-
}
|
|
4517
|
-
updateErrorMessage();
|
|
4518
|
-
}, [props.value]);
|
|
4519
|
-
const styles = css.css({
|
|
4520
|
-
backgroundColor: theme.colors.bg,
|
|
4521
|
-
maxWidth: '100%',
|
|
4522
|
-
minHeight: theme.controls.height,
|
|
4523
|
-
fontFamily: theme.fonts.family,
|
|
4524
|
-
fontSize: theme.fonts.size,
|
|
4525
|
-
width: '100%',
|
|
4526
|
-
border: theme.controls.border,
|
|
4527
|
-
borderRadius: theme.controls.borderRadius,
|
|
4528
|
-
color: theme.colors.font,
|
|
4529
|
-
paddingTop: '0.75rem',
|
|
4530
|
-
paddingLeft: theme.controls.padding,
|
|
4531
|
-
paddingRight: theme.controls.padding,
|
|
4532
|
-
height: 'auto',
|
|
4533
|
-
transition: theme.controls.transition,
|
|
4534
|
-
':focus': {
|
|
4535
|
-
outline: 'none',
|
|
4536
|
-
boxShadow: theme.controls.focusOutlineShadow
|
|
4537
|
-
},
|
|
4538
|
-
':disabled': {
|
|
4539
|
-
backgroundColor: theme.colors.disabled,
|
|
4540
|
-
cursor: 'not-allowed'
|
|
4541
|
-
},
|
|
4542
|
-
':invalid': {
|
|
4543
|
-
borderColor: theme.colors.required,
|
|
4544
|
-
':focus': {
|
|
4545
|
-
boxShadow: theme.controls.focusOutlineRequiredShadow
|
|
4546
|
-
}
|
|
4547
|
-
},
|
|
4548
|
-
}, props.readOnly && {
|
|
4549
|
-
backgroundColor: 'transparent',
|
|
4550
|
-
cursor: 'default',
|
|
4551
|
-
border: 'none',
|
|
4552
|
-
':focus': {
|
|
4553
|
-
outline: 'none',
|
|
4554
|
-
boxShadow: 'none'
|
|
4555
|
-
}
|
|
4556
|
-
});
|
|
4557
|
-
return (React__namespace.createElement("span", { className: css.css({
|
|
4558
|
-
display: 'inline-block',
|
|
4559
|
-
width: '100%'
|
|
4560
|
-
}) },
|
|
4561
|
-
React__namespace.createElement("textarea", Object.assign({}, nativeProps, { className: css.cx(styles, props.className), autoComplete: (_a = props.autoComplete) !== null && _a !== void 0 ? _a : 'off', tabIndex: props.readOnly ? -1 : props.tabIndex, maxLength: props.maxLength || defaultMaxLength, rows: (_b = props.rows) !== null && _b !== void 0 ? _b : defaultRows, ref: inputRef, value: localValue !== null && localValue !== void 0 ? localValue : '', onChange: e => {
|
|
4562
|
-
var _a;
|
|
4563
|
-
setLocalValue(e.target.value || undefined);
|
|
4564
|
-
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
4565
|
-
}, onBlur: e => {
|
|
4566
|
-
var _a;
|
|
4567
|
-
if (!props.noTrim) {
|
|
4568
|
-
setLocalValue(currentValue => {
|
|
4569
|
-
return currentValue === null || currentValue === void 0 ? void 0 : currentValue.trim();
|
|
4570
|
-
});
|
|
4385
|
+
const log = useLogger('LocalizationProvider', (_a = p.__debug) !== null && _a !== void 0 ? _a : false);
|
|
4386
|
+
const stringsDb = strings;
|
|
4387
|
+
return (React.createElement(LocalizationContext.Provider, { value: {
|
|
4388
|
+
language: p.language,
|
|
4389
|
+
getText: (text) => {
|
|
4390
|
+
if (!text) {
|
|
4391
|
+
return '';
|
|
4571
4392
|
}
|
|
4572
|
-
(
|
|
4573
|
-
|
|
4574
|
-
(showErrorDisplay !== null && showErrorDisplay !== void 0 ? showErrorDisplay : true) && React__namespace.createElement(InputErrorDisplay, { error: validationError })));
|
|
4575
|
-
});
|
|
4576
|
-
|
|
4577
|
-
const ToggleButton = React__namespace.forwardRef((props, ref) => {
|
|
4578
|
-
const { checked, checkedChildren, uncheckedChildren, checkedVariant, checkedClassName, checkedStyle, checkedIcon, uncheckedIcon } = props, buttonProps = __rest(props, ["checked", "checkedChildren", "uncheckedChildren", "checkedVariant", "checkedClassName", "checkedStyle", "checkedIcon", "uncheckedIcon"]);
|
|
4579
|
-
let children;
|
|
4580
|
-
if (checked) {
|
|
4581
|
-
children = checkedChildren;
|
|
4582
|
-
}
|
|
4583
|
-
else {
|
|
4584
|
-
children = uncheckedChildren;
|
|
4585
|
-
}
|
|
4586
|
-
return (React__namespace.createElement(Button, Object.assign({}, buttonProps, { ref: ref, className: css.cx('toggleButton', checked && 'toggleButton--checked', props.className, checked && checkedClassName), rightIcon: checked ? checkedIcon : uncheckedIcon, variant: checked ? checkedVariant : props.variant, style: checked ? checkedStyle : props.style }), children));
|
|
4587
|
-
});
|
|
4588
|
-
|
|
4589
|
-
const ToggleButtonGroup = (props) => {
|
|
4590
|
-
const theme = useThemeSafely();
|
|
4591
|
-
const groupStyles = css.css `
|
|
4592
|
-
display: flex;
|
|
4593
|
-
box-shadow: ${theme.controls.buttonBoxShadow};
|
|
4594
|
-
border-radius: ${theme.controls.borderRadius};
|
|
4595
|
-
${props.round && `
|
|
4596
|
-
border-radius: ${theme.controls.roundRadius};
|
|
4597
|
-
`}
|
|
4598
|
-
`;
|
|
4599
|
-
const buttonStyles = css.css `
|
|
4600
|
-
flex-grow:1;
|
|
4601
|
-
box-shadow: none;
|
|
4602
|
-
&:nth-of-type(1n+2){
|
|
4603
|
-
margin-left: -1px;
|
|
4604
|
-
}
|
|
4605
|
-
border-radius: 0;
|
|
4606
|
-
&:first-of-type{
|
|
4607
|
-
border-top-left-radius: ${theme.controls.borderRadius};
|
|
4608
|
-
border-bottom-left-radius: ${theme.controls.borderRadius};
|
|
4609
|
-
}
|
|
4610
|
-
&:last-child {
|
|
4611
|
-
border-top-right-radius: ${theme.controls.borderRadius};
|
|
4612
|
-
border-bottom-right-radius: ${theme.controls.borderRadius};
|
|
4613
|
-
}
|
|
4614
|
-
${props.round && `
|
|
4615
|
-
&:first-of-type{
|
|
4616
|
-
border-top-left-radius: ${theme.controls.roundRadius};
|
|
4617
|
-
border-bottom-left-radius: ${theme.controls.roundRadius};
|
|
4618
|
-
padding-left: 1rem;
|
|
4619
|
-
}
|
|
4620
|
-
&:last-child {
|
|
4621
|
-
border-top-right-radius: ${theme.controls.roundRadius};
|
|
4622
|
-
border-bottom-right-radius: ${theme.controls.roundRadius};
|
|
4623
|
-
padding-right: 1rem;
|
|
4624
|
-
}
|
|
4625
|
-
`}
|
|
4626
|
-
`;
|
|
4627
|
-
return (React__namespace.createElement("div", { className: css.cx('toggleButtonGroup', groupStyles, props.className) }, props.options.map(o => {
|
|
4628
|
-
const active = o.id === props.value;
|
|
4629
|
-
return React__namespace.createElement(Button, { style: props.width ? { width: props.width } : undefined, small: props.small, rightIcon: o.rightIcon, key: o.id, tabIndex: active ? -1 : 0, className: css.cx(css.css `
|
|
4630
|
-
${buttonStyles}
|
|
4631
|
-
${active && `
|
|
4632
|
-
background-color: ${theme.colors.font};
|
|
4633
|
-
color: ${theme.colors.bg};
|
|
4634
|
-
cursor: default;
|
|
4635
|
-
&:hover:not(:disabled) {
|
|
4636
|
-
filter: none;
|
|
4637
|
-
}
|
|
4638
|
-
&:focus {
|
|
4639
|
-
outline: none;
|
|
4640
|
-
box-shadow: none;
|
|
4641
|
-
}
|
|
4642
|
-
`}
|
|
4643
|
-
`, active ? o.activeClass : undefined), disabled: props.disabled, enforceMinWidth: props.enforceMinWidth, onClick: () => {
|
|
4644
|
-
if (active) {
|
|
4645
|
-
return;
|
|
4393
|
+
if (!isNaN(parseInt(text))) {
|
|
4394
|
+
return text;
|
|
4646
4395
|
}
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
}
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
fontSize: '1rem'
|
|
4662
|
-
}, variant: "icon", onClick: () => {
|
|
4663
|
-
setShow(previous => !previous);
|
|
4664
|
-
} },
|
|
4665
|
-
React__namespace.createElement(Icon, { id: show ? 'show' : 'hide' }))) })));
|
|
4666
|
-
});
|
|
4667
|
-
|
|
4668
|
-
let clearTimerId = undefined;
|
|
4669
|
-
/** Allows for status notificaiton methods for screen readers.
|
|
4670
|
-
* This hook does not have any dependencies, so it can be used in projects that don't important anything else from the style_guide. */
|
|
4671
|
-
function useAriaLiveRegion() {
|
|
4672
|
-
const id = 'MknAriaLiveRegion';
|
|
4673
|
-
if (!document.getElementById(id)) {
|
|
4674
|
-
const div = document.createElement('div');
|
|
4675
|
-
div.id = id;
|
|
4676
|
-
// different sources cannot decide if this is needed.
|
|
4677
|
-
// "Can work for status messages, but aria-live="polite" + text is usually simpler and more reliable for loading."
|
|
4678
|
-
div.role = 'status';
|
|
4679
|
-
div.ariaLive = 'polite';
|
|
4680
|
-
div.ariaAtomic = 'true';
|
|
4681
|
-
div.style.position = 'absolute';
|
|
4682
|
-
div.style.width = '1px';
|
|
4683
|
-
div.style.height = '1px';
|
|
4684
|
-
div.style.padding = '0px';
|
|
4685
|
-
div.style.margin = '-1px';
|
|
4686
|
-
div.style.overflow = 'hidden';
|
|
4687
|
-
div.style.whiteSpace = 'nowrap';
|
|
4688
|
-
document.body.prepend(div);
|
|
4689
|
-
}
|
|
4690
|
-
const clearNotification = () => {
|
|
4691
|
-
if (clearTimerId) {
|
|
4692
|
-
clearTimeout(clearTimerId);
|
|
4693
|
-
}
|
|
4694
|
-
const element = document.getElementById(id);
|
|
4695
|
-
if (!element) {
|
|
4696
|
-
return;
|
|
4697
|
-
}
|
|
4698
|
-
element.textContent = '';
|
|
4699
|
-
};
|
|
4700
|
-
return {
|
|
4701
|
-
/**
|
|
4702
|
-
* @param message - The text to be read by the screen reader.
|
|
4703
|
-
* @param clearTimeoutMs - Milliseconds to wait before the message is cleared. Defaults to `2000`.
|
|
4704
|
-
*/
|
|
4705
|
-
notify: (message, clearTimoutMs) => {
|
|
4706
|
-
if (clearTimerId) {
|
|
4707
|
-
clearTimeout(clearTimerId);
|
|
4708
|
-
}
|
|
4709
|
-
const element = document.getElementById(id);
|
|
4710
|
-
if (!element) {
|
|
4711
|
-
return;
|
|
4712
|
-
}
|
|
4713
|
-
element.textContent = message;
|
|
4714
|
-
clearTimerId = setTimeout(() => {
|
|
4715
|
-
// this is considered a good practice. if you leave text here, some screen readers will read it out randomly as you navigate around the page.
|
|
4716
|
-
clearNotification();
|
|
4717
|
-
}, clearTimoutMs !== null && clearTimoutMs !== void 0 ? clearTimoutMs : 2000);
|
|
4718
|
-
},
|
|
4719
|
-
clearNotification
|
|
4720
|
-
};
|
|
4721
|
-
}
|
|
4722
|
-
|
|
4723
|
-
const WaitingIndicator = (p) => {
|
|
4724
|
-
var _a, _b, _c;
|
|
4725
|
-
const [show, setShow] = React.useState(p.show);
|
|
4726
|
-
const hideTimer = React.useRef(0);
|
|
4727
|
-
const lastShowStatus = React.useRef(false);
|
|
4728
|
-
const log = useLogger(`WaitingIndicator ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
4729
|
-
const { notify, clearNotification } = useAriaLiveRegion();
|
|
4730
|
-
if (p.__debug) {
|
|
4731
|
-
React.useEffect(() => {
|
|
4732
|
-
log('mounted');
|
|
4733
|
-
return () => {
|
|
4734
|
-
log('unmounted');
|
|
4735
|
-
};
|
|
4736
|
-
}, []);
|
|
4737
|
-
}
|
|
4738
|
-
React.useEffect(() => {
|
|
4739
|
-
log('show changed', p.show);
|
|
4740
|
-
// we need to store the 'last props' since props.show will be captured locally and the incorrect
|
|
4741
|
-
// value will display in the timeout below.
|
|
4742
|
-
log('storing lastShowStatus', p.show);
|
|
4743
|
-
lastShowStatus.current = p.show;
|
|
4744
|
-
if (p.show) {
|
|
4745
|
-
log('setShow', true);
|
|
4746
|
-
setShow(true);
|
|
4747
|
-
if (p.minShowTimeMs) {
|
|
4748
|
-
log('staring hideTimer', 'timout in ms:', p.minShowTimeMs);
|
|
4749
|
-
hideTimer.current = window.setTimeout(() => {
|
|
4750
|
-
log('hideTimer complete', 'clearing hideTimer');
|
|
4751
|
-
window.clearTimeout(hideTimer.current);
|
|
4752
|
-
hideTimer.current = 0;
|
|
4753
|
-
// this check is necessary since the show status may have updated again to true.
|
|
4754
|
-
// if so, ignore this timeout since we're already past the min time and we're still
|
|
4755
|
-
// showing the component.
|
|
4756
|
-
if (!lastShowStatus.current) {
|
|
4757
|
-
log('setShow', false);
|
|
4758
|
-
setShow(false);
|
|
4759
|
-
}
|
|
4760
|
-
else {
|
|
4761
|
-
log('ignoring hideTimer handler due to hideTimer ticking');
|
|
4762
|
-
}
|
|
4763
|
-
}, p.minShowTimeMs);
|
|
4764
|
-
}
|
|
4765
|
-
}
|
|
4766
|
-
else {
|
|
4767
|
-
// ignore hiding the component since the min timer is running.
|
|
4768
|
-
if (!hideTimer.current) {
|
|
4769
|
-
log('setShow', false);
|
|
4770
|
-
setShow(false);
|
|
4771
|
-
}
|
|
4772
|
-
else {
|
|
4773
|
-
log('ignoring show change due to hideTimer ticking');
|
|
4396
|
+
const wordArray = stringsDb[text];
|
|
4397
|
+
if (!wordArray) {
|
|
4398
|
+
log(`No localization data exists for "${text}".`);
|
|
4399
|
+
}
|
|
4400
|
+
if (p.language === exports.StyleGuideLanguage.English) {
|
|
4401
|
+
return text;
|
|
4402
|
+
}
|
|
4403
|
+
const languageIndex = p.language - 1;
|
|
4404
|
+
const translation = wordArray === null || wordArray === void 0 ? void 0 : wordArray[languageIndex];
|
|
4405
|
+
if (translation) {
|
|
4406
|
+
return translation;
|
|
4407
|
+
}
|
|
4408
|
+
log(`No ${exports.StyleGuideLanguage[p.language]} translations exist for "${text}".`);
|
|
4409
|
+
return text;
|
|
4774
4410
|
}
|
|
4775
|
-
}
|
|
4776
|
-
if (p.show) {
|
|
4777
|
-
// set to a very long time so the hiding of the waiting indicator clears it.
|
|
4778
|
-
notify('Loading content.', 60000);
|
|
4779
|
-
}
|
|
4780
|
-
else {
|
|
4781
|
-
clearNotification();
|
|
4782
|
-
}
|
|
4783
|
-
}, [p.show]);
|
|
4784
|
-
const id = (_c = p.id) !== null && _c !== void 0 ? _c : 'MknWaitingIndicator';
|
|
4785
|
-
return (React.createElement(Modal, { id: id, __debug: p.__debug, __asWaitingIndicator: true, heading: '', onClose: () => {
|
|
4786
|
-
/* noop */
|
|
4787
|
-
}, className: "waitingIndicator", show: show },
|
|
4788
|
-
React.createElement("div", { className: css.css({
|
|
4789
|
-
color: 'white',
|
|
4790
|
-
fontSize: '3rem',
|
|
4791
|
-
padding: '0.7rem'
|
|
4792
|
-
}) },
|
|
4793
|
-
React.createElement(Icon, { id: "waiting", spin: true }))));
|
|
4411
|
+
} }, p.children));
|
|
4794
4412
|
};
|
|
4795
4413
|
|
|
4796
4414
|
/*
|
|
@@ -5089,283 +4707,777 @@ summary {
|
|
|
5089
4707
|
`;
|
|
5090
4708
|
return null;
|
|
5091
4709
|
};
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
const
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
4710
|
+
|
|
4711
|
+
const Table = (props) => {
|
|
4712
|
+
const theme = useThemeSafely();
|
|
4713
|
+
const tableStyles = css.css `
|
|
4714
|
+
label: Table;
|
|
4715
|
+
width: 100%;
|
|
4716
|
+
border-collapse: collapse;
|
|
4717
|
+
${props.noCellBorder && `
|
|
4718
|
+
.table__td {
|
|
4719
|
+
border-left: none;
|
|
4720
|
+
border-right: none;
|
|
4721
|
+
}
|
|
4722
|
+
`}
|
|
4723
|
+
${props.altRows && `
|
|
4724
|
+
.table__tr:nth-of-type(even) {
|
|
4725
|
+
background-color: ${theme.colors.lightBg};
|
|
4726
|
+
}
|
|
4727
|
+
`}
|
|
4728
|
+
`;
|
|
4729
|
+
const wrapperStyles = css.css `
|
|
4730
|
+
label: TableScrollWrapper;
|
|
4731
|
+
width:100%;
|
|
4732
|
+
overflow-y: auto;
|
|
4733
|
+
padding:0 1px; //fixes always showing of the table scroller
|
|
4734
|
+
`;
|
|
4735
|
+
return (React__namespace.createElement("div", { className: css.cx(wrapperStyles, props.wrapperClassName) },
|
|
4736
|
+
React__namespace.createElement("table", { className: css.cx(tableStyles, props.className) },
|
|
4737
|
+
props.caption && React__namespace.createElement("caption", { className: css.css({
|
|
4738
|
+
fontWeight: 'bold',
|
|
4739
|
+
padding: theme.controls.padding
|
|
4740
|
+
}) }, props.caption),
|
|
4741
|
+
props.children)));
|
|
4742
|
+
};
|
|
4743
|
+
const Tr = (props) => {
|
|
4744
|
+
return (React__namespace.createElement("tr", { className: css.cx('table__tr', props.className) }, props.children));
|
|
4745
|
+
};
|
|
4746
|
+
const Th = (props) => {
|
|
4747
|
+
var _a;
|
|
4748
|
+
let style = props.style;
|
|
4749
|
+
if (props.width) {
|
|
4750
|
+
if (style) {
|
|
4751
|
+
style = Object.assign(Object.assign({}, style), { width: props.width, minWidth: props.width });
|
|
4752
|
+
}
|
|
4753
|
+
else {
|
|
4754
|
+
style = { width: props.width, minWidth: props.width };
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
const theme = useThemeSafely();
|
|
4758
|
+
const thStyles = css.css `
|
|
4759
|
+
border-bottom: ${theme.controls.border};
|
|
4760
|
+
padding: ${theme.controls.padding};
|
|
4761
|
+
font-weight: bold;
|
|
4762
|
+
text-align: ${(_a = props.align) !== null && _a !== void 0 ? _a : 'center'};
|
|
4763
|
+
> .button {
|
|
4764
|
+
font-weight: bold;
|
|
4765
|
+
}
|
|
4766
|
+
`;
|
|
4767
|
+
return (React__namespace.createElement("th", { className: css.cx(thStyles, props.className), style: style }, props.children));
|
|
4768
|
+
};
|
|
4769
|
+
const Td = (props) => {
|
|
4770
|
+
var _a;
|
|
4771
|
+
const theme = useThemeSafely();
|
|
4772
|
+
const tdStyles = css.css `
|
|
4773
|
+
border: ${theme.controls.border};
|
|
4774
|
+
padding: ${theme.controls.padding};
|
|
4775
|
+
vertical-align: middle;
|
|
4776
|
+
text-align: ${(_a = props.align) !== null && _a !== void 0 ? _a : 'center'};
|
|
4777
|
+
`;
|
|
4778
|
+
return (React__namespace.createElement("td", { colSpan: props.colSpan, style: props.style, className: css.cx('table__td', tdStyles, props.className) }, props.children));
|
|
4779
|
+
};
|
|
4780
|
+
|
|
4781
|
+
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
4782
|
+
const ThemeRenderer = (p) => {
|
|
4783
|
+
const { backgroundColor, color } = p, theme = __rest(p, ["backgroundColor", "color"]);
|
|
4784
|
+
const flatTheme = flatten(theme);
|
|
4785
|
+
const entries = lodash.orderBy(Object.entries(flatTheme), x => x[0]);
|
|
4786
|
+
return (React__namespace.createElement(Table, { caption: (React__namespace.createElement("div", null,
|
|
4787
|
+
React__namespace.createElement(Text, { tag: "h1", align: "center" }, "Theme"),
|
|
4788
|
+
React__namespace.createElement(Text, { tag: "p", align: "center", italics: true }, "Background color applied to show colors with alpha ('rgba(X, X, X, 0.X)')"))), className: css.css({
|
|
4789
|
+
backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : '#eee7ca',
|
|
4790
|
+
color: color !== null && color !== void 0 ? color : 'black'
|
|
4791
|
+
}) },
|
|
4792
|
+
React__namespace.createElement("thead", null,
|
|
4793
|
+
React__namespace.createElement(Tr, null,
|
|
4794
|
+
React__namespace.createElement(Th, { align: "left" }, "Property"),
|
|
4795
|
+
React__namespace.createElement(Th, { align: "left" }, "Value"))),
|
|
4796
|
+
React__namespace.createElement("tbody", null, entries.map(([key, value]) => {
|
|
4797
|
+
let colorBox;
|
|
4798
|
+
if (/color/i.test(key)) {
|
|
4799
|
+
colorBox = (React__namespace.createElement("span", { className: css.css({
|
|
4800
|
+
display: 'block',
|
|
4801
|
+
border: '1px solid black',
|
|
4802
|
+
width: '100%',
|
|
4803
|
+
height: 24,
|
|
4804
|
+
background: value
|
|
4805
|
+
}) }));
|
|
4806
|
+
}
|
|
4807
|
+
return (React__namespace.createElement(Tr, { key: key },
|
|
4808
|
+
React__namespace.createElement(Td, { align: "left" }, key),
|
|
4809
|
+
React__namespace.createElement(Td, { align: "left" },
|
|
4810
|
+
React__namespace.createElement("div", { className: css.css({
|
|
4811
|
+
display: 'flex',
|
|
4812
|
+
alignItems: 'center',
|
|
4813
|
+
gap: '1rem'
|
|
4814
|
+
}) },
|
|
4815
|
+
React__namespace.createElement("span", { className: css.css({ flexShrink: 1 }) }, value),
|
|
4816
|
+
" ",
|
|
4817
|
+
colorBox))));
|
|
4818
|
+
}))));
|
|
4819
|
+
};
|
|
4820
|
+
const flatten = (obj, parent, path = 'theme') => {
|
|
4821
|
+
const flatObj = parent !== null && parent !== void 0 ? parent : {};
|
|
4822
|
+
for (const prop in obj) {
|
|
4823
|
+
const value = obj[prop];
|
|
4824
|
+
const fullPath = `${path}.${prop}`;
|
|
4825
|
+
if (typeof value !== 'object') {
|
|
4826
|
+
flatObj[fullPath] = value;
|
|
4827
|
+
}
|
|
4828
|
+
else {
|
|
4829
|
+
flatten(value, flatObj, fullPath);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
return flatObj;
|
|
4833
|
+
};
|
|
4834
|
+
|
|
4835
|
+
let clearTimerId = undefined;
|
|
4836
|
+
/** Allows for status notificaiton methods for screen readers.
|
|
4837
|
+
* This hook does not have any dependencies, so it can be used in projects that don't important anything else from the style_guide. */
|
|
4838
|
+
function useAriaLiveRegion() {
|
|
4839
|
+
const id = 'MknAriaLiveRegion';
|
|
4840
|
+
if (!document.getElementById(id)) {
|
|
4841
|
+
const div = document.createElement('div');
|
|
4842
|
+
div.id = id;
|
|
4843
|
+
// different sources cannot decide if this is needed.
|
|
4844
|
+
// "Can work for status messages, but aria-live="polite" + text is usually simpler and more reliable for loading."
|
|
4845
|
+
div.role = 'status';
|
|
4846
|
+
div.ariaLive = 'polite';
|
|
4847
|
+
div.ariaAtomic = 'true';
|
|
4848
|
+
div.style.position = 'absolute';
|
|
4849
|
+
div.style.width = '1px';
|
|
4850
|
+
div.style.height = '1px';
|
|
4851
|
+
div.style.padding = '0px';
|
|
4852
|
+
div.style.margin = '-1px';
|
|
4853
|
+
div.style.overflow = 'hidden';
|
|
4854
|
+
div.style.whiteSpace = 'nowrap';
|
|
4855
|
+
document.body.prepend(div);
|
|
4856
|
+
}
|
|
4857
|
+
const clearNotification = () => {
|
|
4858
|
+
if (clearTimerId) {
|
|
4859
|
+
clearTimeout(clearTimerId);
|
|
4860
|
+
}
|
|
4861
|
+
const element = document.getElementById(id);
|
|
4862
|
+
if (!element) {
|
|
4863
|
+
return;
|
|
4864
|
+
}
|
|
4865
|
+
element.textContent = '';
|
|
4866
|
+
};
|
|
4867
|
+
return {
|
|
4868
|
+
/**
|
|
4869
|
+
* @param message - The text to be read by the screen reader.
|
|
4870
|
+
* @param clearTimeoutMs - Milliseconds to wait before the message is cleared. Defaults to `2000`.
|
|
4871
|
+
*/
|
|
4872
|
+
notify: (message, clearTimoutMs) => {
|
|
4873
|
+
if (clearTimerId) {
|
|
4874
|
+
clearTimeout(clearTimerId);
|
|
4875
|
+
}
|
|
4876
|
+
const element = document.getElementById(id);
|
|
4877
|
+
if (!element) {
|
|
4878
|
+
return;
|
|
4879
|
+
}
|
|
4880
|
+
element.textContent = message;
|
|
4881
|
+
clearTimerId = setTimeout(() => {
|
|
4882
|
+
// this is considered a good practice. if you leave text here, some screen readers will read it out randomly as you navigate around the page.
|
|
4883
|
+
clearNotification();
|
|
4884
|
+
}, clearTimoutMs !== null && clearTimoutMs !== void 0 ? clearTimoutMs : 2000);
|
|
4885
|
+
},
|
|
4886
|
+
clearNotification
|
|
4887
|
+
};
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
/*
|
|
4891
|
+
From https://fireship.io/snippets/use-media-query-hook/.
|
|
4892
|
+
Tried using https://www.npmjs.com/package/react-media, but it cause Webpack build issues.
|
|
4893
|
+
*/
|
|
4894
|
+
/** React wrapper around window resizing and window.matchMedia.
|
|
4895
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
|
|
4896
|
+
*/
|
|
4897
|
+
const useMediaQuery = (query) => {
|
|
4898
|
+
const [matches, setMatches] = React.useState(window.matchMedia(query).matches);
|
|
4899
|
+
React.useEffect(() => {
|
|
4900
|
+
const media = window.matchMedia(query);
|
|
4901
|
+
if (media.matches !== matches) {
|
|
4902
|
+
setMatches(media.matches);
|
|
4903
|
+
}
|
|
4904
|
+
const listener = () => setMatches(media.matches);
|
|
4905
|
+
window.addEventListener("resize", listener);
|
|
4906
|
+
return () => window.removeEventListener("resize", listener);
|
|
4907
|
+
}, [matches, query]);
|
|
4908
|
+
return matches;
|
|
4909
|
+
};
|
|
4910
|
+
|
|
4911
|
+
const Slider = (p) => {
|
|
4912
|
+
var _a;
|
|
4913
|
+
const theme = useThemeSafely();
|
|
4914
|
+
const sliderContainer = React.useRef(null);
|
|
4915
|
+
const sliderHandleSize = (_a = p.sliderHandleSize) !== null && _a !== void 0 ? _a : theme.controls.height;
|
|
4916
|
+
const height = p.showValue ? `calc(${sliderHandleSize} + 1.5rem)` : sliderHandleSize;
|
|
4917
|
+
// we're keeping this value in a ref vs. state so the constant updates don't cause re-render.
|
|
4918
|
+
// we will have to respond to outside value changes after the fact however...
|
|
4919
|
+
const currentValue = React.useRef(p.value);
|
|
4920
|
+
const [, forceUpdate] = React.useState(Date.now());
|
|
4921
|
+
React.useEffect(() => {
|
|
4922
|
+
if (p.value !== currentValue.current) {
|
|
4923
|
+
currentValue.current = p.value;
|
|
4924
|
+
forceUpdate(Date.now());
|
|
4925
|
+
}
|
|
4926
|
+
}, [p.value]);
|
|
4927
|
+
return (React.createElement("div", { ref: sliderContainer, className: css.cx(css.css({
|
|
4928
|
+
label: 'Slider',
|
|
4929
|
+
width: '100%',
|
|
4930
|
+
height,
|
|
4931
|
+
}), p.className) },
|
|
4932
|
+
React.createElement(ReactSlider, { ariaLabel: p.ariaLabel, step: p.step, min: p.min, max: p.max, value: p.value, onAfterChange: (value) => {
|
|
4933
|
+
p.onChange(value);
|
|
4934
|
+
}, onChange: p.onUpdate || p.showValue ? (value) => {
|
|
4935
|
+
var _a;
|
|
4936
|
+
currentValue.current = value;
|
|
4937
|
+
(_a = p.onUpdate) === null || _a === void 0 ? void 0 : _a.call(p, value);
|
|
4938
|
+
} : undefined, renderTrack: (props) => {
|
|
4939
|
+
const { className } = props, rest = __rest(props, ["className"]);
|
|
4940
|
+
return (React.createElement("div", Object.assign({ className: css.cx(className, p.trackClassName, css.css({
|
|
4941
|
+
display: 'flex',
|
|
4942
|
+
alignItems: 'center',
|
|
4943
|
+
height: sliderHandleSize
|
|
4944
|
+
})) }, rest),
|
|
4945
|
+
React.createElement("div", { className: css.css({
|
|
4946
|
+
backgroundColor: theme.colors.secondary,
|
|
4947
|
+
height: `calc(${sliderHandleSize} / 4)`,
|
|
4948
|
+
borderRadius: theme.controls.roundRadius,
|
|
4949
|
+
width: '100%'
|
|
4950
|
+
}, p.innerTrackClassName && rest.key === 'track-1' && Array.isArray(p.value) ? p.innerTrackClassName : undefined) })));
|
|
4951
|
+
}, renderThumb: (props, state) => {
|
|
4952
|
+
var _a;
|
|
4953
|
+
const { className } = props, rest = __rest(props, ["className"]);
|
|
4954
|
+
let specificThumbStyles;
|
|
4955
|
+
if (p.handle1ClassName && props.key === 'thumb-0') {
|
|
4956
|
+
specificThumbStyles = p.handle1ClassName;
|
|
4957
|
+
}
|
|
4958
|
+
else if (p.handle2ClassName && props.key === 'thumb-1') {
|
|
4959
|
+
specificThumbStyles = p.handle2ClassName;
|
|
4960
|
+
}
|
|
4961
|
+
return (React.createElement("div", Object.assign({ className: css.cx(className, css.css({
|
|
4962
|
+
borderRadius: theme.controls.roundRadius,
|
|
4963
|
+
backgroundColor: 'white',
|
|
4964
|
+
border: theme.controls.border,
|
|
4965
|
+
cursor: 'grab',
|
|
4966
|
+
boxShadow: theme.controls.buttonBoxShadow,
|
|
4967
|
+
transition: theme.controls.transition,
|
|
4968
|
+
'&:focus': {
|
|
4969
|
+
outline: 'none',
|
|
4970
|
+
boxShadow: theme.controls.focusOutlineShadow
|
|
4971
|
+
},
|
|
4972
|
+
'&:active': {
|
|
4973
|
+
boxShadow: 'none',
|
|
4974
|
+
cursor: 'grabbing'
|
|
4975
|
+
},
|
|
4976
|
+
'&:hover': {
|
|
4977
|
+
filter: theme.controls.hoverBrightness
|
|
4978
|
+
}
|
|
4979
|
+
}), specificThumbStyles, p.handleClassName, css.css({
|
|
4980
|
+
width: sliderHandleSize,
|
|
4981
|
+
height: sliderHandleSize,
|
|
4982
|
+
})) }, rest, { tabIndex: (_a = p.tabIndex) !== null && _a !== void 0 ? _a : 0 }), p.showValue && (React.createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
4983
|
+
} })));
|
|
4984
|
+
};
|
|
4985
|
+
const rectsCollideX = (r1, r2) => {
|
|
4986
|
+
if (r1.left >= r2.left && r1.left <= r2.right) {
|
|
4987
|
+
return true;
|
|
5098
4988
|
}
|
|
5099
|
-
|
|
4989
|
+
if (r1.right >= r2.left && r1.right <= r2.right) {
|
|
4990
|
+
return true;
|
|
4991
|
+
}
|
|
4992
|
+
return false;
|
|
4993
|
+
};
|
|
4994
|
+
const HandleText = (p) => {
|
|
4995
|
+
var _a, _b, _c;
|
|
4996
|
+
const displayValue = (_b = (_a = p.renderValue) === null || _a === void 0 ? void 0 : _a.call(p, p.value)) !== null && _b !== void 0 ? _b : p.value;
|
|
4997
|
+
const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c : p.sliderHandleSize;
|
|
4998
|
+
const renderValueLeft = React.useMemo(() => {
|
|
4999
|
+
return `calc(${renderValueWidth} * 0.5 * -1 + (${p.sliderHandleSize} * 0.5))`;
|
|
5000
|
+
}, [p.renderValueWidth, p.sliderHandleSize]);
|
|
5001
|
+
const [flipText, setFlipText] = React.useState(false);
|
|
5002
|
+
const offset = '2px';
|
|
5003
|
+
React.useEffect(() => {
|
|
5004
|
+
// this needs to fire on every render due to the other handle also moving.
|
|
5005
|
+
var _a, _b;
|
|
5006
|
+
if (p.index === 1) {
|
|
5007
|
+
// only do this for the max/right-most handle
|
|
5008
|
+
const [r1, r2] = Array.from((_b = (_a = p.parentElement) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.slider-handle').values()) !== null && _b !== void 0 ? _b : []).map(e => e.getBoundingClientRect());
|
|
5009
|
+
if (r1 && r2) {
|
|
5010
|
+
setFlipText(rectsCollideX(r1, r2));
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
});
|
|
5014
|
+
return (React.createElement(Text, { ellipsis: true, className: css.cx('slider-handle', css.css({
|
|
5015
|
+
width: renderValueWidth,
|
|
5016
|
+
left: renderValueLeft,
|
|
5017
|
+
top: flipText ? undefined : `calc(${p.sliderHandleSize} + ${offset})`,
|
|
5018
|
+
bottom: flipText ? `calc(${p.sliderHandleSize} + ${offset})` : undefined,
|
|
5019
|
+
position: 'absolute',
|
|
5020
|
+
overflow: 'hidden',
|
|
5021
|
+
}), p.className), tag: "div", align: "center" }, displayValue));
|
|
5100
5022
|
};
|
|
5101
5023
|
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
const
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5024
|
+
const TabHeader = (p) => {
|
|
5025
|
+
var _a, _b;
|
|
5026
|
+
const [tabIndex, setTabIndex] = React__namespace.useState((_a = p.startingIndex) !== null && _a !== void 0 ? _a : 0);
|
|
5027
|
+
const [tabsChanging, setTabsChanging] = React__namespace.useState(false);
|
|
5028
|
+
const theme = useThemeSafely();
|
|
5029
|
+
const variant = (_b = p.variant) !== null && _b !== void 0 ? _b : 'tab';
|
|
5030
|
+
const menuStyles = css.css({
|
|
5031
|
+
display: 'flex',
|
|
5032
|
+
gap: theme.controls.gap,
|
|
5033
|
+
listStyleType: 'none',
|
|
5034
|
+
margin: 0,
|
|
5035
|
+
padding: 0,
|
|
5036
|
+
flexWrap: variant === 'button' ? 'wrap' : 'nowrap'
|
|
5037
|
+
}, variant === 'button' && {
|
|
5038
|
+
borderBottom: theme.controls.border,
|
|
5039
|
+
paddingBottom: '1rem'
|
|
5040
|
+
});
|
|
5041
|
+
function onTabSelect(index, tabId, focusAfter) {
|
|
5042
|
+
const onChange = () => {
|
|
5043
|
+
var _a;
|
|
5044
|
+
setTabIndex(index);
|
|
5045
|
+
(_a = p.onTabChanged) === null || _a === void 0 ? void 0 : _a.call(p, index);
|
|
5046
|
+
if (focusAfter) {
|
|
5047
|
+
setTimeout(() => {
|
|
5048
|
+
var _a;
|
|
5049
|
+
(_a = document.getElementById(tabId)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5050
|
+
}, 0);
|
|
5051
|
+
}
|
|
5052
|
+
};
|
|
5053
|
+
if (p.onBeforeTabChanged) {
|
|
5054
|
+
setTabsChanging(true);
|
|
5055
|
+
p.onBeforeTabChanged(index)
|
|
5056
|
+
.then(() => {
|
|
5057
|
+
onChange();
|
|
5058
|
+
})
|
|
5059
|
+
.catch(() => {
|
|
5060
|
+
/* do nothing */
|
|
5061
|
+
})
|
|
5062
|
+
.finally(() => {
|
|
5063
|
+
setTabsChanging(false);
|
|
5110
5064
|
});
|
|
5111
5065
|
}
|
|
5066
|
+
else {
|
|
5067
|
+
onChange();
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
return (React__namespace.createElement("div", { className: "tabHeader" },
|
|
5071
|
+
React__namespace.createElement("ul", { role: 'tablist', "aria-label": p.ariaLabel, className: css.cx(menuStyles, p.containerClassName) }, p.tabs.map((tab, index) => {
|
|
5072
|
+
var _a, _b;
|
|
5073
|
+
const active = index === tabIndex;
|
|
5074
|
+
let tabStyles;
|
|
5075
|
+
let buttonStyles;
|
|
5076
|
+
let buttonVariant;
|
|
5077
|
+
if (variant === 'tab') {
|
|
5078
|
+
tabStyles = css.css({
|
|
5079
|
+
paddingLeft: '1rem',
|
|
5080
|
+
paddingRight: '1rem',
|
|
5081
|
+
backgroundColor: theme.colors.bg,
|
|
5082
|
+
zIndex: 1,
|
|
5083
|
+
}, active && {
|
|
5084
|
+
border: theme.controls.border,
|
|
5085
|
+
borderRadius: theme.controls.borderRadius,
|
|
5086
|
+
borderBottomLeftRadius: 0,
|
|
5087
|
+
borderBottomRightRadius: 0,
|
|
5088
|
+
borderBottom: 'none',
|
|
5089
|
+
zIndex: 3,
|
|
5090
|
+
});
|
|
5091
|
+
buttonVariant = 'link';
|
|
5092
|
+
buttonStyles = css.css({
|
|
5093
|
+
maxWidth: (_a = p.maxTabWidth) !== null && _a !== void 0 ? _a : '10rem',
|
|
5094
|
+
overflow: 'hidden'
|
|
5095
|
+
});
|
|
5096
|
+
}
|
|
5097
|
+
else {
|
|
5098
|
+
buttonVariant = active ? 'primary' : undefined;
|
|
5099
|
+
buttonStyles = css.css({
|
|
5100
|
+
paddingLeft: '1rem',
|
|
5101
|
+
paddingRight: '1rem',
|
|
5102
|
+
maxWidth: (_b = p.maxTabWidth) !== null && _b !== void 0 ? _b : '10rem',
|
|
5103
|
+
overflow: 'hidden',
|
|
5104
|
+
});
|
|
5105
|
+
}
|
|
5106
|
+
let title = tab.title;
|
|
5107
|
+
let buttonContent;
|
|
5108
|
+
if (typeof tab.name === 'string') {
|
|
5109
|
+
title !== null && title !== void 0 ? title : (title = tab.name);
|
|
5110
|
+
buttonContent = React__namespace.createElement(Text, { tag: "div", align: "center", ellipsis: true }, tab.name);
|
|
5111
|
+
}
|
|
5112
|
+
else {
|
|
5113
|
+
buttonContent = tab.name;
|
|
5114
|
+
}
|
|
5115
|
+
const tabId = getTabHeaderTabId(p.id, index);
|
|
5116
|
+
return (React__namespace.createElement("li", { key: index, className: css.cx(tabStyles, p.tabClassName) },
|
|
5117
|
+
React__namespace.createElement(Button, { id: tabId, tabIndex: active ? 0 : -1, role: "tab", "aria-controls": p.ariaControlsId, "aria-selected": active, disabled: tabsChanging, className: buttonStyles, variant: buttonVariant, title: title, readOnly: active, onClick: () => {
|
|
5118
|
+
onTabSelect(index, tabId, false);
|
|
5119
|
+
}, onKeyDown: e => {
|
|
5120
|
+
e.stopPropagation();
|
|
5121
|
+
let newIndex = index;
|
|
5122
|
+
if (e.code === 'ArrowLeft') {
|
|
5123
|
+
if (index === 0) {
|
|
5124
|
+
newIndex = p.tabs.length - 1;
|
|
5125
|
+
}
|
|
5126
|
+
else {
|
|
5127
|
+
newIndex = index - 1;
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
else if (e.code === 'ArrowRight') {
|
|
5131
|
+
if (index === p.tabs.length - 1) {
|
|
5132
|
+
newIndex = 0;
|
|
5133
|
+
}
|
|
5134
|
+
else {
|
|
5135
|
+
newIndex = index + 1;
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
if (newIndex !== index) {
|
|
5139
|
+
onTabSelect(newIndex, getTabHeaderTabId(p.id, newIndex), true);
|
|
5140
|
+
}
|
|
5141
|
+
} }, buttonContent)));
|
|
5142
|
+
})),
|
|
5143
|
+
variant === 'tab' && (React__namespace.createElement("div", { className: css.cx(css.css({
|
|
5144
|
+
label: 'TabHeaderDivider',
|
|
5145
|
+
borderBottom: theme.controls.border,
|
|
5146
|
+
marginTop: `calc(${theme.controls.borderWidth} * -1)`,
|
|
5147
|
+
zIndex: 2,
|
|
5148
|
+
position: 'relative'
|
|
5149
|
+
}), p.tabHeaderDividerClassName) }))));
|
|
5150
|
+
};
|
|
5151
|
+
function getTabHeaderTabId(tabHeaderId, tabIndex) {
|
|
5152
|
+
return `${tabHeaderId}_tab_${tabIndex}`;
|
|
5153
|
+
}
|
|
5154
|
+
|
|
5155
|
+
const TabContainer = (p) => {
|
|
5156
|
+
var _a;
|
|
5157
|
+
const [tabIndex, setTabIndex] = React__namespace.useState((_a = p.startingIndex) !== null && _a !== void 0 ? _a : 0);
|
|
5158
|
+
const theme = useThemeSafely();
|
|
5159
|
+
const tabPanelId = `${p.id}_tabpanel`;
|
|
5160
|
+
const tabHeaderId = `${p.id}_TabHeader`;
|
|
5161
|
+
return (React__namespace.createElement("div", { className: css.css({
|
|
5162
|
+
label: 'TabContainer'
|
|
5163
|
+
}) },
|
|
5164
|
+
React__namespace.createElement(TabHeader, { id: tabHeaderId, ariaControlsId: tabPanelId, ariaLabel: p.ariaLabel, tabs: p.tabs, maxTabWidth: p.maxTabWidth, variant: p.variant, containerClassName: p.tabHeaderClassName, tabClassName: p.tabClassName, tabHeaderDividerClassName: p.tabHeaderDividerClassName, startingIndex: tabIndex, onBeforeTabChanged: p.onBeforeTabChanged, onTabChanged: (newIndex) => {
|
|
5165
|
+
var _a;
|
|
5166
|
+
setTabIndex(newIndex);
|
|
5167
|
+
(_a = p.onTabChanged) === null || _a === void 0 ? void 0 : _a.call(p, newIndex);
|
|
5168
|
+
} }),
|
|
5169
|
+
React__namespace.createElement("div", { role: 'tabpanel', id: tabPanelId, "aria-labelledby": getTabHeaderTabId(tabHeaderId, tabIndex), className: css.cx(css.css({
|
|
5170
|
+
label: 'TabContainerContent',
|
|
5171
|
+
padding: '1rem',
|
|
5172
|
+
borderLeft: theme.controls.border,
|
|
5173
|
+
borderRight: theme.controls.border,
|
|
5174
|
+
borderBottom: theme.controls.border,
|
|
5175
|
+
}), p.contentClassName) }, p.tabs[tabIndex].getContent())));
|
|
5176
|
+
};
|
|
5177
|
+
|
|
5178
|
+
const TdCurrency = (props) => {
|
|
5179
|
+
let actualValue = props.value || 0;
|
|
5180
|
+
if (props.cents) {
|
|
5181
|
+
actualValue = actualValue / 100;
|
|
5182
|
+
}
|
|
5183
|
+
const displayValue = actualValue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
5184
|
+
return (React__namespace.createElement(Td, { align: "right" },
|
|
5185
|
+
"$",
|
|
5186
|
+
displayValue));
|
|
5187
|
+
};
|
|
5188
|
+
|
|
5189
|
+
const TdNumber = (props) => {
|
|
5190
|
+
return React__namespace.createElement(Td, { align: "right" }, props.value || props.value === 0 ? props.value.toLocaleString() : '');
|
|
5191
|
+
};
|
|
5192
|
+
|
|
5193
|
+
const ThSort = (props) => {
|
|
5194
|
+
let iconId = '';
|
|
5195
|
+
if (props.direction) {
|
|
5196
|
+
if (props.direction === 'asc') {
|
|
5197
|
+
iconId = 'sortAsc';
|
|
5198
|
+
}
|
|
5199
|
+
else {
|
|
5200
|
+
iconId = 'sortDesc';
|
|
5201
|
+
}
|
|
5112
5202
|
}
|
|
5113
|
-
|
|
5203
|
+
let rightContentSpecialJustify = 'center';
|
|
5204
|
+
switch (props.align) {
|
|
5205
|
+
case 'left':
|
|
5206
|
+
rightContentSpecialJustify = 'flex-start';
|
|
5207
|
+
break;
|
|
5208
|
+
case 'right':
|
|
5209
|
+
rightContentSpecialJustify = 'flex-end';
|
|
5210
|
+
break;
|
|
5211
|
+
}
|
|
5212
|
+
return (React__namespace.createElement(Th, { align: props.align, style: props.style, width: props.width },
|
|
5213
|
+
React__namespace.createElement("div", { className: props.rightContent && css.css({
|
|
5214
|
+
display: 'flex',
|
|
5215
|
+
alignItems: 'center',
|
|
5216
|
+
justifyContent: rightContentSpecialJustify,
|
|
5217
|
+
gap: '0.5rem'
|
|
5218
|
+
}) },
|
|
5219
|
+
React__namespace.createElement(Button, { onClick: props.onClick, variant: "link" },
|
|
5220
|
+
props.text,
|
|
5221
|
+
iconId && React__namespace.createElement(Icon, { className: css.css({
|
|
5222
|
+
marginLeft: '0.5rem'
|
|
5223
|
+
}), id: iconId })),
|
|
5224
|
+
props.rightContent)));
|
|
5114
5225
|
};
|
|
5115
5226
|
|
|
5116
|
-
const
|
|
5227
|
+
const defaultMaxLength = 200;
|
|
5228
|
+
const defaultRows = 10;
|
|
5229
|
+
const TextArea = React__namespace.forwardRef((props, ref) => {
|
|
5230
|
+
var _a, _b;
|
|
5231
|
+
const [localValue, setLocalValue] = React__namespace.useState(props.value);
|
|
5232
|
+
const inputRef = (ref !== null && ref !== void 0 ? ref : React__namespace.useRef(null));
|
|
5233
|
+
const [validationError, updateErrorMessage] = useInputValidationMessage(inputRef, props);
|
|
5117
5234
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5118
|
-
const {
|
|
5235
|
+
const { onValueChange, customError, reportValueOnError, showErrorDisplay, allowUpdateOnFocus } = props, nativeProps = __rest(props, ["onValueChange", "customError", "reportValueOnError", "showErrorDisplay", "allowUpdateOnFocus"]);
|
|
5119
5236
|
const theme = useThemeSafely();
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5237
|
+
React__namespace.useEffect(() => {
|
|
5238
|
+
updateErrorMessage();
|
|
5239
|
+
}, []);
|
|
5240
|
+
useIgnoreMount(() => {
|
|
5241
|
+
var _a;
|
|
5242
|
+
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity()) {
|
|
5243
|
+
onValueChange(localValue);
|
|
5244
|
+
}
|
|
5245
|
+
else {
|
|
5246
|
+
if (reportValueOnError) {
|
|
5247
|
+
onValueChange(localValue);
|
|
5131
5248
|
}
|
|
5132
5249
|
else {
|
|
5133
|
-
(
|
|
5134
|
-
}
|
|
5135
|
-
} }),
|
|
5136
|
-
React__namespace.createElement(LinkContent, Object.assign({}, props))));
|
|
5137
|
-
};
|
|
5138
|
-
|
|
5139
|
-
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
5140
|
-
const ThemeRenderer = (p) => {
|
|
5141
|
-
const { backgroundColor, color } = p, theme = __rest(p, ["backgroundColor", "color"]);
|
|
5142
|
-
const flatTheme = flatten(theme);
|
|
5143
|
-
const entries = lodash.orderBy(Object.entries(flatTheme), x => x[0]);
|
|
5144
|
-
return (React__namespace.createElement(Table, { caption: (React__namespace.createElement("div", null,
|
|
5145
|
-
React__namespace.createElement(Text, { tag: "h1", align: "center" }, "Theme"),
|
|
5146
|
-
React__namespace.createElement(Text, { tag: "p", align: "center", italics: true }, "Background color applied to show colors with alpha ('rgba(X, X, X, 0.X)')"))), className: css.css({
|
|
5147
|
-
backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : '#eee7ca',
|
|
5148
|
-
color: color !== null && color !== void 0 ? color : 'black'
|
|
5149
|
-
}) },
|
|
5150
|
-
React__namespace.createElement("thead", null,
|
|
5151
|
-
React__namespace.createElement(Tr, null,
|
|
5152
|
-
React__namespace.createElement(Th, { align: "left" }, "Property"),
|
|
5153
|
-
React__namespace.createElement(Th, { align: "left" }, "Value"))),
|
|
5154
|
-
React__namespace.createElement("tbody", null, entries.map(([key, value]) => {
|
|
5155
|
-
let colorBox;
|
|
5156
|
-
if (/color/i.test(key)) {
|
|
5157
|
-
colorBox = (React__namespace.createElement("span", { className: css.css({
|
|
5158
|
-
display: 'block',
|
|
5159
|
-
border: '1px solid black',
|
|
5160
|
-
width: '100%',
|
|
5161
|
-
height: 24,
|
|
5162
|
-
background: value
|
|
5163
|
-
}) }));
|
|
5250
|
+
onValueChange(undefined);
|
|
5164
5251
|
}
|
|
5165
|
-
return (React__namespace.createElement(Tr, { key: key },
|
|
5166
|
-
React__namespace.createElement(Td, { align: "left" }, key),
|
|
5167
|
-
React__namespace.createElement(Td, { align: "left" },
|
|
5168
|
-
React__namespace.createElement("div", { className: css.css({
|
|
5169
|
-
display: 'flex',
|
|
5170
|
-
alignItems: 'center',
|
|
5171
|
-
gap: '1rem'
|
|
5172
|
-
}) },
|
|
5173
|
-
React__namespace.createElement("span", { className: css.css({ flexShrink: 1 }) }, value),
|
|
5174
|
-
" ",
|
|
5175
|
-
colorBox))));
|
|
5176
|
-
}))));
|
|
5177
|
-
};
|
|
5178
|
-
const flatten = (obj, parent, path = 'theme') => {
|
|
5179
|
-
const flatObj = parent !== null && parent !== void 0 ? parent : {};
|
|
5180
|
-
for (const prop in obj) {
|
|
5181
|
-
const value = obj[prop];
|
|
5182
|
-
const fullPath = `${path}.${prop}`;
|
|
5183
|
-
if (typeof value !== 'object') {
|
|
5184
|
-
flatObj[fullPath] = value;
|
|
5185
5252
|
}
|
|
5186
|
-
|
|
5187
|
-
|
|
5253
|
+
updateErrorMessage();
|
|
5254
|
+
}, [localValue]);
|
|
5255
|
+
useIgnoreMount(() => {
|
|
5256
|
+
if (allowUpdateOnFocus || document.activeElement !== inputRef.current) {
|
|
5257
|
+
setLocalValue(props.value);
|
|
5188
5258
|
}
|
|
5259
|
+
updateErrorMessage();
|
|
5260
|
+
}, [props.value]);
|
|
5261
|
+
const styles = css.css({
|
|
5262
|
+
backgroundColor: theme.colors.bg,
|
|
5263
|
+
maxWidth: '100%',
|
|
5264
|
+
minHeight: theme.controls.height,
|
|
5265
|
+
fontFamily: theme.fonts.family,
|
|
5266
|
+
fontSize: theme.fonts.size,
|
|
5267
|
+
width: '100%',
|
|
5268
|
+
border: theme.controls.border,
|
|
5269
|
+
borderRadius: theme.controls.borderRadius,
|
|
5270
|
+
color: theme.colors.font,
|
|
5271
|
+
paddingTop: '0.75rem',
|
|
5272
|
+
paddingLeft: theme.controls.padding,
|
|
5273
|
+
paddingRight: theme.controls.padding,
|
|
5274
|
+
height: 'auto',
|
|
5275
|
+
transition: theme.controls.transition,
|
|
5276
|
+
':focus': {
|
|
5277
|
+
outline: 'none',
|
|
5278
|
+
boxShadow: theme.controls.focusOutlineShadow
|
|
5279
|
+
},
|
|
5280
|
+
':disabled': {
|
|
5281
|
+
backgroundColor: theme.colors.disabled,
|
|
5282
|
+
cursor: 'not-allowed'
|
|
5283
|
+
},
|
|
5284
|
+
':invalid': {
|
|
5285
|
+
borderColor: theme.colors.required,
|
|
5286
|
+
':focus': {
|
|
5287
|
+
boxShadow: theme.controls.focusOutlineRequiredShadow
|
|
5288
|
+
}
|
|
5289
|
+
},
|
|
5290
|
+
}, props.readOnly && {
|
|
5291
|
+
backgroundColor: 'transparent',
|
|
5292
|
+
cursor: 'default',
|
|
5293
|
+
border: 'none',
|
|
5294
|
+
':focus': {
|
|
5295
|
+
outline: 'none',
|
|
5296
|
+
boxShadow: 'none'
|
|
5297
|
+
}
|
|
5298
|
+
});
|
|
5299
|
+
return (React__namespace.createElement("span", { className: css.css({
|
|
5300
|
+
display: 'inline-block',
|
|
5301
|
+
width: '100%'
|
|
5302
|
+
}) },
|
|
5303
|
+
React__namespace.createElement("textarea", Object.assign({}, nativeProps, { className: css.cx(styles, props.className), autoComplete: (_a = props.autoComplete) !== null && _a !== void 0 ? _a : 'off', tabIndex: props.readOnly ? -1 : props.tabIndex, maxLength: props.maxLength || defaultMaxLength, rows: (_b = props.rows) !== null && _b !== void 0 ? _b : defaultRows, ref: inputRef, value: localValue !== null && localValue !== void 0 ? localValue : '', onChange: e => {
|
|
5304
|
+
var _a;
|
|
5305
|
+
setLocalValue(e.target.value || undefined);
|
|
5306
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
5307
|
+
}, onBlur: e => {
|
|
5308
|
+
var _a;
|
|
5309
|
+
if (!props.noTrim) {
|
|
5310
|
+
setLocalValue(currentValue => {
|
|
5311
|
+
return currentValue === null || currentValue === void 0 ? void 0 : currentValue.trim();
|
|
5312
|
+
});
|
|
5313
|
+
}
|
|
5314
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
5315
|
+
} })),
|
|
5316
|
+
(showErrorDisplay !== null && showErrorDisplay !== void 0 ? showErrorDisplay : true) && React__namespace.createElement(InputErrorDisplay, { error: validationError })));
|
|
5317
|
+
});
|
|
5318
|
+
|
|
5319
|
+
const ToggleButton = React__namespace.forwardRef((props, ref) => {
|
|
5320
|
+
const { checked, checkedChildren, uncheckedChildren, checkedVariant, checkedClassName, checkedStyle, checkedIcon, uncheckedIcon } = props, buttonProps = __rest(props, ["checked", "checkedChildren", "uncheckedChildren", "checkedVariant", "checkedClassName", "checkedStyle", "checkedIcon", "uncheckedIcon"]);
|
|
5321
|
+
let children;
|
|
5322
|
+
if (checked) {
|
|
5323
|
+
children = checkedChildren;
|
|
5189
5324
|
}
|
|
5190
|
-
|
|
5325
|
+
else {
|
|
5326
|
+
children = uncheckedChildren;
|
|
5327
|
+
}
|
|
5328
|
+
return (React__namespace.createElement(Button, Object.assign({}, buttonProps, { ref: ref, className: css.cx('toggleButton', checked && 'toggleButton--checked', props.className, checked && checkedClassName), rightIcon: checked ? checkedIcon : uncheckedIcon, variant: checked ? checkedVariant : props.variant, style: checked ? checkedStyle : props.style }), children));
|
|
5329
|
+
});
|
|
5330
|
+
|
|
5331
|
+
const ToggleButtonGroup = (props) => {
|
|
5332
|
+
const theme = useThemeSafely();
|
|
5333
|
+
const groupStyles = css.css `
|
|
5334
|
+
display: flex;
|
|
5335
|
+
box-shadow: ${theme.controls.buttonBoxShadow};
|
|
5336
|
+
border-radius: ${theme.controls.borderRadius};
|
|
5337
|
+
${props.round && `
|
|
5338
|
+
border-radius: ${theme.controls.roundRadius};
|
|
5339
|
+
`}
|
|
5340
|
+
`;
|
|
5341
|
+
const buttonStyles = css.css `
|
|
5342
|
+
flex-grow:1;
|
|
5343
|
+
box-shadow: none;
|
|
5344
|
+
&:nth-of-type(1n+2){
|
|
5345
|
+
margin-left: -1px;
|
|
5346
|
+
}
|
|
5347
|
+
border-radius: 0;
|
|
5348
|
+
&:first-of-type{
|
|
5349
|
+
border-top-left-radius: ${theme.controls.borderRadius};
|
|
5350
|
+
border-bottom-left-radius: ${theme.controls.borderRadius};
|
|
5351
|
+
}
|
|
5352
|
+
&:last-child {
|
|
5353
|
+
border-top-right-radius: ${theme.controls.borderRadius};
|
|
5354
|
+
border-bottom-right-radius: ${theme.controls.borderRadius};
|
|
5355
|
+
}
|
|
5356
|
+
${props.round && `
|
|
5357
|
+
&:first-of-type{
|
|
5358
|
+
border-top-left-radius: ${theme.controls.roundRadius};
|
|
5359
|
+
border-bottom-left-radius: ${theme.controls.roundRadius};
|
|
5360
|
+
padding-left: 1rem;
|
|
5361
|
+
}
|
|
5362
|
+
&:last-child {
|
|
5363
|
+
border-top-right-radius: ${theme.controls.roundRadius};
|
|
5364
|
+
border-bottom-right-radius: ${theme.controls.roundRadius};
|
|
5365
|
+
padding-right: 1rem;
|
|
5366
|
+
}
|
|
5367
|
+
`}
|
|
5368
|
+
`;
|
|
5369
|
+
return (React__namespace.createElement("div", { className: css.cx('toggleButtonGroup', groupStyles, props.className) }, props.options.map(o => {
|
|
5370
|
+
const active = o.id === props.value;
|
|
5371
|
+
return React__namespace.createElement(Button, { style: props.width ? { width: props.width } : undefined, small: props.small, rightIcon: o.rightIcon, key: o.id, tabIndex: active ? -1 : 0, className: css.cx(css.css `
|
|
5372
|
+
${buttonStyles}
|
|
5373
|
+
${active && `
|
|
5374
|
+
background-color: ${theme.colors.font};
|
|
5375
|
+
color: ${theme.colors.bg};
|
|
5376
|
+
cursor: default;
|
|
5377
|
+
&:hover:not(:disabled) {
|
|
5378
|
+
filter: none;
|
|
5379
|
+
}
|
|
5380
|
+
&:focus {
|
|
5381
|
+
outline: none;
|
|
5382
|
+
box-shadow: none;
|
|
5383
|
+
}
|
|
5384
|
+
`}
|
|
5385
|
+
`, active ? o.activeClass : undefined), disabled: props.disabled, enforceMinWidth: props.enforceMinWidth, onClick: () => {
|
|
5386
|
+
if (active) {
|
|
5387
|
+
return;
|
|
5388
|
+
}
|
|
5389
|
+
props.onChange(o.id);
|
|
5390
|
+
} }, o.name);
|
|
5391
|
+
})));
|
|
5191
5392
|
};
|
|
5192
5393
|
|
|
5193
|
-
const
|
|
5194
|
-
|
|
5195
|
-
const [
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
return (React__namespace.createElement(
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
} })
|
|
5207
|
-
|
|
5208
|
-
label: 'TabContainerContent',
|
|
5209
|
-
padding: '1rem',
|
|
5210
|
-
borderLeft: theme.controls.border,
|
|
5211
|
-
borderRight: theme.controls.border,
|
|
5212
|
-
borderBottom: theme.controls.border,
|
|
5213
|
-
}), p.contentClassName) }, p.tabs[tabIndex].getContent())));
|
|
5214
|
-
};
|
|
5394
|
+
const TogglePasswordInput = React__namespace.forwardRef((props, ref) => {
|
|
5395
|
+
const { onVisibilityChanged } = props, inputProps = __rest(props, ["onVisibilityChanged"]);
|
|
5396
|
+
const [show, setShow] = React__namespace.useState(false);
|
|
5397
|
+
useIgnoreMount(() => {
|
|
5398
|
+
onVisibilityChanged === null || onVisibilityChanged === void 0 ? void 0 : onVisibilityChanged(show);
|
|
5399
|
+
}, [show]);
|
|
5400
|
+
return (React__namespace.createElement(TextInput, Object.assign({}, inputProps, { ref: ref, type: show ? 'text' : 'password', rightControl: (React__namespace.createElement(Button, { small: true, style: {
|
|
5401
|
+
// small button is required here due to the icon pushing outside the boundries of the
|
|
5402
|
+
// parent textbox. increasing the font size here to fill the small button.
|
|
5403
|
+
fontSize: '1rem'
|
|
5404
|
+
}, variant: "icon", onClick: () => {
|
|
5405
|
+
setShow(previous => !previous);
|
|
5406
|
+
} },
|
|
5407
|
+
React__namespace.createElement(Icon, { id: show ? 'show' : 'hide' }))) })));
|
|
5408
|
+
});
|
|
5215
5409
|
|
|
5216
|
-
const
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
get value() {
|
|
5231
|
-
return this._value;
|
|
5232
|
-
}
|
|
5233
|
-
get options() {
|
|
5234
|
-
return this._options;
|
|
5235
|
-
}
|
|
5236
|
-
async onChange(newValue) {
|
|
5237
|
-
// don't make getOptions calls if the value hasn't changed.
|
|
5238
|
-
if (newValue === this.value) {
|
|
5239
|
-
return;
|
|
5240
|
-
}
|
|
5241
|
-
// nullish should not make the getOptions call and instead clear everything.
|
|
5242
|
-
if (!newValue) {
|
|
5243
|
-
this._value = newValue;
|
|
5244
|
-
this._options = [];
|
|
5245
|
-
return;
|
|
5246
|
-
}
|
|
5247
|
-
// sub min chars should clear everything and not attempt the getOptions call.
|
|
5248
|
-
if (newValue.length < this._minChars) {
|
|
5249
|
-
this._value = newValue;
|
|
5250
|
-
this._options = [];
|
|
5251
|
-
return;
|
|
5252
|
-
}
|
|
5253
|
-
try {
|
|
5254
|
-
this._value = newValue;
|
|
5255
|
-
this._options = (await this.getOptions(newValue));
|
|
5256
|
-
}
|
|
5257
|
-
catch (err) {
|
|
5258
|
-
// this method will throw errors on debounce rejections. that is to be expected.
|
|
5259
|
-
// for actual getOptions exceptions, the owner of that function will need to handle errors.
|
|
5260
|
-
}
|
|
5261
|
-
}
|
|
5262
|
-
onPick(newValue) {
|
|
5263
|
-
this._value = newValue;
|
|
5264
|
-
this._options = [];
|
|
5410
|
+
const WaitingIndicator = (p) => {
|
|
5411
|
+
var _a, _b, _c;
|
|
5412
|
+
const [show, setShow] = React.useState(p.show);
|
|
5413
|
+
const hideTimer = React.useRef(0);
|
|
5414
|
+
const lastShowStatus = React.useRef(false);
|
|
5415
|
+
const log = useLogger(`WaitingIndicator ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
5416
|
+
const { notify, clearNotification } = useAriaLiveRegion();
|
|
5417
|
+
if (p.__debug) {
|
|
5418
|
+
React.useEffect(() => {
|
|
5419
|
+
log('mounted');
|
|
5420
|
+
return () => {
|
|
5421
|
+
log('unmounted');
|
|
5422
|
+
};
|
|
5423
|
+
}, []);
|
|
5265
5424
|
}
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5425
|
+
React.useEffect(() => {
|
|
5426
|
+
log('show changed', p.show);
|
|
5427
|
+
// we need to store the 'last props' since props.show will be captured locally and the incorrect
|
|
5428
|
+
// value will display in the timeout below.
|
|
5429
|
+
log('storing lastShowStatus', p.show);
|
|
5430
|
+
lastShowStatus.current = p.show;
|
|
5431
|
+
if (p.show) {
|
|
5432
|
+
log('setShow', true);
|
|
5433
|
+
setShow(true);
|
|
5434
|
+
if (p.minShowTimeMs) {
|
|
5435
|
+
log('staring hideTimer', 'timout in ms:', p.minShowTimeMs);
|
|
5436
|
+
hideTimer.current = window.setTimeout(() => {
|
|
5437
|
+
log('hideTimer complete', 'clearing hideTimer');
|
|
5438
|
+
window.clearTimeout(hideTimer.current);
|
|
5439
|
+
hideTimer.current = 0;
|
|
5440
|
+
// this check is necessary since the show status may have updated again to true.
|
|
5441
|
+
// if so, ignore this timeout since we're already past the min time and we're still
|
|
5442
|
+
// showing the component.
|
|
5443
|
+
if (!lastShowStatus.current) {
|
|
5444
|
+
log('setShow', false);
|
|
5445
|
+
setShow(false);
|
|
5446
|
+
}
|
|
5447
|
+
else {
|
|
5448
|
+
log('ignoring hideTimer handler due to hideTimer ticking');
|
|
5449
|
+
}
|
|
5450
|
+
}, p.minShowTimeMs);
|
|
5451
|
+
}
|
|
5273
5452
|
}
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5453
|
+
else {
|
|
5454
|
+
// ignore hiding the component since the min timer is running.
|
|
5455
|
+
if (!hideTimer.current) {
|
|
5456
|
+
log('setShow', false);
|
|
5457
|
+
setShow(false);
|
|
5458
|
+
}
|
|
5459
|
+
else {
|
|
5460
|
+
log('ignoring show change due to hideTimer ticking');
|
|
5461
|
+
}
|
|
5277
5462
|
}
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
originalFunction(value)
|
|
5282
|
-
.then(values => {
|
|
5283
|
-
res(values);
|
|
5284
|
-
})
|
|
5285
|
-
.catch(err => {
|
|
5286
|
-
rej(err);
|
|
5287
|
-
})
|
|
5288
|
-
.finally(() => {
|
|
5289
|
-
clearTimeout(timer);
|
|
5290
|
-
});
|
|
5291
|
-
}, trailingTimeoutMs);
|
|
5292
|
-
});
|
|
5293
|
-
};
|
|
5294
|
-
};
|
|
5295
|
-
|
|
5296
|
-
/** Extracted logic around autocomplete functionality for Autocomplete.tsx that supports Entity (id/name) mapping. */
|
|
5297
|
-
class AutocompleteEntityController {
|
|
5298
|
-
constructor(getOptions, config) {
|
|
5299
|
-
this._options = [];
|
|
5300
|
-
const getStringOptions = async (value) => {
|
|
5301
|
-
this._options = await getOptions(value);
|
|
5302
|
-
return this._options.map(o => o.name);
|
|
5303
|
-
};
|
|
5304
|
-
this._ctrl = new AutocompleteController(getStringOptions, config);
|
|
5305
|
-
}
|
|
5306
|
-
get entity() {
|
|
5307
|
-
return this._pickedEntity;
|
|
5308
|
-
}
|
|
5309
|
-
get entities() {
|
|
5310
|
-
return this._options;
|
|
5311
|
-
}
|
|
5312
|
-
get value() {
|
|
5313
|
-
return this._ctrl.value;
|
|
5314
|
-
}
|
|
5315
|
-
get options() {
|
|
5316
|
-
return this._options.map(o => o.name);
|
|
5317
|
-
}
|
|
5318
|
-
async onChange(newValue) {
|
|
5319
|
-
const clearEntity = newValue !== this._ctrl.value;
|
|
5320
|
-
await this._ctrl.onChange(newValue);
|
|
5321
|
-
if (clearEntity) {
|
|
5322
|
-
this._pickedEntity = undefined;
|
|
5463
|
+
if (p.show) {
|
|
5464
|
+
// set to a very long time so the hiding of the waiting indicator clears it.
|
|
5465
|
+
notify('Loading content.', 60000);
|
|
5323
5466
|
}
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
onPick(newValue) {
|
|
5327
|
-
this._ctrl.onPick(newValue);
|
|
5328
|
-
this._pickedEntity = this._options.find(o => o.name === this._ctrl.value);
|
|
5329
|
-
this.trySyncCtrlOptions();
|
|
5330
|
-
}
|
|
5331
|
-
trySyncCtrlOptions() {
|
|
5332
|
-
if (!this._ctrl.options.length) {
|
|
5333
|
-
this._options = [];
|
|
5467
|
+
else {
|
|
5468
|
+
clearNotification();
|
|
5334
5469
|
}
|
|
5335
|
-
}
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
getText: (text) => {
|
|
5347
|
-
if (!text) {
|
|
5348
|
-
return '';
|
|
5349
|
-
}
|
|
5350
|
-
if (!isNaN(parseInt(text))) {
|
|
5351
|
-
return text;
|
|
5352
|
-
}
|
|
5353
|
-
const wordArray = stringsDb[text];
|
|
5354
|
-
if (!wordArray) {
|
|
5355
|
-
log(`No localization data exists for "${text}".`);
|
|
5356
|
-
}
|
|
5357
|
-
if (p.language === exports.StyleGuideLanguage.English) {
|
|
5358
|
-
return text;
|
|
5359
|
-
}
|
|
5360
|
-
const languageIndex = p.language - 1;
|
|
5361
|
-
const translation = wordArray === null || wordArray === void 0 ? void 0 : wordArray[languageIndex];
|
|
5362
|
-
if (translation) {
|
|
5363
|
-
return translation;
|
|
5364
|
-
}
|
|
5365
|
-
log(`No ${exports.StyleGuideLanguage[p.language]} translations exist for "${text}".`);
|
|
5366
|
-
return text;
|
|
5367
|
-
}
|
|
5368
|
-
} }, p.children));
|
|
5470
|
+
}, [p.show]);
|
|
5471
|
+
const id = (_c = p.id) !== null && _c !== void 0 ? _c : 'MknWaitingIndicator';
|
|
5472
|
+
return (React.createElement(Modal, { id: id, __debug: p.__debug, __asWaitingIndicator: true, heading: '', onClose: () => {
|
|
5473
|
+
/* noop */
|
|
5474
|
+
}, className: "waitingIndicator", show: show },
|
|
5475
|
+
React.createElement("div", { className: css.css({
|
|
5476
|
+
color: 'white',
|
|
5477
|
+
fontSize: '3rem',
|
|
5478
|
+
padding: '0.7rem'
|
|
5479
|
+
}) },
|
|
5480
|
+
React.createElement(Icon, { id: "waiting", spin: true }))));
|
|
5369
5481
|
};
|
|
5370
5482
|
|
|
5371
5483
|
exports.Accordion = Accordion;
|
|
@@ -5404,6 +5516,7 @@ exports.List = List;
|
|
|
5404
5516
|
exports.ListItem = ListItem;
|
|
5405
5517
|
exports.LocalizationProvider = LocalizationProvider;
|
|
5406
5518
|
exports.Modal = Modal;
|
|
5519
|
+
exports.MultiPicker = MultiPicker;
|
|
5407
5520
|
exports.Nav = Nav;
|
|
5408
5521
|
exports.NormalizeCss = NormalizeCss;
|
|
5409
5522
|
exports.NumberInput = NumberInput;
|