@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,144 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.CommandPaletteInput = void 0;
62
+ var React = __importStar(require("react"));
63
+ var icon_1 = require("../icon");
64
+ var styled_1 = require("../styled");
65
+ var clsx_1 = __importDefault(require("../utils/clsx"));
66
+ var command_palette_classes_1 = require("./command-palette-classes");
67
+ var command_palette_context_1 = require("./command-palette-context");
68
+ var Wrapper = (0, styled_1.styled)('div', {
69
+ name: command_palette_classes_1.commandPaletteComponentName,
70
+ slot: 'InputWrapper',
71
+ })(function (_a) {
72
+ var theme = _a.theme;
73
+ return ({
74
+ display: 'flex',
75
+ alignItems: 'center',
76
+ gap: theme.spacing(1.5),
77
+ padding: "".concat(theme.spacing(1.5), " ").concat(theme.spacing(2)),
78
+ });
79
+ });
80
+ var IconWrapper = (0, styled_1.styled)('div', {
81
+ name: command_palette_classes_1.commandPaletteComponentName,
82
+ slot: 'InputIcon',
83
+ })(function (_a) {
84
+ var theme = _a.theme;
85
+ return ({
86
+ display: 'flex',
87
+ alignItems: 'center',
88
+ justifyContent: 'center',
89
+ flexShrink: 0,
90
+ color: theme.tokens.color_fg_disabled,
91
+ '& svg': {
92
+ width: theme.typography.pxToRem(20),
93
+ height: theme.typography.pxToRem(20),
94
+ },
95
+ });
96
+ });
97
+ var InputElement = (0, styled_1.styled)('input', {
98
+ name: command_palette_classes_1.commandPaletteComponentName,
99
+ slot: 'Input',
100
+ })(function (_a) {
101
+ var theme = _a.theme;
102
+ return ({
103
+ flex: 1,
104
+ border: 'none',
105
+ outline: 'none',
106
+ backgroundColor: 'transparent',
107
+ color: theme.tokens.color_fg_default,
108
+ fontSize: theme.typography.body1.fontSize,
109
+ lineHeight: theme.typography.body1.lineHeight,
110
+ fontFamily: theme.typography.fontFamily,
111
+ caretColor: theme.tokens.color_fg_brand_primary,
112
+ '&::placeholder': {
113
+ color: theme.tokens.color_fg_disabled,
114
+ },
115
+ width: '100%',
116
+ padding: 0,
117
+ margin: 0,
118
+ });
119
+ });
120
+ exports.CommandPaletteInput = React.forwardRef(function (props, ref) {
121
+ var _a = props.icon, icon = _a === void 0 ? React.createElement(icon_1.SearchIcon, { size: 20 }) : _a, _b = props.placeholder, placeholder = _b === void 0 ? 'Search for commands...' : _b, onValueChange = props.onValueChange, className = props.className, inputProps = __rest(props, ["icon", "placeholder", "onValueChange", "className"]);
122
+ var context = (0, command_palette_context_1.useCommandPaletteContext)();
123
+ var store = (0, command_palette_context_1.useCommandPaletteStore)();
124
+ var search = (0, command_palette_context_1.useCommandPaletteState)(function (state) { return state.search; });
125
+ var isComposing = React.useRef(false);
126
+ var handleChange = React.useCallback(function (e) {
127
+ if (!isComposing.current) {
128
+ store.setState('search', e.target.value);
129
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(e.target.value);
130
+ }
131
+ }, [store, onValueChange]);
132
+ var handleCompositionStart = React.useCallback(function () {
133
+ isComposing.current = true;
134
+ }, []);
135
+ var handleCompositionEnd = React.useCallback(function (e) {
136
+ isComposing.current = false;
137
+ store.setState('search', e.target.value);
138
+ onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(e.target.value);
139
+ }, [store, onValueChange]);
140
+ return (React.createElement(Wrapper, { className: (0, clsx_1.default)(command_palette_classes_1.commandPaletteClasses.inputWrapper, className) },
141
+ icon && React.createElement(IconWrapper, { className: command_palette_classes_1.commandPaletteClasses.inputIcon }, icon),
142
+ React.createElement(InputElement, __assign({ ref: ref, id: context.inputId, className: command_palette_classes_1.commandPaletteClasses.input, type: "text", role: "combobox", "aria-expanded": true, "aria-controls": context.listId, "aria-label": placeholder, "aria-autocomplete": "list", autoComplete: "off", autoCorrect: "off", spellCheck: false, placeholder: placeholder, value: search, onChange: handleChange, onCompositionStart: handleCompositionStart, onCompositionEnd: handleCompositionEnd }, inputProps))));
143
+ });
144
+ exports.CommandPaletteInput.displayName = 'CommandPaletteInput';
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { ICommandPaletteItemProps } from './command-palette-types';
3
+ export declare const CommandPaletteItem: React.ForwardRefExoticComponent<ICommandPaletteItemProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ var __read = (this && this.__read) || function (o, n) {
58
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
59
+ if (!m) return o;
60
+ var i = m.call(o), r, ar = [], e;
61
+ try {
62
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
63
+ }
64
+ catch (error) { e = { error: error }; }
65
+ finally {
66
+ try {
67
+ if (r && !r.done && (m = i["return"])) m.call(i);
68
+ }
69
+ finally { if (e) throw e.error; }
70
+ }
71
+ return ar;
72
+ };
73
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
74
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
75
+ if (ar || !(i in from)) {
76
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
77
+ ar[i] = from[i];
78
+ }
79
+ }
80
+ return to.concat(ar || Array.prototype.slice.call(from));
81
+ };
82
+ var __importDefault = (this && this.__importDefault) || function (mod) {
83
+ return (mod && mod.__esModule) ? mod : { "default": mod };
84
+ };
85
+ Object.defineProperty(exports, "__esModule", { value: true });
86
+ exports.CommandPaletteItem = void 0;
87
+ var React = __importStar(require("react"));
88
+ var useForkRef_1 = __importDefault(require("@mui/utils/useForkRef"));
89
+ var styled_1 = require("../styled");
90
+ var clsx_1 = __importDefault(require("../utils/clsx"));
91
+ var use_id_1 = require("../utils/use-id");
92
+ var command_palette_1 = require("./command-palette");
93
+ var command_palette_classes_1 = require("./command-palette-classes");
94
+ var command_palette_context_1 = require("./command-palette-context");
95
+ var Root = (0, styled_1.styled)('div', {
96
+ name: command_palette_classes_1.commandPaletteComponentName,
97
+ slot: 'Item',
98
+ })(function (_a) {
99
+ var theme = _a.theme, ownerState = _a.ownerState;
100
+ return (__assign(__assign(__assign(__assign({ display: 'flex', alignItems: 'center', gap: theme.spacing(1.5), padding: "".concat(theme.spacing(1), " ").concat(theme.spacing(1.5)), borderRadius: theme.spacing(1), cursor: 'pointer', userSelect: 'none', fontSize: theme.typography.body2.fontSize, fontWeight: theme.typography.fontWeightMedium, lineHeight: theme.typography.body2.lineHeight, color: theme.tokens.color_fg_default, transition: theme.transitions.create(['background-color', 'color'], {
101
+ duration: theme.transitions.duration.shortest,
102
+ }) }, (ownerState.isSelected && {
103
+ backgroundColor: theme.tokens.color_bg_interactive_hover,
104
+ })), (ownerState.disabled && {
105
+ opacity: 0.5,
106
+ cursor: 'not-allowed',
107
+ })), (!ownerState.disabled &&
108
+ !ownerState.isSelected && {
109
+ '&:hover': {
110
+ backgroundColor: theme.tokens.color_bg_interactive_hover,
111
+ },
112
+ })), { '&[aria-disabled="true"]': {
113
+ opacity: 0.5,
114
+ cursor: 'not-allowed',
115
+ } }));
116
+ });
117
+ var ItemIcon = (0, styled_1.styled)('div', {
118
+ name: command_palette_classes_1.commandPaletteComponentName,
119
+ slot: 'ItemIcon',
120
+ })(function (_a) {
121
+ var theme = _a.theme;
122
+ return ({
123
+ display: 'flex',
124
+ alignItems: 'center',
125
+ justifyContent: 'center',
126
+ flexShrink: 0,
127
+ color: theme.tokens.color_fg_disabled,
128
+ '& svg': {
129
+ width: theme.typography.pxToRem(18),
130
+ height: theme.typography.pxToRem(18),
131
+ },
132
+ });
133
+ });
134
+ var ItemLabel = (0, styled_1.styled)('span', {
135
+ name: command_palette_classes_1.commandPaletteComponentName,
136
+ slot: 'ItemLabel',
137
+ })(function () { return ({
138
+ flex: 1,
139
+ overflow: 'hidden',
140
+ textOverflow: 'ellipsis',
141
+ whiteSpace: 'nowrap',
142
+ }); });
143
+ var ItemShortcut = (0, styled_1.styled)('span', {
144
+ name: command_palette_classes_1.commandPaletteComponentName,
145
+ slot: 'ItemShortcut',
146
+ })(function (_a) {
147
+ var theme = _a.theme;
148
+ return ({
149
+ display: 'flex',
150
+ alignItems: 'center',
151
+ gap: theme.spacing(0.5),
152
+ flexShrink: 0,
153
+ marginLeft: 'auto',
154
+ });
155
+ });
156
+ var Kbd = (0, styled_1.styled)('kbd', {
157
+ name: command_palette_classes_1.commandPaletteComponentName,
158
+ slot: 'Kbd',
159
+ })(function (_a) {
160
+ var theme = _a.theme;
161
+ return ({
162
+ display: 'inline-flex',
163
+ alignItems: 'center',
164
+ justifyContent: 'center',
165
+ minWidth: theme.typography.pxToRem(22),
166
+ height: theme.typography.pxToRem(22),
167
+ padding: "0 ".concat(theme.spacing(0.5)),
168
+ borderRadius: theme.typography.pxToRem(4),
169
+ backgroundColor: theme.tokens.color_bg_state_neutral_subtle,
170
+ border: "1px solid ".concat(theme.tokens.color_border_default),
171
+ color: theme.tokens.color_fg_disabled,
172
+ fontSize: theme.typography.overline.fontSize,
173
+ fontFamily: theme.typography.fontFamily,
174
+ lineHeight: 1,
175
+ });
176
+ });
177
+ function deriveValue(valueProp, children, el) {
178
+ var _a;
179
+ if (valueProp)
180
+ return valueProp;
181
+ if (typeof children === 'string')
182
+ return children.trim().toLowerCase();
183
+ if (typeof children === 'number')
184
+ return String(children);
185
+ return ((_a = el === null || el === void 0 ? void 0 : el.textContent) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) || '';
186
+ }
187
+ function useValue(id, ref, deps) {
188
+ var initialValue = deriveValue(deps[0], deps[2], null);
189
+ var valueRef = React.useRef(initialValue);
190
+ var context = (0, command_palette_context_1.useCommandPaletteContext)();
191
+ React.useLayoutEffect(function () {
192
+ var value = deriveValue(deps[0], deps[2], ref.current);
193
+ valueRef.current = value;
194
+ context.value(id, value, deps[1]);
195
+ // eslint-disable-next-line react-hooks/exhaustive-deps
196
+ }, __spreadArray([id], __read(deps), false));
197
+ return valueRef.current;
198
+ }
199
+ exports.CommandPaletteItem = React.forwardRef(function (props, ref) {
200
+ var _a;
201
+ var _b, _c;
202
+ var valueProp = props.value, keywords = props.keywords, _d = props.disabled, disabled = _d === void 0 ? false : _d, onSelect = props.onSelect, _e = props.forceMount, forceMount = _e === void 0 ? false : _e, icon = props.icon, shortcut = props.shortcut, children = props.children, className = props.className, itemProps = __rest(props, ["value", "keywords", "disabled", "onSelect", "forceMount", "icon", "shortcut", "children", "className"]);
203
+ var generatedId = (0, use_id_1.useId)();
204
+ var idRef = React.useRef();
205
+ if (!idRef.current) {
206
+ idRef.current =
207
+ (_c = (_b = itemProps.id) !== null && _b !== void 0 ? _b : generatedId) !== null && _c !== void 0 ? _c : "command-palette-item-".concat(Math.random().toString(36).slice(2));
208
+ }
209
+ var id = idRef.current;
210
+ var itemRef = React.useRef(null);
211
+ var context = (0, command_palette_context_1.useCommandPaletteContext)();
212
+ var store = (0, command_palette_context_1.useCommandPaletteStore)();
213
+ var groupId = React.useContext(command_palette_context_1.CommandPaletteGroupContext);
214
+ var itemValue = useValue(id, itemRef, [valueProp, keywords, children]);
215
+ var selectedValue = (0, command_palette_context_1.useCommandPaletteState)(function (state) { return state.selectedValue; });
216
+ var isSelected = selectedValue === itemValue && itemValue !== '';
217
+ var filteredState = (0, command_palette_context_1.useCommandPaletteState)(function (state) { return state.filtered; });
218
+ var score = filteredState.items.get(id);
219
+ var isVisible = forceMount || context.filter === false || score === undefined || score > 0;
220
+ React.useLayoutEffect(function () {
221
+ var cleanup = context.item(id, groupId);
222
+ return cleanup;
223
+ }, [context, id, groupId]);
224
+ var handlePointerMove = React.useCallback(function () {
225
+ if (!disabled && itemValue) {
226
+ store.setState('selectedValue', itemValue);
227
+ }
228
+ }, [disabled, itemValue, store]);
229
+ var handleClick = React.useCallback(function () {
230
+ if (!disabled) {
231
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(itemValue);
232
+ }
233
+ }, [disabled, onSelect, itemValue]);
234
+ var mergedRef = (0, useForkRef_1.default)(itemRef, ref);
235
+ var shortcutKeys = shortcut ? (Array.isArray(shortcut) ? shortcut : shortcut.split('+')) : null;
236
+ if (!isVisible)
237
+ return null;
238
+ return (React.createElement(Root, __assign((_a = { ref: mergedRef, ownerState: { isSelected: isSelected, disabled: disabled }, className: (0, clsx_1.default)(command_palette_classes_1.commandPaletteClasses.item, isSelected && command_palette_classes_1.commandPaletteClasses.itemSelected, className), role: "option", "aria-selected": isSelected, "aria-disabled": disabled, "data-disabled": disabled || undefined }, _a[command_palette_1.VALUE_ATTR] = encodeURIComponent(itemValue), _a.onPointerMove = handlePointerMove, _a.onClick = handleClick, _a), itemProps),
239
+ icon && React.createElement(ItemIcon, { className: command_palette_classes_1.commandPaletteClasses.itemIcon }, icon),
240
+ React.createElement(ItemLabel, { className: command_palette_classes_1.commandPaletteClasses.itemLabel }, children),
241
+ shortcutKeys && (React.createElement(ItemShortcut, { className: command_palette_classes_1.commandPaletteClasses.itemShortcut }, shortcutKeys.map(function (key, i) { return (React.createElement(Kbd, { key: i, className: command_palette_classes_1.commandPaletteClasses.kbd }, key)); })))));
242
+ });
243
+ exports.CommandPaletteItem.displayName = 'CommandPaletteItem';
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { ICommandPaletteListProps } from './command-palette-types';
3
+ export declare const CommandPaletteList: React.ForwardRefExoticComponent<ICommandPaletteListProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.CommandPaletteList = void 0;
62
+ var React = __importStar(require("react"));
63
+ var styled_1 = require("../styled");
64
+ var clsx_1 = __importDefault(require("../utils/clsx"));
65
+ var command_palette_classes_1 = require("./command-palette-classes");
66
+ var command_palette_context_1 = require("./command-palette-context");
67
+ var Root = (0, styled_1.styled)('div', {
68
+ name: command_palette_classes_1.commandPaletteComponentName,
69
+ slot: 'List',
70
+ })(function (_a) {
71
+ var theme = _a.theme;
72
+ return ({
73
+ height: theme.typography.pxToRem(300),
74
+ overflow: 'auto',
75
+ outline: 'none',
76
+ overscrollBehavior: 'contain',
77
+ scrollbarWidth: 'thin',
78
+ scrollbarColor: "".concat(theme.tokens.color_border_default, " transparent"),
79
+ '&::-webkit-scrollbar': {
80
+ width: 6,
81
+ },
82
+ '&::-webkit-scrollbar-track': {
83
+ background: 'transparent',
84
+ },
85
+ '&::-webkit-scrollbar-thumb': {
86
+ backgroundColor: theme.tokens.color_border_default,
87
+ borderRadius: 3,
88
+ },
89
+ });
90
+ });
91
+ var Inner = (0, styled_1.styled)('div', {
92
+ name: command_palette_classes_1.commandPaletteComponentName,
93
+ slot: 'ListInner',
94
+ })(function () { return ({}); });
95
+ exports.CommandPaletteList = React.forwardRef(function (props, ref) {
96
+ var children = props.children, className = props.className, style = props.style, listProps = __rest(props, ["children", "className", "style"]);
97
+ var context = (0, command_palette_context_1.useCommandPaletteContext)();
98
+ return (React.createElement(Root, __assign({ ref: ref, id: context.listId, role: "listbox", "aria-label": "Suggestions", className: (0, clsx_1.default)(command_palette_classes_1.commandPaletteClasses.list, className), style: style }, listProps),
99
+ React.createElement(Inner, { ref: context.listInnerRef }, children)));
100
+ });
101
+ exports.CommandPaletteList.displayName = 'CommandPaletteList';
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { ICommandPaletteLoadingProps } from './command-palette-types';
3
+ export declare const CommandPaletteLoading: React.ForwardRefExoticComponent<ICommandPaletteLoadingProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.CommandPaletteLoading = void 0;
62
+ var React = __importStar(require("react"));
63
+ var spinner_1 = require("../spinner");
64
+ var styled_1 = require("../styled");
65
+ var clsx_1 = __importDefault(require("../utils/clsx"));
66
+ var command_palette_classes_1 = require("./command-palette-classes");
67
+ var Root = (0, styled_1.styled)('div', {
68
+ name: command_palette_classes_1.commandPaletteComponentName,
69
+ slot: 'Loading',
70
+ })(function (_a) {
71
+ var theme = _a.theme;
72
+ return ({
73
+ display: 'flex',
74
+ flexDirection: 'row',
75
+ alignItems: 'center',
76
+ width: '100%',
77
+ gap: theme.spacing(1.5),
78
+ padding: theme.spacing(2),
79
+ color: theme.tokens.color_fg_disabled,
80
+ fontSize: theme.typography.caption.fontSize,
81
+ });
82
+ });
83
+ exports.CommandPaletteLoading = React.forwardRef(function (props, ref) {
84
+ 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"]);
85
+ return (React.createElement(Root, __assign({ ref: ref, role: "progressbar", "aria-valuenow": progress, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": "Loading results", className: (0, clsx_1.default)(command_palette_classes_1.commandPaletteClasses.loading, className) }, loadingProps),
86
+ React.createElement(spinner_1.Spinner, null),
87
+ children));
88
+ });
89
+ exports.CommandPaletteLoading.displayName = 'CommandPaletteLoading';
@@ -0,0 +1 @@
1
+ export declare function commandScore(value: string, search: string): number;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commandScore = commandScore;
4
+ function commandScore(value, search) {
5
+ if (search.length === 0)
6
+ return 1;
7
+ if (value.length === 0)
8
+ return 0;
9
+ var lowerValue = value.toLowerCase();
10
+ var lowerSearch = search.toLowerCase();
11
+ if (lowerValue === lowerSearch)
12
+ return 1;
13
+ if (lowerValue.includes(lowerSearch)) {
14
+ if (lowerValue.startsWith(lowerSearch)) {
15
+ return 0.9;
16
+ }
17
+ return 0.7;
18
+ }
19
+ var searchIdx = 0;
20
+ var score = 0;
21
+ var consecutive = 0;
22
+ var prevMatchIdx = -2;
23
+ for (var i = 0; i < lowerValue.length && searchIdx < lowerSearch.length; i++) {
24
+ if (lowerValue[i] === lowerSearch[searchIdx]) {
25
+ if (i === prevMatchIdx + 1) {
26
+ consecutive++;
27
+ score += consecutive * 2;
28
+ }
29
+ else {
30
+ consecutive = 1;
31
+ score += 1;
32
+ }
33
+ if (i === 0 || /[\s\-_./]/.test(value[i - 1])) {
34
+ score += 3;
35
+ }
36
+ if (i > 0 && value[i] === value[i].toUpperCase() && value[i - 1] === value[i - 1].toLowerCase()) {
37
+ score += 2;
38
+ }
39
+ prevMatchIdx = i;
40
+ searchIdx++;
41
+ }
42
+ }
43
+ if (searchIdx < lowerSearch.length)
44
+ return 0;
45
+ var maxPossibleScore = lowerSearch.length * 6;
46
+ return Math.min(score / maxPossibleScore, 0.6);
47
+ }
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { ICommandPaletteSeparatorProps } from './command-palette-types';
3
+ export declare const CommandPaletteSeparator: React.ForwardRefExoticComponent<ICommandPaletteSeparatorProps & React.RefAttributes<HTMLDivElement>>;