@llui/components 0.0.6 → 0.0.8

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 (38) hide show
  1. package/dist/components/date-picker.d.ts +12 -0
  2. package/dist/components/date-picker.d.ts.map +1 -1
  3. package/dist/components/date-picker.js +18 -1
  4. package/dist/components/file-upload.d.ts +1 -0
  5. package/dist/components/file-upload.d.ts.map +1 -1
  6. package/dist/components/file-upload.js +1 -0
  7. package/dist/components/form.d.ts +115 -0
  8. package/dist/components/form.d.ts.map +1 -0
  9. package/dist/components/form.js +102 -0
  10. package/dist/components/hover-card.d.ts +0 -1
  11. package/dist/components/hover-card.d.ts.map +1 -1
  12. package/dist/components/hover-card.js +0 -1
  13. package/dist/components/index.d.ts +9 -0
  14. package/dist/components/index.d.ts.map +1 -1
  15. package/dist/components/index.js +6 -0
  16. package/dist/components/scroll-area.d.ts +1 -0
  17. package/dist/components/scroll-area.d.ts.map +1 -1
  18. package/dist/components/scroll-area.js +1 -0
  19. package/dist/components/sortable.d.ts +146 -0
  20. package/dist/components/sortable.d.ts.map +1 -0
  21. package/dist/components/sortable.js +311 -0
  22. package/dist/components/tags-input.d.ts +0 -1
  23. package/dist/components/tags-input.d.ts.map +1 -1
  24. package/dist/components/tags-input.js +0 -1
  25. package/dist/components/theme-switch.d.ts +89 -0
  26. package/dist/components/theme-switch.d.ts.map +1 -0
  27. package/dist/components/theme-switch.js +96 -0
  28. package/dist/components/toggle-group.d.ts +0 -1
  29. package/dist/components/toggle-group.d.ts.map +1 -1
  30. package/dist/components/toggle-group.js +0 -1
  31. package/dist/styles/classes/listbox.js +1 -1
  32. package/dist/styles/classes/select.js +1 -1
  33. package/dist/styles/theme-dark.css +2 -0
  34. package/dist/styles/theme.css +3 -3
  35. package/dist/utils/validators.d.ts +34 -0
  36. package/dist/utils/validators.d.ts.map +1 -0
  37. package/dist/utils/validators.js +83 -0
  38. package/package.json +4 -3
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Composable validators returning `string | null` (null = valid).
3
+ *
4
+ * Use `compose(v1, v2, ...)` to run until first failure (short-circuit),
5
+ * or `validateAll(v1, v2, ...)` to collect all errors as `string[]`.
6
+ *
7
+ * ```ts
8
+ * const username = compose(required(), minLength(3), pattern(/^[a-z]+$/i))
9
+ * username('') // 'Required'
10
+ * username('ab') // 'Must be at least 3 characters'
11
+ * username('foo') // null
12
+ * ```
13
+ */
14
+ export type Validator<T> = (value: T) => string | null;
15
+ export declare function required(message?: string): Validator<unknown>;
16
+ export declare function minLength(n: number, message?: string): Validator<string>;
17
+ export declare function maxLength(n: number, message?: string): Validator<string>;
18
+ export declare function pattern(regex: RegExp, message?: string): Validator<string>;
19
+ export declare function email(message?: string): Validator<string>;
20
+ export declare function url(message?: string): Validator<string>;
21
+ export declare function min(n: number, message?: string): Validator<number>;
22
+ export declare function max(n: number, message?: string): Validator<number>;
23
+ export declare function integer(message?: string): Validator<number>;
24
+ export declare function positive(message?: string): Validator<number>;
25
+ /**
26
+ * Run validators in order, returning the first error (or null if all pass).
27
+ */
28
+ export declare function compose<T>(...validators: Validator<T>[]): Validator<T>;
29
+ /**
30
+ * Run every validator and collect all errors. Returns empty array when valid.
31
+ * Use when you want to display multiple errors at once (e.g. password rules).
32
+ */
33
+ export declare function validateAll<T>(...validators: Validator<T>[]): (value: T) => string[];
34
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;AAStD,wBAAgB,QAAQ,CAAC,OAAO,SAAa,GAAG,SAAS,CAAC,OAAO,CAAC,CAEjE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAGxE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAGxE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAmB,GAAG,SAAS,CAAC,MAAM,CAAC,CAEpF;AAKD,wBAAgB,KAAK,CAAC,OAAO,SAAkB,GAAG,SAAS,CAAC,MAAM,CAAC,CAElE;AAED,wBAAgB,GAAG,CAAC,OAAO,SAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,CAU9D;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAGlE;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAGlE;AAED,wBAAgB,OAAO,CAAC,OAAO,SAAuB,GAAG,SAAS,CAAC,MAAM,CAAC,CAEzE;AAED,wBAAgB,QAAQ,CAAC,OAAO,SAAqB,GAAG,SAAS,CAAC,MAAM,CAAC,CAExE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAQtE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,CASpF"}
@@ -0,0 +1,83 @@
1
+ function isEmpty(v) {
2
+ if (v === null || v === undefined)
3
+ return true;
4
+ if (typeof v === 'string' && v.length === 0)
5
+ return true;
6
+ if (Array.isArray(v) && v.length === 0)
7
+ return true;
8
+ return false;
9
+ }
10
+ export function required(message = 'Required') {
11
+ return (value) => (isEmpty(value) ? message : null);
12
+ }
13
+ export function minLength(n, message) {
14
+ const msg = message ?? `Must be at least ${n} characters`;
15
+ return (value) => (value.length < n ? msg : null);
16
+ }
17
+ export function maxLength(n, message) {
18
+ const msg = message ?? `Must be at most ${n} characters`;
19
+ return (value) => (value.length > n ? msg : null);
20
+ }
21
+ export function pattern(regex, message = 'Invalid format') {
22
+ return (value) => (regex.test(value) ? null : message);
23
+ }
24
+ // RFC 5322 simplified — accepts most valid emails, rejects obvious garbage
25
+ const EMAIL_RE = /^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/;
26
+ export function email(message = 'Invalid email') {
27
+ return (value) => (EMAIL_RE.test(value) ? null : message);
28
+ }
29
+ export function url(message = 'Invalid URL') {
30
+ return (value) => {
31
+ try {
32
+ const u = new URL(value);
33
+ if (u.protocol !== 'http:' && u.protocol !== 'https:')
34
+ return message;
35
+ return null;
36
+ }
37
+ catch {
38
+ return message;
39
+ }
40
+ };
41
+ }
42
+ export function min(n, message) {
43
+ const msg = message ?? `Must be at least ${n}`;
44
+ return (value) => (value < n ? msg : null);
45
+ }
46
+ export function max(n, message) {
47
+ const msg = message ?? `Must be at most ${n}`;
48
+ return (value) => (value > n ? msg : null);
49
+ }
50
+ export function integer(message = 'Must be an integer') {
51
+ return (value) => (Number.isInteger(value) ? null : message);
52
+ }
53
+ export function positive(message = 'Must be positive') {
54
+ return (value) => (value > 0 ? null : message);
55
+ }
56
+ /**
57
+ * Run validators in order, returning the first error (or null if all pass).
58
+ */
59
+ export function compose(...validators) {
60
+ return (value) => {
61
+ for (const v of validators) {
62
+ const err = v(value);
63
+ if (err !== null)
64
+ return err;
65
+ }
66
+ return null;
67
+ };
68
+ }
69
+ /**
70
+ * Run every validator and collect all errors. Returns empty array when valid.
71
+ * Use when you want to display multiple errors at once (e.g. password rules).
72
+ */
73
+ export function validateAll(...validators) {
74
+ return (value) => {
75
+ const errors = [];
76
+ for (const v of validators) {
77
+ const err = v(value);
78
+ if (err !== null)
79
+ errors.push(err);
80
+ }
81
+ return errors;
82
+ };
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llui/components",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -463,7 +463,7 @@
463
463
  "test": "vitest run"
464
464
  },
465
465
  "peerDependencies": {
466
- "@llui/dom": "^0.0.6"
466
+ "@llui/dom": "^0.0.8"
467
467
  },
468
468
  "devDependencies": {
469
469
  "@llui/dom": "workspace:*",
@@ -475,7 +475,8 @@
475
475
  "./dist/styles/theme-dark.css"
476
476
  ],
477
477
  "dependencies": {
478
- "@floating-ui/dom": "^1.7.6"
478
+ "@floating-ui/dom": "^1.7.6",
479
+ "@standard-schema/spec": "^1.0.0"
479
480
  },
480
481
  "description": "54 headless UI components for LLui — accordion, dialog, tabs, select, tree-view, timer, tour, and more",
481
482
  "keywords": [