@auth0/quantum-product 2.10.2 → 2.10.3
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/command-palette/command-palette-classes.d.ts +5 -0
- package/command-palette/command-palette-classes.js +34 -0
- package/command-palette/command-palette-context.d.ts +8 -0
- package/command-palette/command-palette-context.js +61 -0
- package/command-palette/command-palette-dialog.d.ts +3 -0
- package/command-palette/command-palette-dialog.js +112 -0
- package/command-palette/command-palette-empty.d.ts +3 -0
- package/command-palette/command-palette-empty.js +90 -0
- package/command-palette/command-palette-footer.d.ts +4 -0
- package/command-palette/command-palette-footer.js +111 -0
- package/command-palette/command-palette-group.d.ts +3 -0
- package/command-palette/command-palette-group.js +118 -0
- package/command-palette/command-palette-input.d.ts +3 -0
- package/command-palette/command-palette-input.js +144 -0
- package/command-palette/command-palette-item.d.ts +3 -0
- package/command-palette/command-palette-item.js +235 -0
- package/command-palette/command-palette-list.d.ts +3 -0
- package/command-palette/command-palette-list.js +101 -0
- package/command-palette/command-palette-loading.d.ts +3 -0
- package/command-palette/command-palette-loading.js +89 -0
- package/command-palette/command-palette-score.d.ts +1 -0
- package/command-palette/command-palette-score.js +47 -0
- package/command-palette/command-palette-separator.d.ts +3 -0
- package/command-palette/command-palette-separator.js +86 -0
- package/command-palette/command-palette-tabs.d.ts +4 -0
- package/command-palette/command-palette-tabs.js +146 -0
- package/command-palette/command-palette-types.d.ts +121 -0
- package/command-palette/command-palette-types.js +2 -0
- package/command-palette/command-palette.d.ts +5 -0
- package/command-palette/command-palette.js +474 -0
- package/command-palette/index.d.ts +27 -0
- package/command-palette/index.js +36 -0
- package/command-palette/use-command-palette-shortcut.d.ts +6 -0
- package/command-palette/use-command-palette-shortcut.js +65 -0
- package/esm/command-palette/command-palette-classes.js +30 -0
- package/esm/command-palette/command-palette-context.js +22 -0
- package/esm/command-palette/command-palette-dialog.js +73 -0
- package/esm/command-palette/command-palette-empty.js +51 -0
- package/esm/command-palette/command-palette-footer.js +72 -0
- package/esm/command-palette/command-palette-group.js +79 -0
- package/esm/command-palette/command-palette-input.js +105 -0
- package/esm/command-palette/command-palette-item.js +196 -0
- package/esm/command-palette/command-palette-list.js +62 -0
- package/esm/command-palette/command-palette-loading.js +50 -0
- package/esm/command-palette/command-palette-score.js +44 -0
- package/esm/command-palette/command-palette-separator.js +47 -0
- package/esm/command-palette/command-palette-tabs.js +107 -0
- package/esm/command-palette/command-palette-types.js +1 -0
- package/esm/command-palette/command-palette.js +435 -0
- package/esm/command-palette/index.js +14 -0
- package/esm/command-palette/use-command-palette-shortcut.js +29 -0
- package/esm/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- 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,235 @@
|
|
|
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 command_palette_1 = require("./command-palette");
|
|
92
|
+
var command_palette_classes_1 = require("./command-palette-classes");
|
|
93
|
+
var command_palette_context_1 = require("./command-palette-context");
|
|
94
|
+
var Root = (0, styled_1.styled)('div', {
|
|
95
|
+
name: command_palette_classes_1.commandPaletteComponentName,
|
|
96
|
+
slot: 'Item',
|
|
97
|
+
})(function (_a) {
|
|
98
|
+
var theme = _a.theme, ownerState = _a.ownerState;
|
|
99
|
+
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'], {
|
|
100
|
+
duration: theme.transitions.duration.shortest,
|
|
101
|
+
}) }, (ownerState.isSelected && {
|
|
102
|
+
backgroundColor: theme.tokens.color_bg_interactive_hover,
|
|
103
|
+
})), (ownerState.disabled && {
|
|
104
|
+
opacity: 0.5,
|
|
105
|
+
cursor: 'not-allowed',
|
|
106
|
+
})), (!ownerState.disabled &&
|
|
107
|
+
!ownerState.isSelected && {
|
|
108
|
+
'&:hover': {
|
|
109
|
+
backgroundColor: theme.tokens.color_bg_interactive_hover,
|
|
110
|
+
},
|
|
111
|
+
})), { '&[aria-disabled="true"]': {
|
|
112
|
+
opacity: 0.5,
|
|
113
|
+
cursor: 'not-allowed',
|
|
114
|
+
} }));
|
|
115
|
+
});
|
|
116
|
+
var ItemIcon = (0, styled_1.styled)('div', {
|
|
117
|
+
name: command_palette_classes_1.commandPaletteComponentName,
|
|
118
|
+
slot: 'ItemIcon',
|
|
119
|
+
})(function (_a) {
|
|
120
|
+
var theme = _a.theme;
|
|
121
|
+
return ({
|
|
122
|
+
display: 'flex',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
justifyContent: 'center',
|
|
125
|
+
flexShrink: 0,
|
|
126
|
+
color: theme.tokens.color_fg_disabled,
|
|
127
|
+
'& svg': {
|
|
128
|
+
width: theme.typography.pxToRem(18),
|
|
129
|
+
height: theme.typography.pxToRem(18),
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
var ItemLabel = (0, styled_1.styled)('span', {
|
|
134
|
+
name: command_palette_classes_1.commandPaletteComponentName,
|
|
135
|
+
slot: 'ItemLabel',
|
|
136
|
+
})(function () { return ({
|
|
137
|
+
flex: 1,
|
|
138
|
+
overflow: 'hidden',
|
|
139
|
+
textOverflow: 'ellipsis',
|
|
140
|
+
whiteSpace: 'nowrap',
|
|
141
|
+
}); });
|
|
142
|
+
var ItemShortcut = (0, styled_1.styled)('span', {
|
|
143
|
+
name: command_palette_classes_1.commandPaletteComponentName,
|
|
144
|
+
slot: 'ItemShortcut',
|
|
145
|
+
})(function (_a) {
|
|
146
|
+
var theme = _a.theme;
|
|
147
|
+
return ({
|
|
148
|
+
display: 'flex',
|
|
149
|
+
alignItems: 'center',
|
|
150
|
+
gap: theme.spacing(0.5),
|
|
151
|
+
flexShrink: 0,
|
|
152
|
+
marginLeft: 'auto',
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
var Kbd = (0, styled_1.styled)('kbd', {
|
|
156
|
+
name: command_palette_classes_1.commandPaletteComponentName,
|
|
157
|
+
slot: 'Kbd',
|
|
158
|
+
})(function (_a) {
|
|
159
|
+
var theme = _a.theme;
|
|
160
|
+
return ({
|
|
161
|
+
display: 'inline-flex',
|
|
162
|
+
alignItems: 'center',
|
|
163
|
+
justifyContent: 'center',
|
|
164
|
+
minWidth: theme.typography.pxToRem(22),
|
|
165
|
+
height: theme.typography.pxToRem(22),
|
|
166
|
+
padding: "0 ".concat(theme.spacing(0.5)),
|
|
167
|
+
borderRadius: theme.typography.pxToRem(4),
|
|
168
|
+
backgroundColor: theme.tokens.color_bg_state_neutral_subtle,
|
|
169
|
+
border: "1px solid ".concat(theme.tokens.color_border_default),
|
|
170
|
+
color: theme.tokens.color_fg_disabled,
|
|
171
|
+
fontSize: theme.typography.overline.fontSize,
|
|
172
|
+
fontFamily: theme.typography.fontFamily,
|
|
173
|
+
lineHeight: 1,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
function deriveValue(valueProp, children, el) {
|
|
177
|
+
var _a;
|
|
178
|
+
if (valueProp)
|
|
179
|
+
return valueProp;
|
|
180
|
+
if (typeof children === 'string')
|
|
181
|
+
return children.trim().toLowerCase();
|
|
182
|
+
if (typeof children === 'number')
|
|
183
|
+
return String(children);
|
|
184
|
+
return ((_a = el === null || el === void 0 ? void 0 : el.textContent) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) || '';
|
|
185
|
+
}
|
|
186
|
+
function useValue(id, ref, deps) {
|
|
187
|
+
var initialValue = deriveValue(deps[0], deps[2], null);
|
|
188
|
+
var valueRef = React.useRef(initialValue);
|
|
189
|
+
var context = (0, command_palette_context_1.useCommandPaletteContext)();
|
|
190
|
+
React.useLayoutEffect(function () {
|
|
191
|
+
var value = deriveValue(deps[0], deps[2], ref.current);
|
|
192
|
+
valueRef.current = value;
|
|
193
|
+
context.value(id, value, deps[1]);
|
|
194
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
195
|
+
}, __spreadArray([id], __read(deps), false));
|
|
196
|
+
return valueRef.current;
|
|
197
|
+
}
|
|
198
|
+
exports.CommandPaletteItem = React.forwardRef(function (props, ref) {
|
|
199
|
+
var _a;
|
|
200
|
+
var valueProp = props.value, keywords = props.keywords, _b = props.disabled, disabled = _b === void 0 ? false : _b, onSelect = props.onSelect, _c = props.forceMount, forceMount = _c === void 0 ? false : _c, icon = props.icon, shortcut = props.shortcut, children = props.children, className = props.className, itemProps = __rest(props, ["value", "keywords", "disabled", "onSelect", "forceMount", "icon", "shortcut", "children", "className"]);
|
|
201
|
+
var id = React.useId();
|
|
202
|
+
var itemRef = React.useRef(null);
|
|
203
|
+
var context = (0, command_palette_context_1.useCommandPaletteContext)();
|
|
204
|
+
var store = (0, command_palette_context_1.useCommandPaletteStore)();
|
|
205
|
+
var groupId = React.useContext(command_palette_context_1.CommandPaletteGroupContext);
|
|
206
|
+
var itemValue = useValue(id, itemRef, [valueProp, keywords, children]);
|
|
207
|
+
var selectedValue = (0, command_palette_context_1.useCommandPaletteState)(function (state) { return state.selectedValue; });
|
|
208
|
+
var isSelected = selectedValue === itemValue && itemValue !== '';
|
|
209
|
+
var filteredState = (0, command_palette_context_1.useCommandPaletteState)(function (state) { return state.filtered; });
|
|
210
|
+
var score = filteredState.items.get(id);
|
|
211
|
+
var isVisible = forceMount || context.filter === false || score === undefined || score > 0;
|
|
212
|
+
React.useLayoutEffect(function () {
|
|
213
|
+
var cleanup = context.item(id, groupId);
|
|
214
|
+
return cleanup;
|
|
215
|
+
}, [context, id, groupId]);
|
|
216
|
+
var handlePointerMove = React.useCallback(function () {
|
|
217
|
+
if (!disabled && itemValue) {
|
|
218
|
+
store.setState('selectedValue', itemValue);
|
|
219
|
+
}
|
|
220
|
+
}, [disabled, itemValue, store]);
|
|
221
|
+
var handleClick = React.useCallback(function () {
|
|
222
|
+
if (!disabled) {
|
|
223
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(itemValue);
|
|
224
|
+
}
|
|
225
|
+
}, [disabled, onSelect, itemValue]);
|
|
226
|
+
var mergedRef = (0, useForkRef_1.default)(itemRef, ref);
|
|
227
|
+
var shortcutKeys = shortcut ? (Array.isArray(shortcut) ? shortcut : shortcut.split('+')) : null;
|
|
228
|
+
if (!isVisible)
|
|
229
|
+
return null;
|
|
230
|
+
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),
|
|
231
|
+
icon && React.createElement(ItemIcon, { className: command_palette_classes_1.commandPaletteClasses.itemIcon }, icon),
|
|
232
|
+
React.createElement(ItemLabel, { className: command_palette_classes_1.commandPaletteClasses.itemLabel }, children),
|
|
233
|
+
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)); })))));
|
|
234
|
+
});
|
|
235
|
+
exports.CommandPaletteItem.displayName = 'CommandPaletteItem';
|
|
@@ -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,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
|
+
}
|