@enigmax/primitives 0.18.0 → 0.19.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/dist/{chunk-UZFEEFMF.js → chunk-D5A2ZMAG.js} +34 -1
- package/dist/chunk-DTWZDONY.js +99 -0
- package/dist/{chunk-LKA2UG4P.js → chunk-FWVWX67R.js} +26 -106
- package/dist/{chunk-WSB655JB.js → chunk-QQFNAKMY.js} +1 -1
- package/dist/{chunk-IIT6U7LM.js → chunk-R4ZAEE7V.js} +1 -1
- package/dist/{index-DNXPtY9X.d.ts → index-dTdAbOWl.d.ts} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/next/index.d.ts +6 -5
- package/dist/next/index.js +5 -4
- package/dist/palette-D7iuQh_T.d.ts +86 -0
- package/dist/react/index.d.ts +7 -6
- package/dist/react/index.js +5 -4
- package/dist/react/input.d.ts +2 -2
- package/dist/react/input.js +1 -1
- package/dist/react/palette.d.ts +231 -3
- package/dist/react/palette.js +3 -2
- package/dist/react/search.d.ts +1 -1
- package/dist/react/search.js +2 -2
- package/dist/react-router/index.d.ts +6 -5
- package/dist/react-router/index.js +5 -4
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +1 -1
- package/dist/{search-CsO3L1Lw.d.ts → search-DXxY8SEH.d.ts} +15 -1
- package/dist/{search-P4OHCRXD.js → search-UQEXAPQB.js} +1 -1
- package/package.json +3 -2
- package/recipes/input/styles.css +60 -20
- package/recipes/palette/styles.css +243 -0
- package/registry.json +12 -1
- package/src/core/search.ts +60 -0
- package/src/index.ts +17 -1
- package/src/react/index.ts +10 -0
- package/src/react/palette/root.tsx +46 -6
- package/dist/index-D-ARvWpQ.d.ts +0 -306
package/dist/react/palette.d.ts
CHANGED
|
@@ -1,3 +1,231 @@
|
|
|
1
|
-
import 'react';
|
|
2
|
-
|
|
3
|
-
import '../
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import { b as SearchMatch, c as SearchOptions } from '../search-DXxY8SEH.js';
|
|
3
|
+
import { R as RecentEntry } from '../palette-D7iuQh_T.js';
|
|
4
|
+
|
|
5
|
+
/** One line in the palette, whatever it came from. */
|
|
6
|
+
interface PaletteRow<Item> {
|
|
7
|
+
/** Stable within a render. Used for React keys and for `aria-activedescendant`. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Which group it appears under. */
|
|
10
|
+
group: string;
|
|
11
|
+
/** `item` for a result, `recent` for a memory, `action` for a row the app declared. */
|
|
12
|
+
kind: "item" | "recent" | "action";
|
|
13
|
+
item?: Item;
|
|
14
|
+
recent?: RecentEntry;
|
|
15
|
+
/** Set for a result that came from the engine, so a renderer can show the score. */
|
|
16
|
+
match?: SearchMatch<Item>;
|
|
17
|
+
/** What running this row does. The palette closes afterwards unless this returns false. */
|
|
18
|
+
onSelect?: () => void | boolean;
|
|
19
|
+
label: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
interface PaletteContextValue<Item = unknown> {
|
|
23
|
+
open: boolean;
|
|
24
|
+
setOpen: (open: boolean) => void;
|
|
25
|
+
query: string;
|
|
26
|
+
setQuery: (query: string) => void;
|
|
27
|
+
rows: PaletteRow<Item>[];
|
|
28
|
+
active: number;
|
|
29
|
+
setActive: (index: number) => void;
|
|
30
|
+
/** Run a row: its own action, or the palette's `onSelect`, then remember it. */
|
|
31
|
+
select: (row: PaletteRow<Item> | undefined) => void;
|
|
32
|
+
/** Wipe the remembered searches. */
|
|
33
|
+
clearRecents: () => void;
|
|
34
|
+
forgetRecent: (entry: RecentEntry) => void;
|
|
35
|
+
/** True while the engine is loading or an async source is in flight. */
|
|
36
|
+
busy: boolean;
|
|
37
|
+
/** ids the parts need to point at each other. */
|
|
38
|
+
ids: {
|
|
39
|
+
field: string;
|
|
40
|
+
list: string;
|
|
41
|
+
title: string;
|
|
42
|
+
};
|
|
43
|
+
/** `Ctrl K` or `⌘ K`, whichever this platform uses. */
|
|
44
|
+
shortcutLabel: string;
|
|
45
|
+
triggerRef: {
|
|
46
|
+
current: HTMLElement | null;
|
|
47
|
+
};
|
|
48
|
+
fieldRef: {
|
|
49
|
+
current: HTMLInputElement | null;
|
|
50
|
+
};
|
|
51
|
+
rowId: (row: PaletteRow<Item>) => string;
|
|
52
|
+
}
|
|
53
|
+
declare function usePaletteContext<Item = unknown>(part: string): PaletteContextValue<Item>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The command palette: the panel that opens on Ctrl/Cmd+K, searches as you type, remembers
|
|
57
|
+
* what was searched before, and is driven entirely from the keyboard.
|
|
58
|
+
*
|
|
59
|
+
* It is a DIALOG, which is why it is its own component rather than a prop on `<Input>`: a
|
|
60
|
+
* palette is a trigger, an overlay, a focus trap, a listbox and a footer, and the thing that
|
|
61
|
+
* makes those usable together is composition. Radix draws the line in the same place, and
|
|
62
|
+
* for the same reason - one `<input>` is a component, a widget made of parts is an anatomy:
|
|
63
|
+
*
|
|
64
|
+
* ```tsx
|
|
65
|
+
* <SearchPalette.Root items={docs} keys={["title"]} onSelect={open}>
|
|
66
|
+
* <SearchPalette.Trigger />
|
|
67
|
+
* <SearchPalette.Content>
|
|
68
|
+
* <SearchPalette.Field placeholder="Search the docs" />
|
|
69
|
+
* <SearchPalette.List />
|
|
70
|
+
* <SearchPalette.Footer />
|
|
71
|
+
* </SearchPalette.Content>
|
|
72
|
+
* </SearchPalette.Root>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* `<SearchPalette>` on its own renders exactly that, for the case that needs no arguing
|
|
76
|
+
* with. Every part takes `asChild`, so any of them can be your own element instead.
|
|
77
|
+
*
|
|
78
|
+
* The keyboard sequence is ONE flat list across every group - a group boundary is invisible
|
|
79
|
+
* to the arrow keys - and the highlight wraps, because in a short list the row after the
|
|
80
|
+
* last one is the first, and a key that does nothing at the end reads as a frozen panel.
|
|
81
|
+
*/
|
|
82
|
+
interface PaletteSection<Item> {
|
|
83
|
+
label: string;
|
|
84
|
+
items: Item[];
|
|
85
|
+
/** Shown whatever the query, e.g. a list of commands. Off by default. */
|
|
86
|
+
always?: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface PaletteRootProps<Item> {
|
|
89
|
+
/** What to search. */
|
|
90
|
+
items?: Item[];
|
|
91
|
+
/** Fields to read. Dotted paths work. */
|
|
92
|
+
keys?: SearchOptions<Item>["keys"];
|
|
93
|
+
/** Fuse.js's constructor, for fuzzy matching. Without it, a substring matcher runs. */
|
|
94
|
+
fuse?: SearchOptions<Item>["fuse"];
|
|
95
|
+
fuseOptions?: SearchOptions<Item>["fuseOptions"];
|
|
96
|
+
/** Replaces the engine outright. */
|
|
97
|
+
matcher?: SearchOptions<Item>["matcher"];
|
|
98
|
+
/** ms after the last keystroke. Default 120: a palette should feel immediate. */
|
|
99
|
+
delay?: number;
|
|
100
|
+
limit?: number;
|
|
101
|
+
/** Which group a result belongs under. One group when this is left out. */
|
|
102
|
+
groupBy?: (item: Item) => string;
|
|
103
|
+
/** The row's text. Falls back to the first string field. */
|
|
104
|
+
labelOf?: (item: Item) => string;
|
|
105
|
+
descriptionOf?: (item: Item) => string | undefined;
|
|
106
|
+
/** Rows the app always offers - commands, shortcuts, "create new". */
|
|
107
|
+
sections?: PaletteSection<Item>[];
|
|
108
|
+
/** What running a row does. Closing afterwards is the default; return false to stay. */
|
|
109
|
+
onSelect?: (item: Item) => void | boolean;
|
|
110
|
+
/** Remember what was searched, in this browser. On by default. */
|
|
111
|
+
recents?: boolean;
|
|
112
|
+
recentsKey?: string;
|
|
113
|
+
recentsLimit?: number;
|
|
114
|
+
/** The key that opens it, with Ctrl or Cmd. `null` binds nothing. Default "k". */
|
|
115
|
+
shortcut?: string | null;
|
|
116
|
+
/** Controlled open state. Leave both out for an uncontrolled palette. */
|
|
117
|
+
open?: boolean;
|
|
118
|
+
onOpenChange?: (open: boolean) => void;
|
|
119
|
+
defaultOpen?: boolean;
|
|
120
|
+
/** Wording for the empty group heading of ungrouped results. Default "Results". */
|
|
121
|
+
resultsLabel?: string;
|
|
122
|
+
recentsLabel?: string;
|
|
123
|
+
children?: ReactNode;
|
|
124
|
+
}
|
|
125
|
+
declare function PaletteRoot<Item>({ items, keys, fuse, fuseOptions, matcher, delay, limit, groupBy, labelOf, descriptionOf, sections, onSelect, recents, recentsKey, recentsLimit, shortcut, open: openProp, onOpenChange, defaultOpen, resultsLabel, recentsLabel, children }: PaletteRootProps<Item>): ReactNode;
|
|
126
|
+
interface PaletteTriggerProps extends ComponentPropsWithoutRef<"button"> {
|
|
127
|
+
asChild?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/** Opens the palette. Carries the shortcut in `aria-keyshortcuts`, so it is announced. */
|
|
130
|
+
declare function PaletteTrigger({ asChild, children, onClick, ...props }: PaletteTriggerProps): ReactNode;
|
|
131
|
+
interface PaletteContentProps extends ComponentPropsWithoutRef<"div"> {
|
|
132
|
+
/** Accessible name for the dialog. Rendered for screen readers only. */
|
|
133
|
+
title?: string;
|
|
134
|
+
/** Render into `document.body`. On by default: a palette inside a clipped or
|
|
135
|
+
* transformed ancestor is a panel nobody can see. */
|
|
136
|
+
portal?: boolean;
|
|
137
|
+
/** Rendered behind the panel. Pass null for no overlay of ours. */
|
|
138
|
+
overlayProps?: ComponentPropsWithoutRef<"div"> | null;
|
|
139
|
+
/**
|
|
140
|
+
* How long the closing animation is given before the panel leaves the DOM, in ms.
|
|
141
|
+
*
|
|
142
|
+
* It exists because a component that unmounts on close can only ever animate IN: the
|
|
143
|
+
* element is gone before a leaving animation has a frame to run. `data-state="closed"`
|
|
144
|
+
* is set first, the stylesheet animates it, and only then does it unmount. 0 removes it
|
|
145
|
+
* immediately, which is also what a reader with reduced motion gets.
|
|
146
|
+
*/
|
|
147
|
+
closeDuration?: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The panel: overlay, focus trap, Escape, scroll lock, and focus handed back to the trigger.
|
|
151
|
+
*
|
|
152
|
+
* Mounted only while open, so nothing of the palette is in the document (or in the tab
|
|
153
|
+
* order) the rest of the time.
|
|
154
|
+
*/
|
|
155
|
+
declare function PaletteContent({ title, portal, overlayProps, closeDuration, children, ...props }: PaletteContentProps): ReactNode;
|
|
156
|
+
interface PaletteFieldProps extends Omit<ComponentPropsWithoutRef<"input">, "value" | "onChange"> {
|
|
157
|
+
asChild?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The query field.
|
|
161
|
+
*
|
|
162
|
+
* A `combobox` that keeps the caret while the arrows move a highlight somewhere else -
|
|
163
|
+
* which is exactly what `aria-activedescendant` is for. Without it a screen reader hears
|
|
164
|
+
* nothing move, because focus never leaves the field.
|
|
165
|
+
*/
|
|
166
|
+
declare function PaletteField({ asChild, onKeyDown, ...props }: PaletteFieldProps): ReactNode;
|
|
167
|
+
interface PaletteListProps<Item> extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
168
|
+
/** Render one row. The default prints its label, which is enough to be usable. */
|
|
169
|
+
children?: (row: PaletteRow<Item>, state: {
|
|
170
|
+
active: boolean;
|
|
171
|
+
index: number;
|
|
172
|
+
}) => ReactNode;
|
|
173
|
+
/** Rendered when there is nothing to show. */
|
|
174
|
+
empty?: ReactNode;
|
|
175
|
+
/** The group heading. Pass null for a flat list with no headings. */
|
|
176
|
+
heading?: ((label: string) => ReactNode) | null;
|
|
177
|
+
}
|
|
178
|
+
/** The results, grouped, with one flat keyboard sequence running through them. */
|
|
179
|
+
declare function PaletteList<Item>({ children, empty, heading, ...props }: PaletteListProps<Item>): ReactNode;
|
|
180
|
+
interface PaletteItemProps<Item> extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
181
|
+
row: PaletteRow<Item>;
|
|
182
|
+
index: number;
|
|
183
|
+
children?: ReactNode;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* One row.
|
|
187
|
+
*
|
|
188
|
+
* The pointer MOVES the highlight rather than running a second one of its own: two
|
|
189
|
+
* highlights on screen is the thing that makes a palette feel unpredictable, because Enter
|
|
190
|
+
* then opens the row the mouse is not on.
|
|
191
|
+
*/
|
|
192
|
+
declare function PaletteItem<Item>({ row, index, children, ...props }: PaletteItemProps<Item>): ReactNode;
|
|
193
|
+
interface PaletteFooterProps extends ComponentPropsWithoutRef<"div"> {
|
|
194
|
+
/** Replace the hints. The default names the three keys that actually matter. */
|
|
195
|
+
hints?: ReactNode;
|
|
196
|
+
}
|
|
197
|
+
/** The strip along the bottom that says which keys do what. */
|
|
198
|
+
declare function PaletteFooter({ hints, children, ...props }: PaletteFooterProps): ReactNode;
|
|
199
|
+
|
|
200
|
+
interface SearchPaletteProps<Item> extends PaletteRootProps<Item> {
|
|
201
|
+
placeholder?: string;
|
|
202
|
+
/** The trigger's own content. Pass null for a palette that only opens on the shortcut. */
|
|
203
|
+
trigger?: ReactNode | null;
|
|
204
|
+
/** Render one row, same signature as `SearchPalette.List`. */
|
|
205
|
+
renderItem?: PaletteListProps<Item>["children"];
|
|
206
|
+
empty?: ReactNode;
|
|
207
|
+
footer?: ReactNode;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The palette, assembled.
|
|
211
|
+
*
|
|
212
|
+
* ```tsx
|
|
213
|
+
* <SearchPalette items={docs} keys={["title", "body"]} onSelect={(doc) => go(doc.href)} />
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* Everything it renders is a part you can render yourself instead - see `SearchPalette.Root`
|
|
217
|
+
* for the anatomy. This is the composition that covers the common case, not a different
|
|
218
|
+
* component: it is those parts, in the order they belong in.
|
|
219
|
+
*/
|
|
220
|
+
declare function SearchPalette<Item>({ placeholder, trigger, renderItem, empty, footer, children, ...root }: SearchPaletteProps<Item>): ReactNode;
|
|
221
|
+
declare namespace SearchPalette {
|
|
222
|
+
var Root: typeof PaletteRoot;
|
|
223
|
+
var Trigger: typeof PaletteTrigger;
|
|
224
|
+
var Content: typeof PaletteContent;
|
|
225
|
+
var Field: typeof PaletteField;
|
|
226
|
+
var List: typeof PaletteList;
|
|
227
|
+
var Item: typeof PaletteItem;
|
|
228
|
+
var Footer: typeof PaletteFooter;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export { PaletteContent, type PaletteContextValue, PaletteField, PaletteFooter, PaletteItem, PaletteList, type PaletteListProps, PaletteRoot, type PaletteRootProps, type PaletteRow, type PaletteSection, PaletteTrigger, SearchPalette, type SearchPaletteProps, type PaletteRow as SearchPaletteRow, usePaletteContext };
|
package/dist/react/palette.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { PaletteContent, PaletteField, PaletteFooter, PaletteItem, PaletteList, PaletteRoot, PaletteTrigger, SearchPalette, usePaletteContext } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
export { PaletteContent, PaletteField, PaletteFooter, PaletteItem, PaletteList, PaletteRoot, PaletteTrigger, SearchPalette, usePaletteContext } from '../chunk-FWVWX67R.js';
|
|
3
|
+
import '../chunk-DTWZDONY.js';
|
|
4
|
+
import '../chunk-D5A2ZMAG.js';
|
|
4
5
|
import '../chunk-HS3X3XCW.js';
|
package/dist/react/search.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import { b as SearchMatch, c as SearchOptions } from '../search-
|
|
2
|
+
import { b as SearchMatch, c as SearchOptions } from '../search-DXxY8SEH.js';
|
|
3
3
|
|
|
4
4
|
interface UseSearchResult<T> {
|
|
5
5
|
/** Attach to the search field, or drive it yourself with `search`. */
|
package/dist/react/search.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { useSearch } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
export { useSearch } from '../chunk-QQFNAKMY.js';
|
|
3
|
+
import '../chunk-D5A2ZMAG.js';
|
|
@@ -5,9 +5,9 @@ export { M as MarqueeHover, a as MarqueeInstance, b as MarqueeOptions } from '..
|
|
|
5
5
|
export { PasswordStrength, PasswordStrengthProps, UseButtonResult, UseInputResult, getLinkComponent, setLinkComponent, useButton, useInput } from '../react/index.js';
|
|
6
6
|
export { UseSearchResult, useSearch } from '../react/search.js';
|
|
7
7
|
export { I as InputAction, b as InputIcon, d as InputOptions } from '../input-BwXjFenq.js';
|
|
8
|
-
export { F as FuseConstructor, b as SearchMatch, c as SearchOptions } from '../search-
|
|
8
|
+
export { F as FuseConstructor, a as FuseLike, S as SearchInstance, b as SearchMatch, c as SearchOptions } from '../search-DXxY8SEH.js';
|
|
9
9
|
export { c as ButtonOptions, d as ButtonState } from '../button-CaXaqG_K.js';
|
|
10
|
-
export { B as BreachChecker, a as BreachState, b as BreachStatus, F as FieldAction, I as Input, c as InputBaseProps, d as InputProps, e as InputType, P as PasswordOnlyProps, g as PlainOnlyProps, S as SearchOnlyProps } from '../index-
|
|
10
|
+
export { B as BreachChecker, a as BreachState, b as BreachStatus, F as FieldAction, I as Input, c as InputBaseProps, d as InputProps, e as InputType, P as PasswordOnlyProps, g as PlainOnlyProps, S as SearchOnlyProps } from '../index-dTdAbOWl.js';
|
|
11
11
|
export { Slot, SlotProps, mergeSlotProps } from '../react/slot.js';
|
|
12
12
|
export { E as EstimateOptions, G as GeneratePasswordOptions, a as PasswordScore, b as PasswordStrengthReport, e as estimatePasswordStrength, g as generatePassword } from '../password-C8lG4Zm9.js';
|
|
13
13
|
export { UseNotificationsResult, createNotificationQueue, defaultQueue, useNotifications } from '../react/notifications.js';
|
|
@@ -15,11 +15,12 @@ export { ToastControls, ToastPosition, Toaster, ToasterProps } from '../react/to
|
|
|
15
15
|
export { useNetworkState } from '../react/network.js';
|
|
16
16
|
export { a as NetworkState } from '../network-D2LsBG_k.js';
|
|
17
17
|
export { RelativeTime, RelativeTimeProps } from '../react/relative-time.js';
|
|
18
|
+
export { R as RelativeTimeFormat, a as RelativeTimeOptions, b as RelativeTimePrecision, c as RelativeTimeStyle, d as RelativeTimeTense } from '../relative-time-YpRTG7YH.js';
|
|
19
|
+
export { N as Notification, a as NotificationAction, b as NotificationInput, c as NotificationTone, e as NotificationsOptions } from '../notifications-BpVV6sel.js';
|
|
18
20
|
export { Flag, FlagProps } from '../react/flag.js';
|
|
19
21
|
export { c as FlagFormat, d as FlagOptions, e as FlagShape, f as FlagSource, h as configureFlags, i as flagAttributes, k as flagName, l as flagSrc, m as flagView, n as normalizeFlagCode } from '../flags-BBJc9unY.js';
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
import '../relative-time-YpRTG7YH.js';
|
|
22
|
+
export { PaletteContent, PaletteContextValue, PaletteField, PaletteFooter, PaletteItem, PaletteList, PaletteListProps, PaletteRoot, PaletteRootProps, PaletteRow, PaletteSection, PaletteTrigger, SearchPalette, SearchPaletteProps, usePaletteContext } from '../react/palette.js';
|
|
23
|
+
export { R as RecentEntry, b as RecentStore, e as createRecentStore, g as groupRows, i as isPaletteShortcut, m as moveActive, r as recentKey, s as shortcutLabel } from '../palette-D7iuQh_T.js';
|
|
23
24
|
|
|
24
25
|
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLElement>>;
|
|
25
26
|
|
|
@@ -4,7 +4,7 @@ export { PasswordStrength } from '../chunk-XQHCZAPJ.js';
|
|
|
4
4
|
export { Flag } from '../chunk-XNNQRA35.js';
|
|
5
5
|
export { Toaster } from '../chunk-ZCUFYBPB.js';
|
|
6
6
|
export { useMarquee } from '../chunk-ZWR2EXHQ.js';
|
|
7
|
-
export { useSearch } from '../chunk-
|
|
7
|
+
export { useSearch } from '../chunk-QQFNAKMY.js';
|
|
8
8
|
export { useNetworkState } from '../chunk-S653GLSF.js';
|
|
9
9
|
export { createNotificationQueue, defaultQueue, useNotifications } from '../chunk-QYMUIW5I.js';
|
|
10
10
|
export { RelativeTime } from '../chunk-OCMI7R6H.js';
|
|
@@ -15,10 +15,11 @@ import '../chunk-UOSSNUSC.js';
|
|
|
15
15
|
import '../chunk-2QFTRNAZ.js';
|
|
16
16
|
import '../chunk-SNYUBXWQ.js';
|
|
17
17
|
import '../chunk-IXVMRVD4.js';
|
|
18
|
-
export { Input } from '../chunk-
|
|
18
|
+
export { Input } from '../chunk-R4ZAEE7V.js';
|
|
19
19
|
import '../chunk-F25CGNQC.js';
|
|
20
|
-
export { PaletteContent, PaletteField, PaletteFooter, PaletteItem, PaletteList, PaletteRoot, PaletteTrigger, SearchPalette,
|
|
21
|
-
|
|
20
|
+
export { PaletteContent, PaletteField, PaletteFooter, PaletteItem, PaletteList, PaletteRoot, PaletteTrigger, SearchPalette, usePaletteContext } from '../chunk-FWVWX67R.js';
|
|
21
|
+
export { createRecentStore, groupRows, isPaletteShortcut, moveActive, recentKey, shortcutLabel } from '../chunk-DTWZDONY.js';
|
|
22
|
+
import '../chunk-D5A2ZMAG.js';
|
|
22
23
|
import { Button } from '../chunk-6BGBYUSZ.js';
|
|
23
24
|
export { getLinkComponent, setLinkComponent, useButton } from '../chunk-6BGBYUSZ.js';
|
|
24
25
|
import '../chunk-MMQPZGSU.js';
|
package/dist/search/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as SearchOptions, S as SearchInstance } from '../search-
|
|
2
|
-
export { b as SearchMatch } from '../search-
|
|
1
|
+
import { c as SearchOptions, S as SearchInstance } from '../search-DXxY8SEH.js';
|
|
2
|
+
export { b as SearchMatch } from '../search-DXxY8SEH.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Search with Fuse.js already wired: the batteries-included entry point.
|
package/dist/search/index.js
CHANGED
|
@@ -63,6 +63,20 @@ interface SearchInstance<T> {
|
|
|
63
63
|
subscribe(listener: (results: SearchMatch<T>[], query: string) => void): () => void;
|
|
64
64
|
destroy(): void;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Subsequence ranking: every letter of the query, in order, anywhere in the text.
|
|
68
|
+
*
|
|
69
|
+
* This is what a COMMAND palette wants and a substring filter cannot do: "qgate" finds
|
|
70
|
+
* "Quality gate" and "plyg" finds "Playground", because the letters only have to appear in
|
|
71
|
+
* order. The score rewards consecutive runs and word starts and penalises gaps, so the
|
|
72
|
+
* closest thing to what was typed comes first rather than the first thing that happened to
|
|
73
|
+
* contain the letters.
|
|
74
|
+
*
|
|
75
|
+
* Pass it as `matcher`, or take it as the default from the palette. The substring matcher
|
|
76
|
+
* stays the default for a plain search FIELD, where a typo should fail rather than quietly
|
|
77
|
+
* match something four words away.
|
|
78
|
+
*/
|
|
79
|
+
declare function subsequenceMatcher<T>(keys?: string[]): NonNullable<SearchOptions<T>["matcher"]>;
|
|
66
80
|
declare function createSearch<T>(options?: SearchOptions<T>): SearchInstance<T>;
|
|
67
81
|
|
|
68
|
-
export { type FuseConstructor as F, type SearchInstance as S, type FuseLike as a, type SearchMatch as b, type SearchOptions as c, createSearch as d };
|
|
82
|
+
export { type FuseConstructor as F, type SearchInstance as S, type FuseLike as a, type SearchMatch as b, type SearchOptions as c, createSearch as d, subsequenceMatcher as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enigmax/primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Headless components: the behaviour, the timing and the accessibility, with no styles of their own. Framework-agnostic core plus thin adapters.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -78,7 +78,8 @@
|
|
|
78
78
|
"./toast.css": "./recipes/toast/styles.css",
|
|
79
79
|
"./input.css": "./recipes/input/styles.css",
|
|
80
80
|
"./marquee.css": "./recipes/marquee/styles.css",
|
|
81
|
-
"./logo-marquee.css": "./recipes/logo-marquee/styles.css"
|
|
81
|
+
"./logo-marquee.css": "./recipes/logo-marquee/styles.css",
|
|
82
|
+
"./palette.css": "./recipes/palette/styles.css"
|
|
82
83
|
},
|
|
83
84
|
"scripts": {
|
|
84
85
|
"build": "tsup",
|
package/recipes/input/styles.css
CHANGED
|
@@ -1,23 +1,64 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* A starting point for the field, yours to edit.
|
|
3
|
+
*
|
|
4
|
+
* The primitive renders the structure and publishes its state through data-* attributes;
|
|
5
|
+
* every colour and distance below is this file's. The custom properties at the top are the
|
|
6
|
+
* whole API - override them on `:root` and you have a different field without touching a
|
|
7
|
+
* selector, which is the same arrangement the toast and the palette use.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
--enigma-input-bg: #171717;
|
|
12
|
+
--enigma-input-border: #404040;
|
|
13
|
+
--enigma-input-border-focus: #a3a3a3;
|
|
14
|
+
--enigma-input-text: #f5f5f5;
|
|
15
|
+
--enigma-input-muted: #a3a3a3;
|
|
16
|
+
--enigma-input-radius: 0.5rem;
|
|
17
|
+
--enigma-input-font-size: 0.875rem;
|
|
18
|
+
--enigma-input-padding: 0 0.75rem;
|
|
19
|
+
--enigma-input-danger: #dc2626;
|
|
20
|
+
--enigma-input-accent: #fbbf24;
|
|
21
|
+
|
|
22
|
+
/* The meter, worst to best. A headless package has no business deciding what "strong"
|
|
23
|
+
looks like on your brand, so the five bands are here rather than in the component. */
|
|
24
|
+
--enigma-strength-empty: #262626;
|
|
25
|
+
--enigma-strength-0: #dc2626;
|
|
26
|
+
--enigma-strength-1: #ea580c;
|
|
27
|
+
--enigma-strength-2: #eab308;
|
|
28
|
+
--enigma-strength-3: #84cc16;
|
|
29
|
+
--enigma-strength-4: #16a34a;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (prefers-color-scheme: light) {
|
|
33
|
+
:root {
|
|
34
|
+
--enigma-input-bg: #ffffff;
|
|
35
|
+
--enigma-input-border: #d4d4d4;
|
|
36
|
+
--enigma-input-border-focus: #737373;
|
|
37
|
+
--enigma-input-text: #171717;
|
|
38
|
+
--enigma-input-muted: #737373;
|
|
39
|
+
--enigma-strength-empty: #e5e5e5;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
3
42
|
|
|
4
43
|
[data-enigma-input-root] { display: grid; gap: 0.375rem; }
|
|
5
44
|
|
|
6
45
|
[data-enigma-input-field] {
|
|
7
46
|
display: flex; align-items: center; gap: 0.375rem;
|
|
8
|
-
padding:
|
|
9
|
-
background:
|
|
47
|
+
padding: var(--enigma-input-padding);
|
|
48
|
+
background: var(--enigma-input-bg);
|
|
49
|
+
border: 1px solid var(--enigma-input-border);
|
|
50
|
+
border-radius: var(--enigma-input-radius);
|
|
10
51
|
}
|
|
11
|
-
[data-enigma-input-field]:focus-within { border-color:
|
|
52
|
+
[data-enigma-input-field]:focus-within { border-color: var(--enigma-input-border-focus); }
|
|
12
53
|
|
|
13
54
|
[data-enigma-input] {
|
|
14
55
|
flex: 1; min-width: 0; padding: 0.625rem 0;
|
|
15
|
-
font-size:
|
|
56
|
+
font-size: var(--enigma-input-font-size); color: var(--enigma-input-text);
|
|
16
57
|
background: transparent; border: 0; outline: none;
|
|
17
58
|
}
|
|
18
59
|
|
|
19
60
|
/* A breached password is worth showing on the field itself, not only in the message. */
|
|
20
|
-
[data-enigma-input-root][data-breached] [data-enigma-input-field] { border-color:
|
|
61
|
+
[data-enigma-input-root][data-breached] [data-enigma-input-field] { border-color: var(--enigma-input-danger); }
|
|
21
62
|
|
|
22
63
|
[data-enigma-input-actions] { display: inline-flex; gap: 0.125rem; }
|
|
23
64
|
[data-enigma-input-actions][data-position="start"] { order: -1; }
|
|
@@ -25,30 +66,29 @@
|
|
|
25
66
|
[data-enigma-input-action] {
|
|
26
67
|
display: grid; place-items: center;
|
|
27
68
|
width: 1.75rem; height: 1.75rem;
|
|
28
|
-
color:
|
|
69
|
+
color: var(--enigma-input-muted); background: none; border: 0; border-radius: 0.375rem;
|
|
29
70
|
cursor: pointer; font-size: 0.9375rem;
|
|
30
71
|
}
|
|
31
|
-
[data-enigma-input-action]:hover { color:
|
|
32
|
-
[data-enigma-input-action][aria-pressed="true"] { color:
|
|
72
|
+
[data-enigma-input-action]:hover { color: var(--enigma-input-text); background: color-mix(in srgb, var(--enigma-input-border) 45%, transparent); }
|
|
73
|
+
[data-enigma-input-action][aria-pressed="true"] { color: var(--enigma-input-accent); }
|
|
33
74
|
[data-enigma-input-action]:disabled { opacity: 0.5; cursor: default; }
|
|
34
75
|
|
|
35
|
-
/* The meter. Five bars, one per score, red through green
|
|
36
|
-
a headless package has no business choosing what "strong" looks like on your brand. */
|
|
76
|
+
/* The meter. Five bars, one per score, red through green. */
|
|
37
77
|
[data-enigma-password-strength] { display: grid; gap: 0.25rem; }
|
|
38
78
|
[data-enigma-password-strength-track] { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.25rem; }
|
|
39
79
|
|
|
40
80
|
[data-enigma-password-strength-segment] {
|
|
41
|
-
height: 0.25rem; border-radius: 999px; background:
|
|
81
|
+
height: 0.25rem; border-radius: 999px; background: var(--enigma-strength-empty);
|
|
42
82
|
transition: background-color 120ms ease-out;
|
|
43
83
|
}
|
|
44
84
|
|
|
45
|
-
[data-score="0"] [data-enigma-password-strength-segment][data-filled] { background:
|
|
46
|
-
[data-score="1"] [data-enigma-password-strength-segment][data-filled] { background:
|
|
47
|
-
[data-score="2"] [data-enigma-password-strength-segment][data-filled] { background:
|
|
48
|
-
[data-score="3"] [data-enigma-password-strength-segment][data-filled] { background:
|
|
49
|
-
[data-score="4"] [data-enigma-password-strength-segment][data-filled] { background:
|
|
85
|
+
[data-score="0"] [data-enigma-password-strength-segment][data-filled] { background: var(--enigma-strength-0); }
|
|
86
|
+
[data-score="1"] [data-enigma-password-strength-segment][data-filled] { background: var(--enigma-strength-1); }
|
|
87
|
+
[data-score="2"] [data-enigma-password-strength-segment][data-filled] { background: var(--enigma-strength-2); }
|
|
88
|
+
[data-score="3"] [data-enigma-password-strength-segment][data-filled] { background: var(--enigma-strength-3); }
|
|
89
|
+
[data-score="4"] [data-enigma-password-strength-segment][data-filled] { background: var(--enigma-strength-4); }
|
|
50
90
|
|
|
51
|
-
[data-enigma-password-strength-label] { margin: 0; font-size: 0.75rem; color:
|
|
52
|
-
[data-enigma-password-strength-warning] { margin: 0; font-size: 0.75rem; color:
|
|
91
|
+
[data-enigma-password-strength-label] { margin: 0; font-size: 0.75rem; color: var(--enigma-input-muted); }
|
|
92
|
+
[data-enigma-password-strength-warning] { margin: 0; font-size: 0.75rem; color: var(--enigma-input-accent); }
|
|
53
93
|
/* An empty field is not a bad password: say nothing until there is something to say. */
|
|
54
94
|
[data-enigma-password-strength][data-empty] [data-enigma-password-strength-label] { visibility: hidden; }
|