@enigmax/primitives 0.23.0 → 0.25.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.
Files changed (40) hide show
  1. package/dist/{chunk-KEVZ5XQV.js → chunk-3MGBZOAU.js} +50 -9
  2. package/dist/{chunk-DSBYVA7V.js → chunk-DZMHY3SU.js} +73 -9
  3. package/dist/chunk-KVLSOQTI.js +66 -0
  4. package/dist/chunk-S2FPN5ID.js +115 -0
  5. package/dist/{chunk-3BQVOOAM.js → chunk-Z3VDE7OA.js} +145 -1
  6. package/dist/{context-menu-D3FtTn7v.d.ts → clipboard-menu-B_ouitfS.d.ts} +91 -1
  7. package/dist/color-D_rZ83Oc.d.ts +152 -0
  8. package/dist/color-T63FLJNH.js +515 -0
  9. package/dist/{index-DQNnohoo.d.ts → index-qXOkYQCU.d.ts} +56 -4
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +2 -1
  12. package/dist/next/index.d.ts +3 -3
  13. package/dist/next/index.js +6 -4
  14. package/dist/react/context-menu.d.ts +23 -6
  15. package/dist/react/context-menu.js +2 -2
  16. package/dist/react/index.d.ts +5 -5
  17. package/dist/react/index.js +6 -4
  18. package/dist/react/input.d.ts +2 -2
  19. package/dist/react/input.js +2 -1
  20. package/dist/react-router/index.d.ts +3 -3
  21. package/dist/react-router/index.js +6 -4
  22. package/package.json +3 -1
  23. package/recipes/color/styles.css +163 -0
  24. package/recipes/context-menu/styles.css +8 -0
  25. package/registry.json +86 -7
  26. package/src/core/clipboard-menu.ts +270 -0
  27. package/src/core/color.ts +248 -0
  28. package/src/index.ts +32 -0
  29. package/src/react/context-menu/context.ts +9 -2
  30. package/src/react/context-menu/index.tsx +14 -0
  31. package/src/react/context-menu/root.tsx +132 -8
  32. package/src/react/context-menu/styles.ts +8 -0
  33. package/src/react/index.ts +32 -0
  34. package/src/react/input/color-styles.ts +176 -0
  35. package/src/react/input/color-swatch.tsx +96 -0
  36. package/src/react/input/color.tsx +527 -0
  37. package/src/react/input/index.tsx +77 -6
  38. package/src/react/input/types.ts +63 -3
  39. package/dist/password-C8lG4Zm9.d.ts +0 -71
  40. /package/dist/{chunk-3HDEZ2E7.js → chunk-MSOCCQGH.js} +0 -0
@@ -12,6 +12,7 @@
12
12
  * are compile errors rather than props that quietly do nothing.
13
13
  */
14
14
 
15
+ import type { ColorFormat } from "@/core/color";
15
16
  import type { ComponentPropsWithoutRef, ReactNode } from "react";
16
17
  import type { SearchMatch, FuseConstructor, SearchOptions } from "@/core/search";
17
18
  import type { GeneratePasswordOptions, EstimateOptions, PasswordStrengthReport } from "@/core/password";
@@ -135,12 +136,71 @@ export interface SearchOnlyProps<Item = unknown> {
135
136
  clearLabel?: string;
136
137
  }
137
138
 
139
+ /** Which side of the field the picker's panel opens on. `auto` measures the room there is. */
140
+ export type ColorPanelPlacement = "auto" | "top" | "bottom";
141
+
142
+ /** The picker's accessible names, for a UI that is not in English. */
143
+ export interface ColorLabels {
144
+ /** The swatch that opens the panel. */
145
+ open?: string;
146
+ /** The panel itself. */
147
+ panel?: string;
148
+ /** The saturation and brightness square. */
149
+ area?: string;
150
+ hue?: string;
151
+ alpha?: string;
152
+ eyedropper?: string;
153
+ swatches?: string;
154
+ /** The editable readout under the rails. Default "Colour value". */
155
+ value?: string;
156
+ /** The button that cycles the readout between HEX, RGB and HSL. Default "Show as". */
157
+ formatAs?: string;
158
+ /** The word before the colour in what a screen reader announces. Default "Colour". */
159
+ color?: string;
160
+ }
161
+
162
+ /** The half only a colour field has. */
163
+ export interface ColorOnlyProps {
164
+ type: "color";
165
+ /**
166
+ * How the picker writes the value back: `#3b82f6`, `rgb(59, 130, 246)` or an `hsl()`.
167
+ * Default hex. Whatever the format, every one of them is READ - a pasted `rgb()` in a hex
168
+ * field is understood and normalized on blur rather than rejected.
169
+ */
170
+ format?: ColorFormat;
171
+ /**
172
+ * The opacity rail, and the alpha channel in the value. OFF by default: it turns
173
+ * `#3b82f6` into `#3b82f680`, which is not what a column typed as a 7-character hex, or a
174
+ * `<input type="color">` on the server side, is expecting.
175
+ */
176
+ alpha?: boolean;
177
+ /** Preset colours under the rails - a brand palette, or the last few that were used. */
178
+ swatches?: readonly string[];
179
+ /**
180
+ * The screen eyedropper, where the browser has one (Chromium today). Default true, and
181
+ * feature-detected: the button is not rendered at all where the API is missing.
182
+ */
183
+ eyedropper?: boolean;
184
+ /** Which side the panel opens on. Default `auto`, which flips near the bottom of the window. */
185
+ placement?: ColorPanelPlacement;
186
+ /**
187
+ * The panel's baseline stylesheet, injected once. Default true, and the one place this
188
+ * package ships a look - see `color-styles.ts` for why a picker cannot be unstyled.
189
+ */
190
+ styles?: boolean;
191
+ colorLabels?: ColorLabels;
192
+ }
193
+
138
194
  /** Everything else: one `<input>`, its native props, and no extras to bundle. */
139
195
  export interface PlainOnlyProps {
140
- type?: Exclude<InputType, "password" | "search">;
196
+ type?: Exclude<InputType, "password" | "search" | "color">;
141
197
  }
142
198
 
143
- export type InputProps<Item = unknown> = InputBaseProps & (PasswordOnlyProps | SearchOnlyProps<Item> | PlainOnlyProps);
199
+ export type InputProps<Item = unknown> = InputBaseProps & (PasswordOnlyProps | SearchOnlyProps<Item> | ColorOnlyProps | PlainOnlyProps);
144
200
 
145
201
  /** Everything the implementation reads, after the union has done its job at the call site. */
146
- export type AnyInputProps<Item = unknown> = InputBaseProps & Partial<Omit<PasswordOnlyProps, "type">> & Partial<Omit<SearchOnlyProps<Item>, "type">> & { type?: InputType; };
202
+ export type AnyInputProps<Item = unknown> = InputBaseProps
203
+ & Partial<Omit<PasswordOnlyProps, "type">>
204
+ & Partial<Omit<SearchOnlyProps<Item>, "type">>
205
+ & Partial<Omit<ColorOnlyProps, "type">>
206
+ & { type?: InputType; };
@@ -1,71 +0,0 @@
1
- /**
2
- * Making a password, and judging one.
3
- *
4
- * Both are opt-in. A sign-in form wants neither: offering to generate a password where one
5
- * already exists is noise, and scoring one the visitor cannot change is worse. They belong
6
- * on a registration form and a change-password form, which is where an agent should switch
7
- * them on.
8
- */
9
- /** Character classes a generated password can draw from. */
10
- interface PasswordAlphabet {
11
- lowercase?: boolean;
12
- uppercase?: boolean;
13
- digits?: boolean;
14
- symbols?: boolean;
15
- }
16
- interface GeneratePasswordOptions extends PasswordAlphabet {
17
- /** Default 20. Long beats clever: length is the only term that scales. */
18
- length?: number;
19
- /**
20
- * Drop the characters that are read wrong off a screen or off paper - I l 1 O 0.
21
- * Worth it when the password will be typed by hand, not worth the entropy otherwise.
22
- */
23
- excludeAmbiguous?: boolean;
24
- /** Characters to remove from every class, e.g. ones your backend rejects. */
25
- exclude?: string;
26
- /**
27
- * Guarantee at least one character from every class asked for. Most password policies
28
- * demand it; it costs a little entropy, because it removes every password that happens
29
- * to lack one.
30
- */
31
- requireEachClass?: boolean;
32
- }
33
- /**
34
- * A random password from the classes asked for.
35
- *
36
- * @throws when the runtime has no CSPRNG, or when the options ask for something impossible
37
- * (every class excluded, or a length too short to hold one of each).
38
- */
39
- declare function generatePassword(options?: GeneratePasswordOptions): string;
40
- type PasswordScore = 0 | 1 | 2 | 3 | 4;
41
- interface PasswordStrengthReport {
42
- /** 0 worst, 4 best. What the bars under the field render. */
43
- score: PasswordScore;
44
- /** Estimated bits of entropy after the penalties below. */
45
- bits: number;
46
- /**
47
- * Why it scored what it scored, worst first. Show the first one; showing all of them
48
- * turns a hint into a lecture.
49
- */
50
- warnings: string[];
51
- /** Empty field. Render nothing rather than a zero score, which reads as a failure. */
52
- empty: boolean;
53
- }
54
- interface EstimateOptions {
55
- /**
56
- * Values the visitor has already typed elsewhere - email, name, company. A password
57
- * containing one of them is guessable by anyone who has the sign-up form in front of
58
- * them, and no character-class rule catches it.
59
- */
60
- userInputs?: string[];
61
- }
62
- /**
63
- * Score a password.
64
- *
65
- * The bits are an estimate and the bands are a convention, not a measurement - they exist
66
- * to move a bar, not to certify anything. Swap this out for zxcvbn where the number has to
67
- * mean something, and check the breach corpus for the cases no estimator can see.
68
- */
69
- declare function estimatePasswordStrength(password: string, options?: EstimateOptions): PasswordStrengthReport;
70
-
71
- export { type EstimateOptions as E, type GeneratePasswordOptions as G, type PasswordAlphabet as P, type PasswordScore as a, type PasswordStrengthReport as b, estimatePasswordStrength as e, generatePassword as g };
File without changes