odontogram 0.0.1

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +299 -0
  3. package/cdn/components/button/button.d.ts +25 -0
  4. package/cdn/components/button/button.d.ts.map +1 -0
  5. package/cdn/components/button/button.js +598 -0
  6. package/cdn/components/button/button.styles.d.ts +3 -0
  7. package/cdn/components/button/button.styles.d.ts.map +1 -0
  8. package/cdn/components/button/index.d.ts +2 -0
  9. package/cdn/components/button/index.d.ts.map +1 -0
  10. package/cdn/components/button/index.js +2 -0
  11. package/cdn/components/index.d.ts +2 -0
  12. package/cdn/components/index.d.ts.map +1 -0
  13. package/cdn/components/index.js +1 -0
  14. package/cdn/index.d.ts +2 -0
  15. package/cdn/index.d.ts.map +1 -0
  16. package/cdn/index.js +1 -0
  17. package/cdn/loader.js +118 -0
  18. package/custom-elements.json +152 -0
  19. package/dist/components/button/button.d.ts +25 -0
  20. package/dist/components/button/button.d.ts.map +1 -0
  21. package/dist/components/button/button.js +47 -0
  22. package/dist/components/button/button.js.map +1 -0
  23. package/dist/components/button/button.styles.d.ts +3 -0
  24. package/dist/components/button/button.styles.d.ts.map +1 -0
  25. package/dist/components/button/button.styles.js +43 -0
  26. package/dist/components/button/button.styles.js.map +1 -0
  27. package/dist/components/button/index.d.ts +2 -0
  28. package/dist/components/button/index.d.ts.map +1 -0
  29. package/dist/components/button/index.js +3 -0
  30. package/dist/components/button/index.js.map +1 -0
  31. package/dist/components/index.d.ts +2 -0
  32. package/dist/components/index.d.ts.map +1 -0
  33. package/dist/components/index.js +2 -0
  34. package/dist/components/index.js.map +1 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +2 -0
  38. package/dist/index.js.map +1 -0
  39. package/package.json +120 -0
  40. package/react/MyButton.d.ts +90 -0
  41. package/react/MyButton.js +32 -0
  42. package/react/index.d.ts +1 -0
  43. package/react/index.js +1 -0
  44. package/react/react-utils.js +67 -0
  45. package/types/custom-element-jsx.d.ts +236 -0
  46. package/types/custom-element-svelte.d.ts +70 -0
  47. package/types/custom-element-vuejs.d.ts +40 -0
@@ -0,0 +1,32 @@
1
+ import React, { forwardRef, useRef } from "react";
2
+ import "../dist/components/button/index.js";
3
+ import { createForwardedRefHandler } from "./react-utils.js";
4
+
5
+ export const MyButton = forwardRef((props, forwardedRef) => {
6
+ const ref = useRef(null);
7
+ const {
8
+ disabled,
9
+ variation,
10
+ exportparts,
11
+ htmlFor,
12
+ part,
13
+ tabIndex,
14
+ ...restProps
15
+ } = props;
16
+
17
+ return React.createElement(
18
+ "my-button",
19
+ {
20
+ ref: createForwardedRefHandler(ref, forwardedRef),
21
+ ...restProps,
22
+ variation: variation,
23
+ exportparts: exportparts,
24
+ for: htmlFor,
25
+ part: part,
26
+ tabindex: tabIndex,
27
+ disabled: disabled ? true : undefined,
28
+ style: { ...props.style },
29
+ },
30
+ props.children,
31
+ );
32
+ });
@@ -0,0 +1 @@
1
+ export * from "./MyButton.js";
package/react/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./MyButton.js";
@@ -0,0 +1,67 @@
1
+ import { useEffect, useLayoutEffect, useRef } from "react";
2
+
3
+ export function mergeRefs(target, forwardedRef) {
4
+ if (!forwardedRef) {
5
+ return;
6
+ }
7
+
8
+ if (typeof forwardedRef === "function") {
9
+ forwardedRef(target);
10
+ } else {
11
+ forwardedRef.current = target;
12
+ }
13
+ }
14
+
15
+ export function createForwardedRefHandler(localRef, forwardedRef) {
16
+ return (node) => {
17
+ localRef.current = node;
18
+ mergeRefs(node, forwardedRef);
19
+ };
20
+ }
21
+
22
+ export function useProperties(targetElement, propName, value) {
23
+ useEffect(() => {
24
+ const el = targetElement?.current;
25
+ if (!el || value === undefined || el[propName] === value) {
26
+ return;
27
+ }
28
+
29
+ try {
30
+ el[propName] = value;
31
+ } catch (e) {
32
+ console.warn(e);
33
+ }
34
+ }, [targetElement, propName, value]);
35
+ }
36
+
37
+ export function useEventListener(targetElement, eventName, eventHandler) {
38
+ // keep a ref to the latest handler so we don't need to re-register the event listener
39
+ // whenever the handler changes (avoids duplicate listeners on re-renders)
40
+ const handlerRef = useRef(eventHandler);
41
+ handlerRef.current = eventHandler;
42
+
43
+ useLayoutEffect(() => {
44
+ const el = targetElement?.current;
45
+ if (!el || eventName === undefined) {
46
+ return;
47
+ }
48
+
49
+ // capture the handler at the time the listener is attached so we can call cancel on it
50
+ const eventListener = (event) => {
51
+ const handler = handlerRef.current;
52
+ if (handler) {
53
+ handler(event);
54
+ }
55
+ };
56
+
57
+ el.addEventListener(eventName, eventListener);
58
+
59
+ return () => {
60
+ const handler = handlerRef.current;
61
+ if (handler?.cancel) {
62
+ handler.cancel();
63
+ }
64
+ el.removeEventListener(eventName, eventListener);
65
+ };
66
+ }, [eventName, targetElement?.current]);
67
+ }
@@ -0,0 +1,236 @@
1
+ import type { MyButton } from "src/components/button/button.ts";
2
+
3
+ /**
4
+ * This type can be used to create scoped tags for your components.
5
+ *
6
+ * Usage:
7
+ *
8
+ * ```ts
9
+ * import type { ScopedElements } from "path/to/library/jsx-integration";
10
+ *
11
+ * declare module "my-library" {
12
+ * namespace JSX {
13
+ * interface IntrinsicElements
14
+ * extends ScopedElements<'test-', ''> {}
15
+ * }
16
+ * }
17
+ * ```
18
+ *
19
+ * @deprecated Runtime scoped elements result in duplicate types and can confusing for developers. It is recommended to use the `prefix` and `suffix` options to generate new types instead.
20
+ */
21
+ export type ScopedElements<
22
+ Prefix extends string = "",
23
+ Suffix extends string = "",
24
+ > = {
25
+ [Key in keyof CustomElements as `${Prefix}${Key}${Suffix}`]: CustomElements[Key];
26
+ };
27
+
28
+ /**
29
+ * A generic type for strongly typing custom events with their targets
30
+ * @template T - The type of the event target (extends EventTarget)
31
+ * @template D - The type of the detail payload for the custom event
32
+ */
33
+ type TypedEvent<T extends EventTarget, E = Event> = E & {
34
+ target: T;
35
+ };
36
+
37
+ type BaseProps<T extends HTMLElement> = {
38
+ /** Content added between the opening and closing tags of the element */
39
+ children?: any;
40
+ /** Used for declaratively styling one or more elements using CSS (Cascading Stylesheets) */
41
+ class?: string;
42
+ /** Used for declaratively styling one or more elements using CSS (Cascading Stylesheets) */
43
+ className?: string;
44
+ /** Takes an object where the key is the class name(s) and the value is a boolean expression. When true, the class is applied, and when false, it is removed. */
45
+ classList?: Record<string, boolean | undefined>;
46
+ /** Specifies the text direction of the element. */
47
+ dir?: "ltr" | "rtl";
48
+ /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
49
+ exportparts?: string;
50
+ /** For <label> and <output>, lets you associate the label with some control. */
51
+ htmlFor?: string;
52
+ /** Specifies whether the element should be hidden. */
53
+ hidden?: boolean | string;
54
+ /** A unique identifier for the element. */
55
+ id?: string;
56
+ /** Keys tell React which array item each component corresponds to */
57
+ key?: string | number;
58
+ /** Specifies the language of the element. */
59
+ lang?: string;
60
+ /** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
61
+ part?: string;
62
+ /** Use the ref attribute with a variable to assign a DOM element to the variable once the element is rendered. */
63
+ ref?: T | ((e: T) => void);
64
+ /** Adds a reference for a custom element slot */
65
+ slot?: string;
66
+ /** Prop for setting inline styles */
67
+ style?: Record<string, string | number>;
68
+ /** Overrides the default Tab button behavior. Avoid using values other than -1 and 0. */
69
+ tabIndex?: number;
70
+ /** Specifies the tooltip text for the element. */
71
+ title?: string;
72
+ /** Passing 'no' excludes the element content from being translated. */
73
+ translate?: "yes" | "no";
74
+ /** The popover global attribute is used to designate an element as a popover element. */
75
+ popover?: "auto" | "hint" | "manual";
76
+ /** Turns an element element into a popover control button; takes the ID of the popover element to control as its value. */
77
+ popovertarget?: "top" | "bottom" | "left" | "right" | "auto";
78
+ /** Specifies the action to be performed on a popover element being controlled by a control element. */
79
+ popovertargetaction?: "show" | "hide" | "toggle";
80
+ };
81
+
82
+ type BaseEvents = {};
83
+
84
+ export type MyButtonProps = {
85
+ /** Changes the display of the button */
86
+ variation?: MyButton["variation"];
87
+ /** Controls the disabled property of the button */
88
+ disabled?: MyButton["disabled"];
89
+ };
90
+
91
+ export type MyButtonSolidJsProps = {
92
+ /** Changes the display of the button */
93
+ "prop:variation"?: MyButton["variation"];
94
+ /** Controls the disabled property of the button */
95
+ "prop:disabled"?: MyButton["disabled"];
96
+
97
+ /** Set the innerHTML of the element */
98
+ innerHTML?: string;
99
+ /** Set the textContent of the element */
100
+ textContent?: string | number;
101
+ };
102
+
103
+ export type CustomElements = {
104
+ /**
105
+ * An example button component
106
+ *
107
+ * ## Attributes & Properties
108
+ *
109
+ * Component attributes and properties that can be applied to the element or by using JavaScript.
110
+ *
111
+ * - `variation`: Changes the display of the button
112
+ * - `disabled`: Controls the disabled property of the button
113
+ *
114
+ * ## Slots
115
+ *
116
+ * Areas where markup can be added to the component.
117
+ *
118
+ * - `(default)`: The main content for the button
119
+ *
120
+ * ## CSS Custom Properties
121
+ *
122
+ * CSS variables available for styling the component.
123
+ *
124
+ * - `--button-bg-color`: The background color of the button (default: `#f0f0f0`)
125
+ * - `--button-fg-color`: The text color of the button (default: `#333`)
126
+ * - `--button-border-color`: The border color of the button (default: `transparent`)
127
+ *
128
+ * ## CSS Parts
129
+ *
130
+ * Custom selectors for styling elements within the component.
131
+ *
132
+ * - `control`: The button element
133
+ */
134
+ "my-button": Partial<MyButtonProps & BaseProps<MyButton> & BaseEvents>;
135
+ };
136
+
137
+ export type CustomElementsSolidJs = {
138
+ /**
139
+ * An example button component
140
+ *
141
+ * ## Attributes & Properties
142
+ *
143
+ * Component attributes and properties that can be applied to the element or by using JavaScript.
144
+ *
145
+ * - `variation`: Changes the display of the button
146
+ * - `disabled`: Controls the disabled property of the button
147
+ *
148
+ * ## Slots
149
+ *
150
+ * Areas where markup can be added to the component.
151
+ *
152
+ * - `(default)`: The main content for the button
153
+ *
154
+ * ## CSS Custom Properties
155
+ *
156
+ * CSS variables available for styling the component.
157
+ *
158
+ * - `--button-bg-color`: The background color of the button (default: `#f0f0f0`)
159
+ * - `--button-fg-color`: The text color of the button (default: `#333`)
160
+ * - `--button-border-color`: The border color of the button (default: `transparent`)
161
+ *
162
+ * ## CSS Parts
163
+ *
164
+ * Custom selectors for styling elements within the component.
165
+ *
166
+ * - `control`: The button element
167
+ */
168
+ "my-button": Partial<
169
+ MyButtonProps & MyButtonSolidJsProps & BaseProps<MyButton> & BaseEvents
170
+ >;
171
+ };
172
+
173
+ export type CustomCssProperties = {
174
+ /** The background color of the button */
175
+ "--button-bg-color"?: string;
176
+ /** The text color of the button */
177
+ "--button-fg-color"?: string;
178
+ /** The border color of the button */
179
+ "--button-border-color"?: string;
180
+ };
181
+
182
+ declare module "react" {
183
+ namespace JSX {
184
+ interface IntrinsicElements extends CustomElements {}
185
+ }
186
+ export interface CSSProperties extends CustomCssProperties {}
187
+ }
188
+
189
+ declare module "preact" {
190
+ namespace JSX {
191
+ interface IntrinsicElements extends CustomElements {}
192
+ }
193
+ export interface CSSProperties extends CustomCssProperties {}
194
+ }
195
+
196
+ declare module "@builder.io/qwik" {
197
+ namespace JSX {
198
+ interface IntrinsicElements extends CustomElements {}
199
+ }
200
+ export interface CSSProperties extends CustomCssProperties {}
201
+ }
202
+
203
+ declare module "@stencil/core" {
204
+ namespace JSX {
205
+ interface IntrinsicElements extends CustomElements {}
206
+ }
207
+ export interface CSSProperties extends CustomCssProperties {}
208
+ }
209
+
210
+ declare module "hono/jsx" {
211
+ namespace JSX {
212
+ interface IntrinsicElements extends CustomElements {}
213
+ }
214
+ export interface CSSProperties extends CustomCssProperties {}
215
+ }
216
+
217
+ declare module "react-native" {
218
+ namespace JSX {
219
+ interface IntrinsicElements extends CustomElements {}
220
+ }
221
+ export interface CSSProperties extends CustomCssProperties {}
222
+ }
223
+
224
+ declare module "solid-js" {
225
+ namespace JSX {
226
+ interface IntrinsicElements extends CustomElementsSolidJs {}
227
+ }
228
+ export interface CSSProperties extends CustomCssProperties {}
229
+ }
230
+
231
+ declare global {
232
+ namespace JSX {
233
+ interface IntrinsicElements extends CustomElements {}
234
+ }
235
+ export interface CSSProperties extends CustomCssProperties {}
236
+ }
@@ -0,0 +1,70 @@
1
+ type BaseProps = {
2
+ /** Content added between the opening and closing tags of the element */
3
+ children?: JSX.Element;
4
+ /** Used for declaratively styling one or more elements using CSS (Cascading Stylesheets) */
5
+ class?: string;
6
+ /** Takes an object where the key is the class name(s) and the value is a boolean expression. When true, the class is applied, and when false, it is removed. */
7
+ classList?: Record<string, boolean | undefined>;
8
+ /** Specifies the text direction of the element. */
9
+ dir?: "ltr" | "rtl";
10
+ /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
11
+ exportparts?: string;
12
+ /** Specifies whether the element should be hidden. */
13
+ hidden?: boolean | string;
14
+ /** A unique identifier for the element. */
15
+ id?: string;
16
+ /** Sets the HTML or XML markup contained within the element. */
17
+ innerHTML?: string;
18
+ /** Specifies the language of the element. */
19
+ lang?: string;
20
+ /** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
21
+ part?: string;
22
+ /** Use the ref attribute with a variable to assign a DOM element to the variable once the element is rendered. */
23
+ ref?: unknown | ((e: unknown) => void);
24
+ /** Adds a reference for a custom element slot */
25
+ slot?: string;
26
+ /** Prop for setting inline styles */
27
+ style?: JSX.CSSProperties;
28
+ /** Overrides the default Tab button behavior. Avoid using values other than -1 and 0. */
29
+ tabIndex?: number;
30
+ /** Sets the text content of the element */
31
+ textContent?: string;
32
+ /** Specifies the tooltip text for the element. */
33
+ title?: string;
34
+ /** Passing 'no' excludes the element content from being translated. */
35
+ translate?: "yes" | "no";
36
+ };
37
+
38
+ type BaseEvents = {};
39
+
40
+ type MyButtonProps = {
41
+ /** Changes the display of the button */
42
+ variation?: "default" | "primary" | "hollow" | "transparent" | undefined;
43
+ /** Controls the disabled property of the button */
44
+ disabled?: boolean;
45
+ };
46
+
47
+ export type CustomElements = {
48
+ /**
49
+ * An example button component
50
+ * ---
51
+ *
52
+ *
53
+ * ### **Slots:**
54
+ * - _default_ - The main content for the button
55
+ *
56
+ * ### **CSS Properties:**
57
+ * - **--button-bg-color** - The background color of the button _(default: #f0f0f0)_
58
+ * - **--button-fg-color** - The text color of the button _(default: #333)_
59
+ * - **--button-border-color** - The border color of the button _(default: transparent)_
60
+ *
61
+ * ### **CSS Parts:**
62
+ * - **control** - The button element
63
+ */
64
+ "my-button": Partial<MyButtonProps & BaseProps & BaseEvents>;
65
+ };
66
+
67
+ declare namespace svelteHTML {
68
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
69
+ interface IntrinsicElements extends CustomElements {}
70
+ }
@@ -0,0 +1,40 @@
1
+ import type { DefineComponent } from "vue";
2
+
3
+ type MyButtonProps = {
4
+ /** Changes the display of the button */
5
+ variation?: "default" | "primary" | "hollow" | "transparent" | undefined;
6
+ /** Controls the disabled property of the button */
7
+ disabled?: boolean;
8
+ };
9
+
10
+ export type CustomElements = {
11
+ /**
12
+ * An example button component
13
+ * ---
14
+ *
15
+ *
16
+ * ### **Slots:**
17
+ * - _default_ - The main content for the button
18
+ *
19
+ * ### **CSS Properties:**
20
+ * - **--button-bg-color** - The background color of the button _(default: #f0f0f0)_
21
+ * - **--button-fg-color** - The text color of the button _(default: #333)_
22
+ * - **--button-border-color** - The border color of the button _(default: transparent)_
23
+ *
24
+ * ### **CSS Parts:**
25
+ * - **control** - The button element
26
+ */
27
+ "my-button": DefineComponent<MyButtonProps>;
28
+ };
29
+
30
+ declare module "vue" {
31
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
32
+ interface GlobalComponents extends CustomElements {}
33
+ }
34
+
35
+ declare global {
36
+ namespace JSX {
37
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
38
+ interface IntrinsicElements extends CustomElements {}
39
+ }
40
+ }