@auth0/quantum-product 2.10.2 → 2.10.4

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.
Files changed (55) hide show
  1. package/command-palette/command-palette-classes.d.ts +5 -0
  2. package/command-palette/command-palette-classes.js +34 -0
  3. package/command-palette/command-palette-context.d.ts +8 -0
  4. package/command-palette/command-palette-context.js +93 -0
  5. package/command-palette/command-palette-dialog.d.ts +3 -0
  6. package/command-palette/command-palette-dialog.js +112 -0
  7. package/command-palette/command-palette-empty.d.ts +3 -0
  8. package/command-palette/command-palette-empty.js +90 -0
  9. package/command-palette/command-palette-footer.d.ts +4 -0
  10. package/command-palette/command-palette-footer.js +111 -0
  11. package/command-palette/command-palette-group.d.ts +3 -0
  12. package/command-palette/command-palette-group.js +119 -0
  13. package/command-palette/command-palette-input.d.ts +3 -0
  14. package/command-palette/command-palette-input.js +144 -0
  15. package/command-palette/command-palette-item.d.ts +3 -0
  16. package/command-palette/command-palette-item.js +243 -0
  17. package/command-palette/command-palette-list.d.ts +3 -0
  18. package/command-palette/command-palette-list.js +101 -0
  19. package/command-palette/command-palette-loading.d.ts +3 -0
  20. package/command-palette/command-palette-loading.js +89 -0
  21. package/command-palette/command-palette-score.d.ts +1 -0
  22. package/command-palette/command-palette-score.js +47 -0
  23. package/command-palette/command-palette-separator.d.ts +3 -0
  24. package/command-palette/command-palette-separator.js +86 -0
  25. package/command-palette/command-palette-tabs.d.ts +4 -0
  26. package/command-palette/command-palette-tabs.js +146 -0
  27. package/command-palette/command-palette-types.d.ts +121 -0
  28. package/command-palette/command-palette-types.js +2 -0
  29. package/command-palette/command-palette.d.ts +5 -0
  30. package/command-palette/command-palette.js +477 -0
  31. package/command-palette/index.d.ts +27 -0
  32. package/command-palette/index.js +36 -0
  33. package/command-palette/use-command-palette-shortcut.d.ts +6 -0
  34. package/command-palette/use-command-palette-shortcut.js +65 -0
  35. package/esm/command-palette/command-palette-classes.js +30 -0
  36. package/esm/command-palette/command-palette-context.js +54 -0
  37. package/esm/command-palette/command-palette-dialog.js +73 -0
  38. package/esm/command-palette/command-palette-empty.js +51 -0
  39. package/esm/command-palette/command-palette-footer.js +72 -0
  40. package/esm/command-palette/command-palette-group.js +80 -0
  41. package/esm/command-palette/command-palette-input.js +105 -0
  42. package/esm/command-palette/command-palette-item.js +204 -0
  43. package/esm/command-palette/command-palette-list.js +62 -0
  44. package/esm/command-palette/command-palette-loading.js +50 -0
  45. package/esm/command-palette/command-palette-score.js +44 -0
  46. package/esm/command-palette/command-palette-separator.js +47 -0
  47. package/esm/command-palette/command-palette-tabs.js +107 -0
  48. package/esm/command-palette/command-palette-types.js +1 -0
  49. package/esm/command-palette/command-palette.js +438 -0
  50. package/esm/command-palette/index.js +14 -0
  51. package/esm/command-palette/use-command-palette-shortcut.js +29 -0
  52. package/esm/index.js +1 -0
  53. package/index.d.ts +1 -0
  54. package/index.js +1 -0
  55. package/package.json +1 -1
@@ -0,0 +1,62 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import * as React from 'react';
24
+ import { styled } from '../styled';
25
+ import clsx from '../utils/clsx';
26
+ import { commandPaletteClasses, commandPaletteComponentName } from './command-palette-classes';
27
+ import { useCommandPaletteContext } from './command-palette-context';
28
+ var Root = styled('div', {
29
+ name: commandPaletteComponentName,
30
+ slot: 'List',
31
+ })(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ height: theme.typography.pxToRem(300),
35
+ overflow: 'auto',
36
+ outline: 'none',
37
+ overscrollBehavior: 'contain',
38
+ scrollbarWidth: 'thin',
39
+ scrollbarColor: "".concat(theme.tokens.color_border_default, " transparent"),
40
+ '&::-webkit-scrollbar': {
41
+ width: 6,
42
+ },
43
+ '&::-webkit-scrollbar-track': {
44
+ background: 'transparent',
45
+ },
46
+ '&::-webkit-scrollbar-thumb': {
47
+ backgroundColor: theme.tokens.color_border_default,
48
+ borderRadius: 3,
49
+ },
50
+ });
51
+ });
52
+ var Inner = styled('div', {
53
+ name: commandPaletteComponentName,
54
+ slot: 'ListInner',
55
+ })(function () { return ({}); });
56
+ export var CommandPaletteList = React.forwardRef(function (props, ref) {
57
+ var children = props.children, className = props.className, style = props.style, listProps = __rest(props, ["children", "className", "style"]);
58
+ var context = useCommandPaletteContext();
59
+ return (React.createElement(Root, __assign({ ref: ref, id: context.listId, role: "listbox", "aria-label": "Suggestions", className: clsx(commandPaletteClasses.list, className), style: style }, listProps),
60
+ React.createElement(Inner, { ref: context.listInnerRef }, children)));
61
+ });
62
+ CommandPaletteList.displayName = 'CommandPaletteList';
@@ -0,0 +1,50 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import * as React from 'react';
24
+ import { Spinner } from '../spinner';
25
+ import { styled } from '../styled';
26
+ import clsx from '../utils/clsx';
27
+ import { commandPaletteClasses, commandPaletteComponentName } from './command-palette-classes';
28
+ var Root = styled('div', {
29
+ name: commandPaletteComponentName,
30
+ slot: 'Loading',
31
+ })(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ display: 'flex',
35
+ flexDirection: 'row',
36
+ alignItems: 'center',
37
+ width: '100%',
38
+ gap: theme.spacing(1.5),
39
+ padding: theme.spacing(2),
40
+ color: theme.tokens.color_fg_disabled,
41
+ fontSize: theme.typography.caption.fontSize,
42
+ });
43
+ });
44
+ export var CommandPaletteLoading = React.forwardRef(function (props, ref) {
45
+ var _a = props.progress, progress = _a === void 0 ? 0 : _a, _b = props.children, children = _b === void 0 ? 'Loading...' : _b, className = props.className, loadingProps = __rest(props, ["progress", "children", "className"]);
46
+ return (React.createElement(Root, __assign({ ref: ref, role: "progressbar", "aria-valuenow": progress, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": "Loading results", className: clsx(commandPaletteClasses.loading, className) }, loadingProps),
47
+ React.createElement(Spinner, null),
48
+ children));
49
+ });
50
+ CommandPaletteLoading.displayName = 'CommandPaletteLoading';
@@ -0,0 +1,44 @@
1
+ export function commandScore(value, search) {
2
+ if (search.length === 0)
3
+ return 1;
4
+ if (value.length === 0)
5
+ return 0;
6
+ var lowerValue = value.toLowerCase();
7
+ var lowerSearch = search.toLowerCase();
8
+ if (lowerValue === lowerSearch)
9
+ return 1;
10
+ if (lowerValue.includes(lowerSearch)) {
11
+ if (lowerValue.startsWith(lowerSearch)) {
12
+ return 0.9;
13
+ }
14
+ return 0.7;
15
+ }
16
+ var searchIdx = 0;
17
+ var score = 0;
18
+ var consecutive = 0;
19
+ var prevMatchIdx = -2;
20
+ for (var i = 0; i < lowerValue.length && searchIdx < lowerSearch.length; i++) {
21
+ if (lowerValue[i] === lowerSearch[searchIdx]) {
22
+ if (i === prevMatchIdx + 1) {
23
+ consecutive++;
24
+ score += consecutive * 2;
25
+ }
26
+ else {
27
+ consecutive = 1;
28
+ score += 1;
29
+ }
30
+ if (i === 0 || /[\s\-_./]/.test(value[i - 1])) {
31
+ score += 3;
32
+ }
33
+ if (i > 0 && value[i] === value[i].toUpperCase() && value[i - 1] === value[i - 1].toLowerCase()) {
34
+ score += 2;
35
+ }
36
+ prevMatchIdx = i;
37
+ searchIdx++;
38
+ }
39
+ }
40
+ if (searchIdx < lowerSearch.length)
41
+ return 0;
42
+ var maxPossibleScore = lowerSearch.length * 6;
43
+ return Math.min(score / maxPossibleScore, 0.6);
44
+ }
@@ -0,0 +1,47 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import * as React from 'react';
24
+ import { styled } from '../styled';
25
+ import clsx from '../utils/clsx';
26
+ import { commandPaletteClasses, commandPaletteComponentName } from './command-palette-classes';
27
+ import { useCommandPaletteState } from './command-palette-context';
28
+ var Root = styled('div', {
29
+ name: commandPaletteComponentName,
30
+ slot: 'Separator',
31
+ })(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ height: 1,
35
+ margin: "".concat(theme.spacing(0), " ").concat(theme.spacing(1.5)),
36
+ backgroundColor: theme.tokens.color_border_default,
37
+ });
38
+ });
39
+ export var CommandPaletteSeparator = React.forwardRef(function (props, ref) {
40
+ var _a = props.alwaysRender, alwaysRender = _a === void 0 ? false : _a, className = props.className, separatorProps = __rest(props, ["alwaysRender", "className"]);
41
+ var search = useCommandPaletteState(function (state) { return state.search; });
42
+ var isSearching = search.length > 0;
43
+ if (!alwaysRender && isSearching)
44
+ return null;
45
+ return (React.createElement(Root, __assign({ ref: ref, role: "separator", className: clsx(commandPaletteClasses.separator, className) }, separatorProps)));
46
+ });
47
+ CommandPaletteSeparator.displayName = 'CommandPaletteSeparator';
@@ -0,0 +1,107 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import * as React from 'react';
24
+ import useForkRef from '@mui/utils/useForkRef';
25
+ import { styled } from '../styled';
26
+ import clsx from '../utils/clsx';
27
+ import { commandPaletteClasses, commandPaletteComponentName } from './command-palette-classes';
28
+ var Root = styled('div', {
29
+ name: commandPaletteComponentName,
30
+ slot: 'Tabs',
31
+ })(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ display: 'flex',
35
+ alignItems: 'center',
36
+ gap: theme.spacing(0.5),
37
+ padding: "".concat(theme.spacing(1), " ").concat(theme.spacing(2)),
38
+ overflowX: 'auto',
39
+ scrollbarWidth: 'none',
40
+ '&::-webkit-scrollbar': {
41
+ display: 'none',
42
+ },
43
+ });
44
+ });
45
+ var TabButton = styled('button', {
46
+ name: commandPaletteComponentName,
47
+ slot: 'Tab',
48
+ })(function (_a) {
49
+ var theme = _a.theme, ownerState = _a.ownerState;
50
+ return (__assign(__assign(__assign({ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', padding: "".concat(theme.spacing(0.5), " ").concat(theme.spacing(1.5)), borderRadius: theme.spacing(1), border: 'none', cursor: 'pointer', fontSize: theme.typography.caption.fontSize, fontWeight: theme.typography.fontWeightSemibold, fontFamily: theme.typography.caption.fontFamily, lineHeight: theme.typography.caption.lineHeight, whiteSpace: 'nowrap', userSelect: 'none', transition: theme.transitions.create(['background-color', 'color'], {
51
+ duration: theme.transitions.duration.shortest,
52
+ }), color: theme.tokens.color_fg_disabled, backgroundColor: 'transparent' }, (ownerState.active && {
53
+ color: theme.tokens.color_fg_default,
54
+ backgroundColor: theme.tokens.color_bg_state_neutral_subtle,
55
+ })), (!ownerState.active && {
56
+ '&:hover': {
57
+ backgroundColor: theme.tokens.color_bg_interactive_hover,
58
+ },
59
+ })), { '&:focus-visible': {
60
+ outline: 'none',
61
+ backgroundColor: theme.tokens.color_bg_interactive_hover,
62
+ } }));
63
+ });
64
+ export var CommandPaletteTabs = React.forwardRef(function (props, ref) {
65
+ var children = props.children, className = props.className, tabsProps = __rest(props, ["children", "className"]);
66
+ var tabsRef = React.useRef(null);
67
+ var handleKeyDown = React.useCallback(function (e) {
68
+ var tabs = tabsRef.current;
69
+ if (!tabs)
70
+ return;
71
+ var tabButtons = Array.from(tabs.querySelectorAll('[role="tab"]'));
72
+ var focused = document.activeElement;
73
+ var currentIndex = tabButtons.indexOf(focused);
74
+ if (currentIndex === -1)
75
+ return;
76
+ var nextIndex = null;
77
+ if (e.key === 'ArrowRight') {
78
+ nextIndex = currentIndex < tabButtons.length - 1 ? currentIndex + 1 : 0;
79
+ }
80
+ else if (e.key === 'ArrowLeft') {
81
+ nextIndex = currentIndex > 0 ? currentIndex - 1 : tabButtons.length - 1;
82
+ }
83
+ else if (e.key === 'Home') {
84
+ nextIndex = 0;
85
+ }
86
+ else if (e.key === 'End') {
87
+ nextIndex = tabButtons.length - 1;
88
+ }
89
+ if (nextIndex !== null) {
90
+ e.preventDefault();
91
+ tabButtons[nextIndex].focus();
92
+ tabButtons[nextIndex].click();
93
+ }
94
+ }, []);
95
+ var mergedRef = useForkRef(tabsRef, ref);
96
+ return (React.createElement(Root, __assign({ ref: mergedRef, role: "tablist", className: clsx(commandPaletteClasses.tabs, className), onKeyDown: handleKeyDown }, tabsProps), children));
97
+ });
98
+ CommandPaletteTabs.displayName = 'CommandPaletteTabs';
99
+ export var CommandPaletteTab = React.forwardRef(function (props, ref) {
100
+ var _a = props.active, active = _a === void 0 ? false : _a, onSelect = props.onSelect, children = props.children, className = props.className, onClick = props.onClick, tabProps = __rest(props, ["active", "onSelect", "children", "className", "onClick"]);
101
+ var handleClick = React.useCallback(function (e) {
102
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
103
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
104
+ }, [onSelect, onClick]);
105
+ return (React.createElement(TabButton, __assign({ ref: ref, role: "tab", type: "button", "aria-selected": active, tabIndex: active ? 0 : -1, ownerState: { active: active }, className: clsx(commandPaletteClasses.tab, active && commandPaletteClasses.tabSelected, className), onClick: handleClick }, tabProps), children));
106
+ });
107
+ CommandPaletteTab.displayName = 'CommandPaletteTab';
@@ -0,0 +1 @@
1
+ export {};