@htmlplus/element 3.2.5 → 3.3.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.
@@ -1 +1 @@
1
- export { G as attributes, J as html, K as styles } from './client-B2DGXsxR.js';
1
+ export { a as attributes, h as html, s as styles } from './client.js';
package/dist/internal.js CHANGED
@@ -1,3 +1,3 @@
1
- export { w as attributes, x as html, y as styles } from './client-D1N1nBuh.js';
1
+ export { a as attributes, h as html, s as styles } from './client.js';
2
2
  import 'change-case';
3
3
  import './constants.js';
@@ -130,4 +130,5 @@ interface WebTypesOptions {
130
130
  }
131
131
  declare const webTypes: (options?: WebTypesOptions) => TransformerPlugin;
132
132
 
133
- export { ASSETS_OPTIONS, type AssetsOptions, COPY_OPTIONS, CUSTOM_ELEMENT_OPTIONS, type CopyOptions, type CustomElementOptions, DOCUMENT_OPTIONS, type DocumentOptions, PARSE_OPTIONS, type ParseOptions, README_OPTIONS, type ReadmeOptions, STYLE_OPTIONS, type StyleOptions, type TransformerPlugin, type TransformerPluginContext, type TransformerPluginGlobal, VISUAL_STUDIO_CODE_OPTIONS, type VisualStudioCodeOptions, WEB_TYPES_OPTIONS, type WebTypesOptions, assets, copy, customElement, document, extract, parse, read, readme, style, transformer, validate, visualStudioCode, webTypes };
133
+ export { ASSETS_OPTIONS, COPY_OPTIONS, CUSTOM_ELEMENT_OPTIONS, DOCUMENT_OPTIONS, PARSE_OPTIONS, README_OPTIONS, STYLE_OPTIONS, VISUAL_STUDIO_CODE_OPTIONS, WEB_TYPES_OPTIONS, assets, copy, customElement, document, extract, parse, read, readme, style, transformer, validate, visualStudioCode, webTypes };
134
+ export type { AssetsOptions, CopyOptions, CustomElementOptions, DocumentOptions, ParseOptions, ReadmeOptions, StyleOptions, TransformerPlugin, TransformerPluginContext, TransformerPluginGlobal, VisualStudioCodeOptions, WebTypesOptions };
@@ -8,7 +8,7 @@ import template from '@babel/template';
8
8
  import { pascalCase, kebabCase, camelCase, capitalCase } from 'change-case';
9
9
  import ora from 'ora';
10
10
  import path, { join, resolve, dirname } from 'node:path';
11
- import { KEY, COMMENT_AUTO_ADDED, DECORATOR_PROPERTY, STATIC_TAG, UTILS_STYLES_LOCAL, UTILS_PATH, DECORATOR_PROPERTY_TYPE, UTILS_STYLES_IMPORTED, ELEMENT_HOST_NAME, UTILS_HTML_IMPORTED, UTILS_HTML_LOCAL, TYPE_OBJECT, TYPE_NULL, TYPE_ARRAY, TYPE_STRING, TYPE_ENUM, TYPE_NUMBER, TYPE_DATE, TYPE_BOOLEAN, UTILS_ATTRIBUTES_IMPORTED, UTILS_ATTRIBUTES_LOCAL, DECORATOR_CSS_VARIABLE, DECORATOR_EVENT, DECORATOR_METHOD, DECORATOR_STATE, STATIC_STYLE, STYLE_IMPORTED, PACKAGE_NAME, DECORATOR_ELEMENT } from './constants.js';
11
+ import { KEY, COMMENT_AUTO_ADDED, DECORATOR_PROPERTY, STATIC_TAG, UTILS_STYLES_LOCAL, UTILS_PATH, ELEMENT_HOST_NAME, UTILS_HTML_LOCAL, DECORATOR_PROPERTY_TYPE, TYPE_OBJECT, TYPE_NULL, TYPE_ARRAY, TYPE_STRING, TYPE_ENUM, TYPE_NUMBER, TYPE_DATE, TYPE_BOOLEAN, UTILS_ATTRIBUTES_LOCAL, UTILS_STYLES_IMPORTED, UTILS_ATTRIBUTES_IMPORTED, UTILS_HTML_IMPORTED, DECORATOR_CSS_VARIABLE, DECORATOR_EVENT, DECORATOR_METHOD, DECORATOR_STATE, STATIC_STYLE, STYLE_IMPORTED, PACKAGE_NAME, DECORATOR_ELEMENT } from './constants.js';
12
12
 
13
13
  const logger = ora({
14
14
  color: 'yellow'
@@ -751,9 +751,7 @@ const customElement = (options) => {
751
751
 
752
752
  namespace JSX {
753
753
  interface IntrinsicElements {
754
- "${context.elementTagName}": ${context.className}Events & ${context.className}Attributes & {
755
- [key: string]: any;
756
- };
754
+ "${context.elementTagName}": ${context.className}Events & ${context.className}Attributes & React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
757
755
  }
758
756
  }
759
757
  }
@@ -761,9 +759,7 @@ const customElement = (options) => {
761
759
  declare module "react" {
762
760
  namespace JSX {
763
761
  interface IntrinsicElements {
764
- "${context.elementTagName}": ${context.className}Events & ${context.className}Attributes & {
765
- [key: string]: any;
766
- };
762
+ "${context.elementTagName}": ${context.className}Events & ${context.className}Attributes & React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
767
763
  }
768
764
  }
769
765
  }
@@ -774,6 +770,22 @@ const customElement = (options) => {
774
770
  preserveComments: true
775
771
  });
776
772
  path.node.body.push(...ast);
773
+ },
774
+ // TODO
775
+ TSTypeReference(path) {
776
+ if (path.node.typeName?.name != 'OverridesConfig')
777
+ return;
778
+ const property = path.findParent((path) => path.isTSPropertySignature());
779
+ if (!property)
780
+ return;
781
+ const name = property.node.key.name || property.node.key.extra.rawValue;
782
+ if (!path.node.typeParameters?.params)
783
+ return;
784
+ path.node.typeParameters.params[1] = t.tsTypeReference(t.identifier('Omit'), t.tsTypeParameterInstantiation([
785
+ t.tsTypeReference(t.identifier(`${context.className}Properties`)),
786
+ t.tsLiteralType(t.stringLiteral(name))
787
+ ]));
788
+ path.skip();
777
789
  }
778
790
  });
779
791
  }
@@ -1136,7 +1148,7 @@ const visualStudioCode = (options) => {
1136
1148
  options = Object.assign({}, VISUAL_STUDIO_CODE_OPTIONS, options);
1137
1149
  const finish = (global) => {
1138
1150
  const contexts = global.contexts.sort((a, b) => {
1139
- return a.elementKey.toUpperCase() > b.elementKey.toUpperCase() ? +1 : -1;
1151
+ return a.elementKey.toUpperCase() > b.elementKey.toUpperCase() ? 1 : -1;
1140
1152
  });
1141
1153
  const json = {
1142
1154
  $schema: 'TODO',
@@ -1208,7 +1220,7 @@ const webTypes = (options) => {
1208
1220
  options = Object.assign({}, WEB_TYPES_OPTIONS, options);
1209
1221
  const finish = (global) => {
1210
1222
  const contexts = global.contexts.sort((a, b) => {
1211
- return a.elementKey.toUpperCase() > b.elementKey.toUpperCase() ? +1 : -1;
1223
+ return a.elementKey.toUpperCase() > b.elementKey.toUpperCase() ? 1 : -1;
1212
1224
  });
1213
1225
  const json = {
1214
1226
  '$schema': 'http://json.schemastore.org/web-types',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "3.2.5",
3
+ "version": "3.3.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
@@ -89,6 +89,6 @@
89
89
  "rollup-plugin-node-externals": "^7.1.3",
90
90
  "semantic-release": "^24.2.0",
91
91
  "tslib": "^2.8.0",
92
- "vite": "^5.4.10"
92
+ "vite": "^6.3.5"
93
93
  }
94
94
  }
@@ -1,327 +0,0 @@
1
- /**
2
- * Used to bind a method of a class to the current context,
3
- * making it easier to reference `this` within the method.
4
- */
5
- declare function Bind(): (target: Object, key: PropertyKey, descriptor: PropertyDescriptor) => {
6
- configurable: boolean;
7
- get(): any;
8
- };
9
-
10
- interface HTMLPlusElement {
11
- }
12
-
13
- declare function Provider(namespace: string): (target: HTMLPlusElement, key: PropertyKey) => void;
14
- declare function Consumer(namespace: string): (target: HTMLPlusElement, key: PropertyKey) => void;
15
-
16
- /**
17
- * A method decorator that applies debounce behavior to a class method.
18
- * Ensures that the method executes only after the specified delay,
19
- * resetting the timer if called again within the delay period.
20
- *
21
- * @param {number} delay - The debounce delay in milliseconds.
22
- */
23
- declare function Debounce(delay?: number): (target: Object, key: PropertyKey, descriptor: PropertyDescriptor) => {
24
- configurable: boolean;
25
- get(): any;
26
- };
27
-
28
- /**
29
- * Indicates whether the [Direction](https://mdn.io/css-direction)
30
- * of the element is `Right-To-Left` or `Left-To-Right`.
31
- */
32
- declare function Direction(): (target: HTMLPlusElement, key: PropertyKey) => void;
33
-
34
- /**
35
- * The class marked with this decorator is considered a
36
- * [Custom Element](https://mdn.io/using-custom-elements),
37
- * and its name, in kebab-case, serves as the element name.
38
- */
39
- declare function Element$1(): (constructor: HTMLPlusElement) => void;
40
-
41
- /**
42
- * A function type that generates a `CustomEvent`.
43
- */
44
- type EventEmitter<T = any> = (data?: T) => CustomEvent<T>;
45
- /**
46
- * An object that configures
47
- * [options](https://developer.mozilla.org/docs/Web/API/Event/EventEvent#options)
48
- * for the event dispatcher.
49
- */
50
- interface EventOptions {
51
- /**
52
- * A boolean value indicating whether the event bubbles.
53
- * The default is `false`.
54
- */
55
- bubbles?: boolean;
56
- /**
57
- * A boolean value indicating whether the event can be cancelled.
58
- * The default is `false`.
59
- */
60
- cancelable?: boolean;
61
- /**
62
- * A boolean value indicating whether the event will trigger listeners outside of a shadow root
63
- * (see [Event.composed](https://mdn.io/event-composed) for more details).
64
- * The default is `false`.
65
- */
66
- composed?: boolean;
67
- }
68
- /**
69
- * Provides the capability to dispatch a [CustomEvent](https://mdn.io/custom-event)
70
- * from an element.
71
- *
72
- * @param options An object that configures options for the event dispatcher.
73
- */
74
- declare function Event<T = any>(options?: EventOptions): (target: HTMLPlusElement, key: PropertyKey) => void;
75
-
76
- /**
77
- * Indicates the host of the element.
78
- */
79
- declare function Host(): (target: HTMLPlusElement, key: PropertyKey) => void;
80
-
81
- /**
82
- * Indicates whether the direction of the element is `Right-To-Left` or not.
83
- */
84
- declare function IsRTL(): (target: HTMLPlusElement, key: PropertyKey) => void;
85
-
86
- /**
87
- * An object that configures
88
- * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
89
- * for the event listener.
90
- */
91
- interface ListenOptions {
92
- /**
93
- * A boolean value indicating that events of this type will be dispatched to the registered
94
- * `listener` before being dispatched to any `EventTarget` beneath it in the DOM tree.
95
- * If not specified, defaults to `false`.
96
- */
97
- capture?: boolean;
98
- /**
99
- * A boolean value indicating that the `listener` should be invoked at most once after being added.
100
- * If `true`, the `listener` would be automatically removed when invoked.
101
- * If not specified, defaults to `false`.
102
- */
103
- once?: boolean;
104
- /**
105
- * A boolean value that, if `true`,
106
- * indicates that the function specified by `listener` will never call
107
- * [preventDefault()](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault).
108
- * If a passive listener does call `preventDefault()`,
109
- * the user agent will do nothing other than generate a console warning.
110
- */
111
- passive?: boolean;
112
- /**
113
- * An [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
114
- * The listener will be removed when the given `AbortSignal` object's
115
- * [abort()](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) method is called.
116
- * If not specified, no `AbortSignal` is associated with the listener.
117
- */
118
- signal?: AbortSignal;
119
- /**
120
- * The target element, defaults to `host`.
121
- */
122
- target?: 'host' | 'body' | 'document' | 'window';
123
- }
124
- /**
125
- * Will be called whenever the specified event is delivered to the target
126
- * [More](https://mdn.io/add-event-listener).
127
- *
128
- * @param type A case-sensitive string representing the [Event Type](https://mdn.io/events) to listen for.
129
- * @param options An object that configures
130
- * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
131
- * for the event listener.
132
- */
133
- declare function Listen(type: string, options?: ListenOptions): (target: HTMLPlusElement, key: PropertyKey, descriptor: PropertyDescriptor) => {
134
- configurable: boolean;
135
- get(): any;
136
- };
137
-
138
- /**
139
- * Provides a way to encapsulate functionality within an element
140
- * and invoke it as needed, both internally and externally.
141
- */
142
- declare function Method(): (target: HTMLPlusElement, key: PropertyKey, descriptor: PropertyDescriptor) => void;
143
-
144
- /**
145
- * The configuration for property decorator.
146
- */
147
- interface PropertyOptions {
148
- /**
149
- * Specifies the name of the attribute related to the property.
150
- */
151
- attribute?: string;
152
- /**
153
- * Whether property value is reflected back to the associated attribute. default is `false`.
154
- */
155
- reflect?: boolean;
156
- /**
157
- * Specifies the property `type` and supports
158
- * [data types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures).
159
- * If this value is not set, it will be set automatically during transforming.
160
- */
161
- type?: any;
162
- }
163
- /**
164
- * Creates a reactive property, reflecting a corresponding attribute value,
165
- * and updates the element when the property is set.
166
- */
167
- declare function Property(options?: PropertyOptions): (target: HTMLPlusElement, key: string, descriptor?: PropertyDescriptor) => void;
168
-
169
- /**
170
- * Selects the first element in the shadow dom that matches a specified CSS selector.
171
- *
172
- * @param selectors A string containing one or more selectors to match.
173
- * This string must be a valid CSS selector string; if it isn't, a `SyntaxError` exception is thrown. See
174
- * [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
175
- * for more about selectors and how to manage them.
176
- */
177
- declare function Query(selectors: string): (target: HTMLPlusElement, key: PropertyKey) => void;
178
-
179
- /**
180
- * Selects all elements in the shadow dom that match a specified CSS selector.
181
- *
182
- * @param selectors A string containing one or more selectors to match against.
183
- * This string must be a valid
184
- * [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
185
- * string; if it's not, a `SyntaxError` exception is thrown. See
186
- * [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
187
- * for more information about using selectors to identify elements.
188
- * Multiple selectors may be specified by separating them using commas.
189
- */
190
- declare function QueryAll(selectors: string): (target: HTMLPlusElement, key: PropertyKey) => void;
191
-
192
- /**
193
- * Returns the slots name.
194
- */
195
- declare function Slots$1(): (target: HTMLPlusElement, key: PropertyKey) => void;
196
-
197
- /**
198
- * Applying this decorator to any `class property` will trigger the
199
- * element to re-render upon the desired property changes.
200
- */
201
- declare function State(): (target: HTMLPlusElement, key: PropertyKey) => void;
202
-
203
- declare function Style(): (target: HTMLPlusElement, key: PropertyKey) => void;
204
-
205
- /**
206
- * Monitors `@Property` and `@State` to detect changes.
207
- * The decorated method will be called after any changes,
208
- * with the `key`, `newValue`, and `oldValue` as parameters.
209
- * If the `key` is not defined, all `@Property` and `@State` are considered.
210
- *
211
- * @param keys Collection of `@Property` and `@State` names.
212
- * @param immediate Triggers the callback immediately after initialization.
213
- */
214
- declare function Watch(keys?: string | string[], immediate?: boolean): (target: HTMLPlusElement, key: PropertyKey) => void;
215
-
216
- /**
217
- * TODO
218
- */
219
- declare const classes: (input: any, smart?: boolean) => string;
220
-
221
- /**
222
- * TODO
223
- */
224
- interface Config {
225
- event?: {
226
- resolver?: (parameters: any) => CustomEvent | undefined;
227
- };
228
- asset?: {
229
- [key: string]: any;
230
- };
231
- element?: {
232
- [key: string]: {
233
- property?: {
234
- [key: string]: any;
235
- };
236
- };
237
- };
238
- }
239
- /**
240
- * TODO
241
- */
242
- interface ConfigOptions {
243
- /**
244
- * TODO
245
- */
246
- force?: boolean;
247
- /**
248
- * TODO
249
- */
250
- override?: boolean;
251
- }
252
- /**
253
- * TODO
254
- */
255
- declare const getConfig: (...keys: string[]) => any;
256
- /**
257
- * TODO
258
- */
259
- declare const setConfig: (config: Config, options?: ConfigOptions) => void;
260
-
261
- /**
262
- * Indicates whether the [Direction](https://mdn.io/css-direction)
263
- * of the element is `Right-To-Left` or `Left-To-Right`.
264
- */
265
- declare const direction: (target: HTMLElement | HTMLPlusElement) => "ltr" | "rtl";
266
-
267
- /**
268
- * TODO
269
- */
270
- declare const dispatch: <T = any>(target: HTMLElement | HTMLPlusElement, type: string, eventInitDict?: CustomEventInit<T>) => CustomEvent<T>;
271
- /**
272
- * TODO
273
- */
274
- declare const on: (target: Window | Document | HTMLElement | HTMLPlusElement, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
275
- /**
276
- * TODO
277
- */
278
- declare const off: (target: Window | Document | HTMLElement | HTMLPlusElement, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
279
-
280
- /**
281
- * Indicates the host of the element.
282
- */
283
- declare const host: (target: HTMLElement | HTMLPlusElement) => HTMLElement;
284
-
285
- /**
286
- * Determines whether the given input string is a valid
287
- * [CSS Color](https://mdn.io/color-value) or not.
288
- */
289
- declare const isCSSColor: (input: string) => boolean;
290
-
291
- /**
292
- * Indicates whether the direction of the element is `Right-To-Left` or not.
293
- */
294
- declare const isRTL: (target: HTMLPlusElement) => boolean;
295
-
296
- /**
297
- * Selects the first element in the shadow dom that matches a specified CSS selector.
298
- */
299
- declare function query(target: HTMLPlusElement, selectors: string): Element | null | undefined;
300
-
301
- /**
302
- * Selects all elements in the shadow dom that match a specified CSS selector.
303
- */
304
- declare function queryAll(target: HTMLPlusElement, selectors: string): NodeListOf<Element> | undefined;
305
-
306
- type Slots = {
307
- [key: string]: boolean;
308
- };
309
- /**
310
- * Returns the slots name.
311
- */
312
- declare const slots: (target: HTMLElement | HTMLPlusElement) => Slots;
313
-
314
- declare const toCSSColor: (input: string) => string | undefined;
315
-
316
- declare const toCSSUnit: (input?: number | string | null) => string | undefined;
317
-
318
- /**
319
- * Converts a value to a unit.
320
- */
321
- declare const toUnit: (input: string | number, unit?: string) => string;
322
-
323
- declare const attributes: any;
324
- declare const html: any;
325
- declare const styles: any;
326
-
327
- export { State as A, Bind as B, type Config as C, Debounce as D, Element$1 as E, Style as F, attributes as G, Host as H, IsRTL as I, html as J, styles as K, type ListenOptions as L, Method as M, Provider as P, Query as Q, Slots$1 as S, Watch as W, type ConfigOptions as a, dispatch as b, classes as c, direction as d, toCSSUnit as e, isRTL as f, getConfig as g, host as h, isCSSColor as i, queryAll as j, off as k, toUnit as l, setConfig as m, Consumer as n, on as o, Direction as p, query as q, type EventEmitter as r, slots as s, toCSSColor as t, type EventOptions as u, Event as v, Listen as w, type PropertyOptions as x, Property as y, QueryAll as z };