domma-js 0.56.0 → 0.58.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 (121) hide show
  1. package/README.md +2 -2
  2. package/assets/types/generated/public/assets/flags/africa.d.ts +6 -0
  3. package/assets/types/generated/public/assets/flags/americas.d.ts +6 -0
  4. package/assets/types/generated/public/assets/flags/asia.d.ts +6 -0
  5. package/assets/types/generated/public/assets/flags/europe.d.ts +9 -0
  6. package/assets/types/generated/public/assets/flags/index.d.ts +11 -0
  7. package/assets/types/generated/public/assets/flags/oceania.d.ts +2 -0
  8. package/assets/types/generated/public/assets/icons/buildings.d.ts +6 -0
  9. package/assets/types/generated/public/assets/icons/code.d.ts +2 -0
  10. package/assets/types/generated/public/assets/icons/commerce.d.ts +7 -0
  11. package/assets/types/generated/public/assets/icons/communication.d.ts +7 -0
  12. package/assets/types/generated/public/assets/icons/devices.d.ts +6 -0
  13. package/assets/types/generated/public/assets/icons/emojis.d.ts +6 -0
  14. package/assets/types/generated/public/assets/icons/files.d.ts +7 -0
  15. package/assets/types/generated/public/assets/icons/finance.d.ts +6 -0
  16. package/assets/types/generated/public/assets/icons/forms.d.ts +5 -0
  17. package/assets/types/generated/public/assets/icons/health.d.ts +6 -0
  18. package/assets/types/generated/public/assets/icons/index.d.ts +24 -0
  19. package/assets/types/generated/public/assets/icons/media.d.ts +7 -0
  20. package/assets/types/generated/public/assets/icons/navigation.d.ts +7 -0
  21. package/assets/types/generated/public/assets/icons/seasonal.d.ts +6 -0
  22. package/assets/types/generated/public/assets/icons/social.d.ts +7 -0
  23. package/assets/types/generated/public/assets/icons/sport.d.ts +6 -0
  24. package/assets/types/generated/public/assets/icons/status.d.ts +7 -0
  25. package/assets/types/generated/public/assets/icons/transport.d.ts +7 -0
  26. package/assets/types/generated/public/assets/icons/ui.d.ts +7 -0
  27. package/assets/types/generated/public/assets/icons/weather.d.ts +6 -0
  28. package/assets/types/generated/src/auth.d.ts +424 -0
  29. package/assets/types/generated/src/avatar.d.ts +270 -0
  30. package/assets/types/generated/src/binding-source.d.ts +58 -0
  31. package/assets/types/generated/src/butterfly-drawing.d.ts +2 -0
  32. package/assets/types/generated/src/component-factory.d.ts +150 -0
  33. package/assets/types/generated/src/component.d.ts +162 -0
  34. package/assets/types/generated/src/components/back-to-top.d.ts +150 -0
  35. package/assets/types/generated/src/components/badge.d.ts +208 -0
  36. package/assets/types/generated/src/components/card.d.ts +189 -0
  37. package/assets/types/generated/src/components/command-palette.d.ts +352 -0
  38. package/assets/types/generated/src/components/dropzone.d.ts +342 -0
  39. package/assets/types/generated/src/components/focus-trap.d.ts +238 -0
  40. package/assets/types/generated/src/components/loader.d.ts +133 -0
  41. package/assets/types/generated/src/components/modal.d.ts +339 -0
  42. package/assets/types/generated/src/components/range-slider.d.ts +267 -0
  43. package/assets/types/generated/src/components/shared.d.ts +91 -0
  44. package/assets/types/generated/src/components/split-pane.d.ts +239 -0
  45. package/assets/types/generated/src/components/toast.d.ts +284 -0
  46. package/assets/types/generated/src/components/tooltip.d.ts +200 -0
  47. package/assets/types/generated/src/components/virtual-list.d.ts +340 -0
  48. package/assets/types/generated/src/config.d.ts +193 -0
  49. package/assets/types/generated/src/context-cursor.d.ts +69 -0
  50. package/assets/types/generated/src/context-menu.d.ts +596 -0
  51. package/assets/types/generated/src/dates.d.ts +367 -0
  52. package/assets/types/generated/src/dom.d.ts +1221 -0
  53. package/assets/types/generated/src/effects.d.ts +1281 -0
  54. package/assets/types/generated/src/elements.d.ts +4994 -0
  55. package/assets/types/generated/src/escape.d.ts +5 -0
  56. package/assets/types/generated/src/flags-bundle.d.ts +4 -0
  57. package/assets/types/generated/src/flags.d.ts +338 -0
  58. package/assets/types/generated/src/forms.d.ts +1060 -0
  59. package/assets/types/generated/src/globals.d.ts +45 -0
  60. package/assets/types/generated/src/http.d.ts +131 -0
  61. package/assets/types/generated/src/i18n.d.ts +261 -0
  62. package/assets/types/generated/src/icons.d.ts +213 -0
  63. package/assets/types/generated/src/index.d.ts +249 -0
  64. package/assets/types/generated/src/input-group.d.ts +135 -0
  65. package/assets/types/generated/src/models.d.ts +968 -0
  66. package/assets/types/generated/src/popover.d.ts +413 -0
  67. package/assets/types/generated/src/router.d.ts +344 -0
  68. package/assets/types/generated/src/safe-url.d.ts +10 -0
  69. package/assets/types/generated/src/sanitize.d.ts +97 -0
  70. package/assets/types/generated/src/schema-builder.d.ts +420 -0
  71. package/assets/types/generated/src/skeleton.d.ts +135 -0
  72. package/assets/types/generated/src/smooth-caret.d.ts +61 -0
  73. package/assets/types/generated/src/sortable.d.ts +368 -0
  74. package/assets/types/generated/src/storage.d.ts +93 -0
  75. package/assets/types/generated/src/tables.d.ts +901 -0
  76. package/assets/types/generated/src/theme.d.ts +262 -0
  77. package/assets/types/generated/src/ticker-tape-drawing.d.ts +2 -0
  78. package/assets/types/generated/src/treeview.d.ts +504 -0
  79. package/assets/types/generated/src/utils.d.ts +1667 -0
  80. package/assets/types/generated/src/web-components/base/domma-element.d.ts +134 -0
  81. package/assets/types/generated/src/web-components/index.d.ts +14 -0
  82. package/assets/types/generated/vendor/domma-reactive.d.ts +587 -0
  83. package/assets/types/index.d.ts +104 -226
  84. package/package.json +5 -2
  85. package/public/dist/bundles/domma-complete.css +20 -14
  86. package/public/dist/bundles/domma-data-focused.css +20 -14
  87. package/public/dist/bundles/domma-essentials.css +20 -14
  88. package/public/dist/bundles/domma-full.css +20 -14
  89. package/public/dist/bundles/domma-minimal.css +8 -8
  90. package/public/dist/domma-flags.esm.js +3 -3
  91. package/public/dist/domma-flags.esm.js.map +1 -1
  92. package/public/dist/domma-flags.min.js +3 -3
  93. package/public/dist/domma-flags.min.js.map +1 -1
  94. package/public/dist/domma-syntax.min.js +3 -3
  95. package/public/dist/domma.css +3 -3
  96. package/public/dist/domma.esm.js +5 -5
  97. package/public/dist/domma.esm.js.map +1 -1
  98. package/public/dist/domma.min.js +5 -5
  99. package/public/dist/domma.min.js.map +1 -1
  100. package/public/dist/elements.css +9 -3
  101. package/public/dist/grid.css +3 -3
  102. package/public/dist/syntax.css +3 -3
  103. package/public/dist/themes/domma-themes.css +3 -3
  104. package/templates/kickstart/.claude/snippets.md +1 -1
  105. package/templates/kickstart/CLAUDE.md +1 -1
  106. package/templates/kickstart/frontend/types/domma.d.ts +7 -4
  107. package/templates/kickstart-spa/.claude/snippets.md +1 -1
  108. package/assets/types/config.d.ts +0 -136
  109. package/assets/types/dates.d.ts +0 -209
  110. package/assets/types/dom.d.ts +0 -448
  111. package/assets/types/elements.d.ts +0 -1168
  112. package/assets/types/flags.d.ts +0 -130
  113. package/assets/types/http.d.ts +0 -97
  114. package/assets/types/i18n.d.ts +0 -99
  115. package/assets/types/icons.d.ts +0 -147
  116. package/assets/types/models.d.ts +0 -260
  117. package/assets/types/smooth-caret.d.ts +0 -12
  118. package/assets/types/storage.d.ts +0 -93
  119. package/assets/types/tables.d.ts +0 -327
  120. package/assets/types/theme.d.ts +0 -137
  121. package/assets/types/utils.d.ts +0 -675
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Read a load-time option from `window.DommaOptions`.
3
+ * @param {keyof DommaLoadOptions} key
4
+ * @param {*} fallback
5
+ * @returns {*}
6
+ */
7
+ export function loadOption(key: keyof DommaLoadOptions, fallback: any): any;
8
+ /**
9
+ * Install Domma and its aliases on `window`, and attach `Domma.noConflict`.
10
+ * @param {Function} Domma - The Domma function
11
+ * @param {Object<string, *>} aliases - Alias name -> value
12
+ * @returns {Function} Domma
13
+ */
14
+ export function installGlobals(Domma: Function, aliases: {
15
+ [x: string]: any;
16
+ }): Function;
17
+ /**
18
+ * Options read from `window.DommaOptions` when Domma loads - set it before the script tag.
19
+ */
20
+ export type DommaLoadOptions = {
21
+ /**
22
+ * true (default): every alias; 'safe': only aliases nobody else owns; false: window.Domma only
23
+ */
24
+ globals?: boolean | "safe";
25
+ /**
26
+ * false: never add the `dm-cloaked` class
27
+ */
28
+ cloak?: boolean;
29
+ /**
30
+ * false: don't initialise the theme engine automatically
31
+ */
32
+ theme?: boolean;
33
+ /**
34
+ * false: no console warning when DOMPurify is missing
35
+ */
36
+ purifyWarning?: boolean;
37
+ /**
38
+ * false: no deprecation warnings
39
+ */
40
+ deprecationWarnings?: boolean;
41
+ /**
42
+ * false: no console warning for a missing translation
43
+ */
44
+ i18nWarnings?: boolean;
45
+ };
@@ -0,0 +1,131 @@
1
+ export namespace http {
2
+ /**
3
+ * Make a request with any method.
4
+ * @template [T=any]
5
+ * @param {HttpMethod} method HTTP method
6
+ * @param {string} url Request URL
7
+ * @param {any} [data] Body - JSON-encoded unless FormData, URLSearchParams, Blob, ArrayBuffer/view or a stream. Not sent for GET/HEAD.
8
+ * @param {RequestOptions} [config] Request options
9
+ * @returns {Promise<T>} The response body
10
+ */
11
+ export function request<T = any>(method: HttpMethod, url: string, data?: any, config?: RequestOptions): Promise<T>;
12
+ /**
13
+ * Make a GET request.
14
+ * @template [T=any]
15
+ * @param {string} url Request URL
16
+ * @param {RequestOptions} [config] Request options
17
+ * @returns {Promise<T>} The response body
18
+ */
19
+ export function get<T = any>(url: string, config?: RequestOptions): Promise<T>;
20
+ /**
21
+ * Make a POST request.
22
+ * @template [T=any]
23
+ * @param {string} url Request URL
24
+ * @param {any} [data] Request body (JSON-encoded unless a raw body such as FormData)
25
+ * @param {RequestOptions} [config] Request options
26
+ * @returns {Promise<T>} The response body
27
+ */
28
+ export function post<T = any>(url: string, data?: any, config?: RequestOptions): Promise<T>;
29
+ /**
30
+ * Make a PUT request.
31
+ * @template [T=any]
32
+ * @param {string} url Request URL
33
+ * @param {any} [data] Request body (JSON-encoded unless a raw body such as FormData)
34
+ * @param {RequestOptions} [config] Request options
35
+ * @returns {Promise<T>} The response body
36
+ */
37
+ export function put<T = any>(url: string, data?: any, config?: RequestOptions): Promise<T>;
38
+ /**
39
+ * Make a PATCH request.
40
+ * @template [T=any]
41
+ * @param {string} url Request URL
42
+ * @param {any} [data] Request body (JSON-encoded unless a raw body such as FormData)
43
+ * @param {RequestOptions} [config] Request options
44
+ * @returns {Promise<T>} The response body
45
+ */
46
+ export function patch<T = any>(url: string, data?: any, config?: RequestOptions): Promise<T>;
47
+ /**
48
+ * Make a DELETE request. DELETE sends no body unless one is given as `config.data`.
49
+ * @template [T=any]
50
+ * @param {string} url Request URL
51
+ * @param {DeleteRequestOptions} [config] Request options
52
+ * @returns {Promise<T>} The response body
53
+ */
54
+ function _delete<T = any>(url: string, config?: DeleteRequestOptions): Promise<T>;
55
+ export { _delete as delete };
56
+ /**
57
+ * Make a HEAD request.
58
+ * @template [T=any]
59
+ * @param {string} url Request URL
60
+ * @param {RequestOptions} [config] Request options
61
+ * @returns {Promise<T>} The response body
62
+ */
63
+ export function head<T = any>(url: string, config?: RequestOptions): Promise<T>;
64
+ /**
65
+ * Make a OPTIONS request.
66
+ * @template [T=any]
67
+ * @param {string} url Request URL
68
+ * @param {RequestOptions} [config] Request options
69
+ * @returns {Promise<T>} The response body
70
+ */
71
+ export function options<T = any>(url: string, config?: RequestOptions): Promise<T>;
72
+ }
73
+ /**
74
+ * Options for a request. Anything not listed by name here is passed to `fetch()` as it is.
75
+ */
76
+ export type RequestOptions = Omit<RequestInit, "method" | keyof RequestOwnOptions> & RequestOwnOptions;
77
+ /**
78
+ * The options Domma reads itself (the rest of {@link RequestOptions} goes to `fetch()`).
79
+ */
80
+ export type RequestOwnOptions = {
81
+ /**
82
+ * Request headers (plain object, `Headers` or entry pairs); copied, never mutated.
83
+ * `Content-Type: application/json` is added for a JSON body unless one is given.
84
+ */
85
+ headers?: HeadersInit;
86
+ /**
87
+ * Do not log a failure to the console (useful for expected errors such as a 401 check).
88
+ */
89
+ silent?: boolean;
90
+ /**
91
+ * Abort after this many milliseconds (rejects with a `TimeoutError`).
92
+ */
93
+ timeout?: number;
94
+ /**
95
+ * Defaults to `'same-origin'`; pass `'include'` to send cookies cross-origin.
96
+ */
97
+ credentials?: RequestCredentials;
98
+ /**
99
+ * Abort signal, composed with `timeout` (whichever fires first aborts).
100
+ */
101
+ signal?: AbortSignal;
102
+ mode?: RequestMode;
103
+ cache?: RequestCache;
104
+ redirect?: RequestRedirect;
105
+ referrer?: string;
106
+ referrerPolicy?: ReferrerPolicy;
107
+ integrity?: string;
108
+ keepalive?: boolean;
109
+ };
110
+ /**
111
+ * Options for `http.delete()`: a body is sent only when given as `data`.
112
+ */
113
+ export type DeleteRequestOptions = RequestOptions & {
114
+ data?: any;
115
+ };
116
+ /**
117
+ * The error a failed request rejects with: the server's `message` (or `error`) from a JSON body,
118
+ * otherwise `HTTP Error: <status> <statusText>`.
119
+ */
120
+ export type HttpError = Error & {
121
+ status?: number;
122
+ statusText?: string;
123
+ body?: any;
124
+ };
125
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | (string & {});
126
+ /**
127
+ * Fetch-based HTTP client. Every method resolves to the response BODY (not a response object):
128
+ * parsed JSON for a JSON or unlabelled body, text for any other type, `null` when there is no body
129
+ * (204/205/304, HEAD, an empty body). A non-2xx status rejects with an {@link HttpError}.
130
+ */
131
+ export type Http = typeof http;
@@ -0,0 +1,261 @@
1
+ export namespace i18n {
2
+ /**
3
+ * Add messages for a locale. Nested objects become dot keys; later calls merge (a key
4
+ * already there is replaced, everything else is kept).
5
+ * @param {string} locale
6
+ * @param {I18nMessages} source
7
+ * @returns {I18n} i18n
8
+ */
9
+ function add(locale: string, source: I18nMessages): I18n;
10
+ /**
11
+ * Load a locale's messages from a JSON URL (via H.get) or a loader function returning a
12
+ * Promise of messages. The result is cached, and a load already under way is shared, so
13
+ * calling this from three places makes one request. A failed load is not cached.
14
+ * `{locale}` in the URL is replaced with the code.
15
+ * @param {string} locale
16
+ * @param {string|((locale: string) => Promise<I18nMessages>|I18nMessages)} source - URL, or () => Promise<Object>
17
+ * @param {{reload?: boolean}} [options]
18
+ * @returns {Promise<I18nMessages>} The messages loaded
19
+ */
20
+ function load(locale: string, source: string | ((locale: string) => Promise<I18nMessages> | I18nMessages), options?: {
21
+ reload?: boolean;
22
+ }): Promise<I18nMessages>;
23
+ /**
24
+ * Get the current locale.
25
+ * @overload
26
+ * @returns {string} The current locale
27
+ */
28
+ function locale(): string;
29
+ /**
30
+ * Set the locale: fires change, sets <html lang dir>, re-translates the document.
31
+ * @overload
32
+ * @param {string} code
33
+ * @returns {string} The current locale
34
+ */
35
+ function locale(code: string): string;
36
+ /**
37
+ * Set the fallback locale(s) searched after the current one (and its parent language).
38
+ * With no argument, returns them.
39
+ * @param {string|string[]} [codes]
40
+ * @returns {string[]}
41
+ */
42
+ function fallback(codes?: string | string[]): string[];
43
+ /**
44
+ * Whether a key has a message in the current locale or its fallbacks.
45
+ * @param {string} key
46
+ * @param {{locale?: string}} [options]
47
+ * @returns {boolean}
48
+ */
49
+ function has(key: string, options?: {
50
+ locale?: string;
51
+ }): boolean;
52
+ /**
53
+ * Translate a key to plain text. Params fill `{name}` placeholders (not escaped - this is
54
+ * text, not HTML); `count` chooses a plural form. A missing key returns `default` (itself
55
+ * interpolated) or the key.
56
+ * @param {string} key
57
+ * @param {Record<string, any>|null} [params]
58
+ * @param {I18nTranslateOptions} [options]
59
+ * @returns {string}
60
+ */
61
+ function t(key: string, params?: Record<string, any> | null, options?: I18nTranslateOptions): string;
62
+ /**
63
+ * Translate a key to HTML: the message's own markup is kept and every param is escaped.
64
+ * The message itself is trusted (it is yours); `translate()` sanitises before inserting.
65
+ * @param {string} key
66
+ * @param {Record<string, any>|null} [params]
67
+ * @param {I18nTranslateOptions} [options] - As for t()
68
+ * @returns {string}
69
+ */
70
+ function html(key: string, params?: Record<string, any> | null, options?: I18nTranslateOptions): string;
71
+ /**
72
+ * Register the hook for a missing key: fn(key, locale). A string it returns is used as the
73
+ * translation. Pass null to remove it.
74
+ * @param {((key: string, locale: string) => string|void)|null} fn
75
+ * @returns {I18n} i18n
76
+ */
77
+ function onMissing(fn: ((key: string, locale: string) => string | void) | null): I18n;
78
+ /**
79
+ * @overload
80
+ * @param {'change'} event
81
+ * @param {(detail: I18nChangeDetail) => void} fn
82
+ * @returns {() => void} Unsubscribe
83
+ */
84
+ function on(event: "change", fn: (detail: I18nChangeDetail) => void): () => void;
85
+ /**
86
+ * @overload
87
+ * @param {'missing'} event
88
+ * @param {(detail: I18nMissingDetail) => void} fn
89
+ * @returns {() => void} Unsubscribe
90
+ */
91
+ function on(event: "missing", fn: (detail: I18nMissingDetail) => void): () => void;
92
+ /**
93
+ * @overload
94
+ * @param {'loaded'} event
95
+ * @param {(detail: I18nLoadedDetail) => void} fn
96
+ * @returns {() => void} Unsubscribe
97
+ */
98
+ function on(event: "loaded", fn: (detail: I18nLoadedDetail) => void): () => void;
99
+ /**
100
+ * Unsubscribe (with no fn, every listener for that event).
101
+ * @param {'change'|'missing'|'loaded'} event
102
+ * @param {(...args: any[]) => void} [fn]
103
+ * @returns {I18n} i18n
104
+ */
105
+ function off(event: "change" | "missing" | "loaded", fn?: (...args: any[]) => void): I18n;
106
+ /** @returns {string[]} Locales that have messages */
107
+ function locales(): string[];
108
+ /**
109
+ * Text direction of a locale: 'rtl' or 'ltr'.
110
+ * @param {string} [code] - Defaults to the current locale
111
+ * @returns {'rtl'|'ltr'}
112
+ */
113
+ function dir(code?: string): "rtl" | "ltr";
114
+ /**
115
+ * Fill translations in the DOM: `[data-i18n]` (textContent), `[data-i18n-html]` (sanitised
116
+ * HTML), `[data-i18n-attr="placeholder:key; title:key2"]`, each taking params from
117
+ * `data-i18n-params` (JSON). What the page first said is kept and shown when a key is
118
+ * missing, so authored text doubles as the default. Call it on content you add later.
119
+ * @param {Element|Document|string|ArrayLike<Element>} [root=document] - Element, selector or Domma collection
120
+ * @returns {number} Elements translated
121
+ */
122
+ function translate(root?: Element | Document | string | ArrayLike<Element>): number;
123
+ /**
124
+ * Pick a locale from storage, the browser and/or `<html lang>`, in the order given, set
125
+ * it, and return it. With `storageKey`, the choice (and every later `locale(code)`) is
126
+ * kept in S under that key. With `supported`, only those (or their base language) count.
127
+ * @param {I18nDetectOptions} [options]
128
+ * @returns {string}
129
+ */
130
+ function detect(options?: I18nDetectOptions): string;
131
+ /**
132
+ * @param {number|bigint} n
133
+ * @param {WithLocale<Intl.NumberFormatOptions>} [opts]
134
+ * @returns {string}
135
+ */
136
+ function number(n: number | bigint, opts?: WithLocale<Intl.NumberFormatOptions>): string;
137
+ /**
138
+ * @param {number|bigint} n
139
+ * @param {string} code - ISO 4217 currency, e.g. 'GBP'
140
+ * @param {WithLocale<Intl.NumberFormatOptions>} [opts]
141
+ * @returns {string}
142
+ */
143
+ function currency(n: number | bigint, code: string, opts?: WithLocale<Intl.NumberFormatOptions>): string;
144
+ /**
145
+ * Format a date. Accepts a Date, timestamp, date string or a D() wrapper.
146
+ * An invalid date formats as ''.
147
+ * @param {Date|number|string|{toDate(): Date}} d
148
+ * @param {WithLocale<Intl.DateTimeFormatOptions>} [opts]
149
+ * @returns {string}
150
+ */
151
+ function date(d: Date | number | string | {
152
+ toDate(): Date;
153
+ }, opts?: WithLocale<Intl.DateTimeFormatOptions>): string;
154
+ /**
155
+ * "in 3 days", "2 hours ago" - Intl.RelativeTimeFormat.
156
+ * @param {number} value - Negative for the past
157
+ * @param {Intl.RelativeTimeFormatUnit} unit - 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'
158
+ * @param {WithLocale<Intl.RelativeTimeFormatOptions>} [opts]
159
+ * @returns {string}
160
+ */
161
+ function relative(value: number, unit: Intl.RelativeTimeFormatUnit, opts?: WithLocale<Intl.RelativeTimeFormatOptions>): string;
162
+ /**
163
+ * "a, b and c" - Intl.ListFormat.
164
+ * @param {Iterable<string>} items
165
+ * @param {WithLocale<{type?: 'conjunction'|'disjunction'|'unit', style?: 'long'|'short'|'narrow'}>} [opts] - Intl.ListFormat options plus `locale`
166
+ * @returns {string}
167
+ */
168
+ function list(items: Iterable<string>, opts?: WithLocale<{
169
+ type?: "conjunction" | "disjunction" | "unit";
170
+ style?: "long" | "short" | "narrow";
171
+ }>): string;
172
+ /**
173
+ * Forget every message, load, listener, hook and setting (tests, or a full reload).
174
+ * @returns {I18n} i18n
175
+ */
176
+ function reset(): I18n;
177
+ }
178
+ export default i18n;
179
+ /**
180
+ * A plural message: chosen by `params.count`; `=N` keys match exactly, `zero` matches 0.
181
+ * `ordinal: true` uses ordinal rules (1st, 2nd, 3rd...).
182
+ */
183
+ export type I18nPluralForms = {
184
+ zero?: string;
185
+ one?: string;
186
+ two?: string;
187
+ few?: string;
188
+ many?: string;
189
+ other: string;
190
+ ordinal?: boolean;
191
+ [exact: `=${number}`]: string;
192
+ };
193
+ /**
194
+ * A select message: `select` names the param whose value picks the form; `other` otherwise.
195
+ */
196
+ export type I18nSelectForms = {
197
+ select: string;
198
+ other: string;
199
+ [value: string]: string;
200
+ };
201
+ /**
202
+ * Nested message tree; nesting becomes dot keys.
203
+ */
204
+ export type I18nMessages = {
205
+ [key: string]: string | number | boolean | I18nPluralForms | I18nSelectForms | I18nMessages;
206
+ };
207
+ export type I18nTranslateOptions = {
208
+ /**
209
+ * Translate in this locale instead of the current one
210
+ */
211
+ locale?: string;
212
+ /**
213
+ * Returned (interpolated) when the key is missing, instead of the key
214
+ */
215
+ default?: string;
216
+ /**
217
+ * Choose plural forms by ordinal rules
218
+ */
219
+ ordinal?: boolean;
220
+ };
221
+ export type I18nDetectOptions = {
222
+ /**
223
+ * Sources in order. Default ['storage', 'navigator', 'html']
224
+ */
225
+ from?: Array<"storage" | "navigator" | "html">;
226
+ /**
227
+ * S key: read in 'storage', and every later locale(code) is saved there
228
+ */
229
+ storageKey?: string;
230
+ /**
231
+ * Only these locales (or their base language) are accepted
232
+ */
233
+ supported?: string[];
234
+ /**
235
+ * Used when nothing matches (else the current locale stays)
236
+ */
237
+ fallback?: string;
238
+ /**
239
+ * Set the found locale (default true)
240
+ */
241
+ apply?: boolean;
242
+ };
243
+ export type I18nChangeDetail = {
244
+ locale: string;
245
+ previous: string;
246
+ };
247
+ export type I18nMissingDetail = {
248
+ key: string;
249
+ locale: string;
250
+ };
251
+ export type I18nLoadedDetail = {
252
+ locale: string;
253
+ messages: I18nMessages;
254
+ };
255
+ /**
256
+ * Formatter options plus an optional `locale` override.
257
+ */
258
+ export type WithLocale<T> = T & {
259
+ locale?: string;
260
+ };
261
+ export type I18n = typeof i18n;
@@ -0,0 +1,213 @@
1
+ export default icons;
2
+ /**
3
+ * Built-in icon categories (keys of `listCategories()`); `custom` appears once an icon is registered.
4
+ */
5
+ export type IconCategory = "ui" | "communication" | "media" | "files" | "social" | "commerce" | "status" | "navigation" | "seasonal" | "weather" | "devices" | "finance" | "health" | "sport" | "buildings" | "emojis" | "transport" | "code" | "forms" | "custom";
6
+ /**
7
+ * A category entry as returned by `listCategories()`.
8
+ */
9
+ export type IconCategoryInfo = {
10
+ /**
11
+ * Display name
12
+ */
13
+ name: string;
14
+ description: string;
15
+ /**
16
+ * Icon names in the category
17
+ */
18
+ icons: string[];
19
+ };
20
+ /**
21
+ * An icon: SVG path data plus the attributes put on the `<svg>`.
22
+ */
23
+ export type IconDefinition = {
24
+ /**
25
+ * SVG viewBox (default '0 0 24 24')
26
+ */
27
+ viewBox?: string;
28
+ /**
29
+ * Single path data
30
+ */
31
+ path?: string;
32
+ /**
33
+ * Multiple path data
34
+ */
35
+ paths?: string[];
36
+ /**
37
+ * Stroke colour (usually 'currentColor')
38
+ */
39
+ stroke?: string;
40
+ /**
41
+ * Fill colour ('none', or 'currentColor' for filled icons)
42
+ */
43
+ fill?: string;
44
+ /**
45
+ * Stroke width
46
+ */
47
+ strokeWidth?: number | string;
48
+ strokeLinecap?: string;
49
+ strokeLinejoin?: string;
50
+ };
51
+ /**
52
+ * Options for `render()`, `html()` and `use()` (`use()` reads only `size` and `class`).
53
+ */
54
+ export type RenderOptions = {
55
+ /**
56
+ * Icon size in pixels
57
+ */
58
+ size?: number | string;
59
+ /**
60
+ * Additional CSS classes
61
+ */
62
+ class?: string;
63
+ /**
64
+ * Icon colour (overrides currentColor)
65
+ */
66
+ colour?: string;
67
+ /**
68
+ * Alias for colour
69
+ */
70
+ color?: string;
71
+ /**
72
+ * Additional attributes
73
+ */
74
+ attrs?: Record<string, string>;
75
+ };
76
+ /**
77
+ * Options for `inject()`: render options plus where the icon goes.
78
+ */
79
+ export type IconInjectOptions = RenderOptions & {
80
+ position?: "prepend" | "append" | "replace";
81
+ };
82
+ export type Icons = IconRegistry;
83
+ export const icons: IconRegistry;
84
+ /**
85
+ * Built-in icon categories (keys of `listCategories()`); `custom` appears once an icon is registered.
86
+ * @typedef {'ui'|'communication'|'media'|'files'|'social'|'commerce'|'status'|'navigation'|'seasonal'|'weather'|'devices'|'finance'|'health'|'sport'|'buildings'|'emojis'|'transport'|'code'|'forms'|'custom'} IconCategory
87
+ */
88
+ /**
89
+ * A category entry as returned by `listCategories()`.
90
+ * @typedef {object} IconCategoryInfo
91
+ * @property {string} name Display name
92
+ * @property {string} description
93
+ * @property {string[]} icons Icon names in the category
94
+ */
95
+ /**
96
+ * An icon: SVG path data plus the attributes put on the `<svg>`.
97
+ * @typedef {object} IconDefinition
98
+ * @property {string} [viewBox] SVG viewBox (default '0 0 24 24')
99
+ * @property {string} [path] Single path data
100
+ * @property {string[]} [paths] Multiple path data
101
+ * @property {string} [stroke] Stroke colour (usually 'currentColor')
102
+ * @property {string} [fill] Fill colour ('none', or 'currentColor' for filled icons)
103
+ * @property {number|string} [strokeWidth] Stroke width
104
+ * @property {string} [strokeLinecap]
105
+ * @property {string} [strokeLinejoin]
106
+ */
107
+ /**
108
+ * Options for `render()`, `html()` and `use()` (`use()` reads only `size` and `class`).
109
+ * @typedef {object} RenderOptions
110
+ * @property {number|string} [size=24] Icon size in pixels
111
+ * @property {string} [class] Additional CSS classes
112
+ * @property {string} [colour] Icon colour (overrides currentColor)
113
+ * @property {string} [color] Alias for colour
114
+ * @property {Record<string, string>} [attrs] Additional attributes
115
+ */
116
+ /**
117
+ * Options for `inject()`: render options plus where the icon goes.
118
+ * @typedef {RenderOptions & {position?: 'prepend'|'append'|'replace'}} IconInjectOptions
119
+ */
120
+ /** @typedef {IconRegistry} Icons */
121
+ export class IconRegistry {
122
+ /** @type {Record<string, IconDefinition>} @private */
123
+ private _icons;
124
+ /** @type {Partial<Record<IconCategory, IconCategoryInfo>>} @private */
125
+ private _categories;
126
+ /**
127
+ * Render an icon as an SVG element
128
+ * @param {string} name - Icon name
129
+ * @param {RenderOptions} [options] - Render options
130
+ * @returns {SVGElement|null}
131
+ */
132
+ render(name: string, options?: RenderOptions): SVGElement | null;
133
+ /**
134
+ * Get icon as HTML string
135
+ * @param {string} name - Icon name
136
+ * @param {RenderOptions} [options] - Render options (same as render())
137
+ * @returns {string}
138
+ */
139
+ html(name: string, options?: RenderOptions): string;
140
+ /**
141
+ * Inject icon into an element
142
+ * @param {string|HTMLElement} target - Target element or selector
143
+ * @param {string} name - Icon name
144
+ * @param {IconInjectOptions} [options] - Render options (same as render()), plus `position`: 'prepend' (default), 'append', or 'replace'
145
+ * @returns {SVGElement|null}
146
+ */
147
+ inject(target: string | HTMLElement, name: string, options?: IconInjectOptions): SVGElement | null;
148
+ /**
149
+ * Scan document for [data-icon] elements and replace with SVGs
150
+ * @param {Element|Document|DocumentFragment|string} [container=document] - Container to scan
151
+ * @returns {number} Number of icons replaced
152
+ */
153
+ scan(container?: Element | Document | DocumentFragment | string): number;
154
+ /**
155
+ * Register a custom icon
156
+ * @param {string} name - Icon name
157
+ * @param {IconDefinition} definition - Icon definition (needs `path` or `paths`; `viewBox` defaults to '0 0 24 24')
158
+ * @returns {this}
159
+ */
160
+ register(name: string, definition: IconDefinition): this;
161
+ /**
162
+ * Unregister an icon
163
+ * @param {string} name - Icon name
164
+ * @returns {boolean}
165
+ */
166
+ unregister(name: string): boolean;
167
+ /**
168
+ * Check if an icon exists
169
+ * @param {string} name - Icon name
170
+ * @returns {boolean}
171
+ */
172
+ has(name: string): boolean;
173
+ /**
174
+ * Get icon definition
175
+ * @param {string} name - Icon name
176
+ * @returns {IconDefinition|null}
177
+ */
178
+ get(name: string): IconDefinition | null;
179
+ /**
180
+ * List all icon names
181
+ * @param {IconCategory|null} [category] - Filter by category
182
+ * @returns {string[]}
183
+ */
184
+ list(category?: IconCategory | null): string[];
185
+ /**
186
+ * List all categories
187
+ * @returns {Partial<Record<IconCategory, IconCategoryInfo>>}
188
+ */
189
+ listCategories(): Partial<Record<IconCategory, IconCategoryInfo>>;
190
+ /**
191
+ * Get icon count
192
+ * @returns {number}
193
+ */
194
+ count(): number;
195
+ /**
196
+ * Search icons by name
197
+ * @param {string} query - Search query
198
+ * @returns {string[]}
199
+ */
200
+ search(query: string): string[];
201
+ /**
202
+ * Create a sprite sheet of all icons (for performance)
203
+ * @returns {SVGElement}
204
+ */
205
+ createSprite(): SVGElement;
206
+ /**
207
+ * Use an icon from sprite sheet
208
+ * @param {string} name - Icon name
209
+ * @param {RenderOptions} [options] - Render options (`size` and `class`)
210
+ * @returns {SVGElement|null}
211
+ */
212
+ use(name: string, options?: RenderOptions): SVGElement | null;
213
+ }