@gild-ui/vue 0.0.0 → 0.1.0-alpha.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/dist/Button.cjs +238 -0
  4. package/dist/Button.d.cts +17 -0
  5. package/dist/Button.d.mts +17 -0
  6. package/dist/Button.mjs +237 -0
  7. package/dist/Button.types-BnJ28ym9.d.mts +1113 -0
  8. package/dist/Flex.cjs +25 -0
  9. package/dist/Flex.d.cts +11 -0
  10. package/dist/Flex.d.mts +11 -0
  11. package/dist/Flex.mjs +24 -0
  12. package/dist/Modal.cjs +369 -0
  13. package/dist/Modal.d.cts +23 -0
  14. package/dist/Modal.d.mts +23 -0
  15. package/dist/Modal.mjs +368 -0
  16. package/dist/TextInput.cjs +299 -0
  17. package/dist/TextInput.d.cts +37 -0
  18. package/dist/TextInput.d.mts +37 -0
  19. package/dist/TextInput.mjs +298 -0
  20. package/dist/ThemeProvider-CareN7BO.mjs +58 -0
  21. package/dist/ThemeProvider-DIeSdYou.cjs +63 -0
  22. package/dist/ThemeProvider.cjs +3 -0
  23. package/dist/ThemeProvider.d.cts +25 -0
  24. package/dist/ThemeProvider.d.mts +25 -0
  25. package/dist/ThemeProvider.mjs +1 -0
  26. package/dist/Typography.cjs +72 -0
  27. package/dist/Typography.d.cts +15 -0
  28. package/dist/Typography.d.mts +15 -0
  29. package/dist/Typography.mjs +71 -0
  30. package/dist/View.cjs +12 -0
  31. package/dist/View.d.cts +11 -0
  32. package/dist/View.d.mts +11 -0
  33. package/dist/View.mjs +11 -0
  34. package/dist/ViewRoot-CsaIxrtD.mjs +40 -0
  35. package/dist/ViewRoot-X9F9RROv.cjs +45 -0
  36. package/dist/bridge-D-x2kK4r.d.mts +36 -0
  37. package/dist/bridge-t6zHXVt-.d.cts +36 -0
  38. package/dist/engine.cjs +82 -0
  39. package/dist/engine.d.cts +46 -0
  40. package/dist/engine.d.mts +46 -0
  41. package/dist/engine.mjs +26 -0
  42. package/dist/index.cjs +57 -0
  43. package/dist/index.d.cts +37 -0
  44. package/dist/index.d.mts +37 -0
  45. package/dist/index.mjs +6 -0
  46. package/dist/props-BRLGZVjJ.d.mts +21 -0
  47. package/dist/props-Bzm7Wbdv.d.cts +21 -0
  48. package/dist/props-DDBSpAkG.mjs +49 -0
  49. package/dist/props-DxoB9cT4.cjs +72 -0
  50. package/dist/styled-Cmxvlft5.mjs +34 -0
  51. package/dist/styled-JHkZtq_1.cjs +39 -0
  52. package/dist/themes-BqxOUMCB.cjs +12 -0
  53. package/dist/themes-CgFrk0_b.d.cts +1112 -0
  54. package/dist/themes-rGHVhV5e.mjs +8 -0
  55. package/dist/useDefaultProps--fOGOSGa.mjs +18 -0
  56. package/dist/useDefaultProps-qCDgeYFm.cjs +23 -0
  57. package/dist/useTheme.cjs +8 -0
  58. package/dist/useTheme.d.cts +3 -0
  59. package/dist/useTheme.d.mts +3 -0
  60. package/dist/useTheme.mjs +1 -0
  61. package/package.json +167 -4
@@ -0,0 +1,21 @@
1
+ import "./Button.types-BnJ28ym9.mjs";
2
+ import { Component, HTMLAttributes, VNodeChild } from "vue";
3
+ /**
4
+ * The members of the React props that have no member of the same name in Vue: the content (`children`
5
+ * is the default slot), the class (`className` is `class`), and what only React's DOM has.
6
+ */
7
+ type ReactOnly = 'children' | 'className' | 'dangerouslySetInnerHTML' | 'suppressContentEditableWarning' | 'suppressHydrationWarning' | 'defaultChecked' | 'defaultValue';
8
+ /** The name of a listener: `onClick`. */
9
+ type ListenerKey = `on${Capitalize<string>}`;
10
+ /**
11
+ * The shared props as Vue has them: without the React-only members, without the listeners (which Vue
12
+ * types from its own attributes), and without `Replaced`, the members a component types again.
13
+ */
14
+ type SharedProps<Shared, Replaced extends PropertyKey = never> = { [K in keyof Shared as K extends ReactOnly | ListenerKey | Replaced ? never : K]: Shared[K]; };
15
+ /** The listeners of the Vue attributes of an element, and the `class` of any element. */
16
+ type Listeners<Attributes> = Pick<Attributes, keyof Attributes & ListenerKey> & Pick<HTMLAttributes, 'class'>;
17
+ /** What a slot gives a component: the content of the default slot, or of a named one. */
18
+ type Slot = () => VNodeChild;
19
+ /** The element a component renders as, by tag name or by component. */
20
+ type Tag = string | Component;
21
+ export { Tag as i, SharedProps as n, Slot as r, Listeners as t };
@@ -0,0 +1,21 @@
1
+ import "./themes-CgFrk0_b.cjs";
2
+ import { Component, HTMLAttributes, VNodeChild } from "vue";
3
+ /**
4
+ * The members of the React props that have no member of the same name in Vue: the content (`children`
5
+ * is the default slot), the class (`className` is `class`), and what only React's DOM has.
6
+ */
7
+ type ReactOnly = 'children' | 'className' | 'dangerouslySetInnerHTML' | 'suppressContentEditableWarning' | 'suppressHydrationWarning' | 'defaultChecked' | 'defaultValue';
8
+ /** The name of a listener: `onClick`. */
9
+ type ListenerKey = `on${Capitalize<string>}`;
10
+ /**
11
+ * The shared props as Vue has them: without the React-only members, without the listeners (which Vue
12
+ * types from its own attributes), and without `Replaced`, the members a component types again.
13
+ */
14
+ type SharedProps<Shared, Replaced extends PropertyKey = never> = { [K in keyof Shared as K extends ReactOnly | ListenerKey | Replaced ? never : K]: Shared[K]; };
15
+ /** The listeners of the Vue attributes of an element, and the `class` of any element. */
16
+ type Listeners<Attributes> = Pick<Attributes, keyof Attributes & ListenerKey> & Pick<HTMLAttributes, 'class'>;
17
+ /** What a slot gives a component: the content of the default slot, or of a named one. */
18
+ type Slot = () => VNodeChild;
19
+ /** The element a component renders as, by tag name or by component. */
20
+ type Tag = string | Component;
21
+ export { Tag as i, SharedProps as n, Slot as r, Listeners as t };
@@ -0,0 +1,49 @@
1
+ // src/overrides.ts
2
+ /**
3
+ * Several overrides of one element, merged in order: the later wins. The attributes are spread, the
4
+ * classes (`className` and `class`) joined, and the styles become one list (one style stays as it is, so
5
+ * an entry given alone keeps its own class). The root merges `slotProps.root` first and the component's
6
+ * own `style` and `class` after, so they win.
7
+ */
8
+ function mergeOverrides(...parts) {
9
+ const styles = parts.flatMap((part) => part?.style ? [part.style] : []);
10
+ return {
11
+ ...Object.assign({}, ...parts),
12
+ class: parts.flatMap((part) => [part?.className, part?.class]),
13
+ style: styles.length > 1 ? styles : styles[0]
14
+ };
15
+ }
16
+ // src/props.ts
17
+ /**
18
+ * The runtime declaration of props, which Vue needs to turn `full-width` into `fullWidth` and to cast a
19
+ * bare `<Button loading>` to `true`. A component declares its own props, and not the style props
20
+ * (`m`, `flexDirection`, ...): those stay attributes, written in camelCase, in the order they are given,
21
+ * which is the order their styles are written in, as it is in `@gild-ui/react`.
22
+ */
23
+ const declare = (...names) => Object.fromEntries(names.map((name) => [name, null]));
24
+ /** A boolean prop that is `undefined` when it is not given, so that a default can fill it in (Vue casts it to `false`). */
25
+ const flag = {
26
+ type: Boolean,
27
+ default: void 0
28
+ };
29
+ /**
30
+ * The props that hold a value, as an object: the declared props that were not given are `undefined` in
31
+ * Vue, which a style would read as a value.
32
+ */
33
+ const given = (props) => Object.fromEntries(Object.entries(props).filter(([, value]) => value !== void 0));
34
+ /**
35
+ * What a component gives its root element: the attributes it was given, its declared props that hold
36
+ * a value, and the overrides of `slotProps.root`, `style` and `class` merged.
37
+ */
38
+ function rootProps(props, attrs) {
39
+ const { slotProps, style, ...rest } = props;
40
+ return {
41
+ ...attrs,
42
+ ...given(rest),
43
+ ...mergeOverrides(slotProps?.root, {
44
+ style,
45
+ class: attrs.class
46
+ })
47
+ };
48
+ }
49
+ export { mergeOverrides as i, flag as n, rootProps as r, declare as t };
@@ -0,0 +1,72 @@
1
+ // src/overrides.ts
2
+ /**
3
+ * Several overrides of one element, merged in order: the later wins. The attributes are spread, the
4
+ * classes (`className` and `class`) joined, and the styles become one list (one style stays as it is, so
5
+ * an entry given alone keeps its own class). The root merges `slotProps.root` first and the component's
6
+ * own `style` and `class` after, so they win.
7
+ */
8
+ function mergeOverrides(...parts) {
9
+ const styles = parts.flatMap((part) => part?.style ? [part.style] : []);
10
+ return {
11
+ ...Object.assign({}, ...parts),
12
+ class: parts.flatMap((part) => [part?.className, part?.class]),
13
+ style: styles.length > 1 ? styles : styles[0]
14
+ };
15
+ }
16
+ // src/props.ts
17
+ /**
18
+ * The runtime declaration of props, which Vue needs to turn `full-width` into `fullWidth` and to cast a
19
+ * bare `<Button loading>` to `true`. A component declares its own props, and not the style props
20
+ * (`m`, `flexDirection`, ...): those stay attributes, written in camelCase, in the order they are given,
21
+ * which is the order their styles are written in, as it is in `@gild-ui/react`.
22
+ */
23
+ const declare = (...names) => Object.fromEntries(names.map((name) => [name, null]));
24
+ /** A boolean prop that is `undefined` when it is not given, so that a default can fill it in (Vue casts it to `false`). */
25
+ const flag = {
26
+ type: Boolean,
27
+ default: void 0
28
+ };
29
+ /**
30
+ * The props that hold a value, as an object: the declared props that were not given are `undefined` in
31
+ * Vue, which a style would read as a value.
32
+ */
33
+ const given = (props) => Object.fromEntries(Object.entries(props).filter(([, value]) => value !== void 0));
34
+ /**
35
+ * What a component gives its root element: the attributes it was given, its declared props that hold
36
+ * a value, and the overrides of `slotProps.root`, `style` and `class` merged.
37
+ */
38
+ function rootProps(props, attrs) {
39
+ const { slotProps, style, ...rest } = props;
40
+ return {
41
+ ...attrs,
42
+ ...given(rest),
43
+ ...mergeOverrides(slotProps?.root, {
44
+ style,
45
+ class: attrs.class
46
+ })
47
+ };
48
+ }
49
+ Object.defineProperty(exports, "declare", {
50
+ enumerable: true,
51
+ get: function() {
52
+ return declare;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "flag", {
56
+ enumerable: true,
57
+ get: function() {
58
+ return flag;
59
+ }
60
+ });
61
+ Object.defineProperty(exports, "mergeOverrides", {
62
+ enumerable: true,
63
+ get: function() {
64
+ return mergeOverrides;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "rootProps", {
68
+ enumerable: true,
69
+ get: function() {
70
+ return rootProps;
71
+ }
72
+ });
@@ -0,0 +1,34 @@
1
+ import { alpha, keyframes, styled as styled$1 } from "@umber-style/vue";
2
+ // src/styled.ts
3
+ const resolveStyle = (style, props) => typeof style === "function" ? style({
4
+ theme: props.theme,
5
+ ownerState: props
6
+ }) : style ?? null;
7
+ const matchesProps = (props, matcher) => Object.entries(matcher).every(([key, value]) => props[key] === value);
8
+ /**
9
+ * The styles a theme contributes to a styled root (`theme.components[name]`): the `styleOverrides` of
10
+ * its slot, then the variants whose props match.
11
+ */
12
+ const themeStyles = (name, slot) => (props) => {
13
+ const config = Reflect.get(props.theme, "components")?.[name];
14
+ if (!config) return null;
15
+ const applied = [];
16
+ if (config.styleOverrides) applied.push(resolveStyle(config.styleOverrides[slot], props));
17
+ if (slot === "root" && config.variants) {
18
+ for (const entry of config.variants) if (matchesProps(props, entry.props)) applied.push(resolveStyle(entry.style, props));
19
+ }
20
+ return applied;
21
+ };
22
+ /**
23
+ * The design system's `styled`: the engine's styled plus theme-level component customization
24
+ * (`theme.components[name].styleOverrides` / `.variants`).
25
+ */
26
+ function styled(tag, options = {}) {
27
+ const { name, slot = "root", systemProps = [], ...engineOptions } = options;
28
+ const create = styled$1(tag, engineOptions);
29
+ function make(...styles) {
30
+ return name === void 0 ? create(...styles) : create(...styles, themeStyles(name, slot), ...systemProps);
31
+ }
32
+ return make;
33
+ }
34
+ export { keyframes as n, styled as r, alpha as t };
@@ -0,0 +1,39 @@
1
+ let _umber_style_vue = require("@umber-style/vue");
2
+ // src/styled.ts
3
+ const resolveStyle = (style, props) => typeof style === "function" ? style({
4
+ theme: props.theme,
5
+ ownerState: props
6
+ }) : style ?? null;
7
+ const matchesProps = (props, matcher) => Object.entries(matcher).every(([key, value]) => props[key] === value);
8
+ /**
9
+ * The styles a theme contributes to a styled root (`theme.components[name]`): the `styleOverrides` of
10
+ * its slot, then the variants whose props match.
11
+ */
12
+ const themeStyles = (name, slot) => (props) => {
13
+ const config = Reflect.get(props.theme, "components")?.[name];
14
+ if (!config) return null;
15
+ const applied = [];
16
+ if (config.styleOverrides) applied.push(resolveStyle(config.styleOverrides[slot], props));
17
+ if (slot === "root" && config.variants) {
18
+ for (const entry of config.variants) if (matchesProps(props, entry.props)) applied.push(resolveStyle(entry.style, props));
19
+ }
20
+ return applied;
21
+ };
22
+ /**
23
+ * The design system's `styled`: the engine's styled plus theme-level component customization
24
+ * (`theme.components[name].styleOverrides` / `.variants`).
25
+ */
26
+ function styled(tag, options = {}) {
27
+ const { name, slot = "root", systemProps = [], ...engineOptions } = options;
28
+ const create = (0, _umber_style_vue.styled)(tag, engineOptions);
29
+ function make(...styles) {
30
+ return name === void 0 ? create(...styles) : create(...styles, themeStyles(name, slot), ...systemProps);
31
+ }
32
+ return make;
33
+ }
34
+ Object.defineProperty(exports, "styled", {
35
+ enumerable: true,
36
+ get: function() {
37
+ return styled;
38
+ }
39
+ });
@@ -0,0 +1,12 @@
1
+ // ../react/src/theme/themes.ts
2
+ /**
3
+ * The core's base theme, typed as this package's `Theme` - the same object. `createTheme(baseTheme, ...)`
4
+ * then accepts and returns `theme.components` too.
5
+ */
6
+ const baseTheme = require("@gild-ui/core/theme").baseTheme;
7
+ Object.defineProperty(exports, "baseTheme", {
8
+ enumerable: true,
9
+ get: function() {
10
+ return baseTheme;
11
+ }
12
+ });