@cronocode/react-box 1.6.9 → 1.7.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 (44) hide show
  1. package/box.js +7 -0
  2. package/components/baseSvg.js +6 -0
  3. package/components/{button.mjs → button.js} +3 -3
  4. package/components/{checkbox.mjs → checkbox.js} +5 -5
  5. package/components/dataGrid.js +5 -0
  6. package/components/{dox.mjs → dox.js} +2 -2
  7. package/components/{doxSvg.mjs → doxSvg.js} +3 -3
  8. package/components/{flex.mjs → flex.js} +3 -3
  9. package/components/form.js +5 -0
  10. package/components/{grid.mjs → grid.js} +3 -3
  11. package/components/{radioButton.mjs → radioButton.js} +3 -3
  12. package/components/{textarea.mjs → textarea.js} +3 -3
  13. package/components/{textbox.mjs → textbox.js} +3 -3
  14. package/components/tooltip.js +6 -0
  15. package/package.json +9 -14
  16. package/theme.d.ts +12 -0
  17. package/{plugins.mjs → theme.js} +95 -31
  18. package/box.cjs +0 -1
  19. package/box.mjs +0 -7
  20. package/box.module.css.cjs +0 -1
  21. package/components/baseSvg.cjs +0 -1
  22. package/components/baseSvg.mjs +0 -6
  23. package/components/button.cjs +0 -1
  24. package/components/checkbox.cjs +0 -1
  25. package/components/dataGrid.cjs +0 -1
  26. package/components/dataGrid.mjs +0 -5
  27. package/components/dox.cjs +0 -7
  28. package/components/doxSvg.cjs +0 -1
  29. package/components/flex.cjs +0 -1
  30. package/components/form.cjs +0 -1
  31. package/components/form.mjs +0 -5
  32. package/components/grid.cjs +0 -1
  33. package/components/radioButton.cjs +0 -1
  34. package/components/textarea.cjs +0 -1
  35. package/components/textbox.cjs +0 -1
  36. package/components/tooltip.cjs +0 -1
  37. package/components/tooltip.mjs +0 -6
  38. package/plugins.cjs +0 -209
  39. package/plugins.d.ts +0 -13
  40. package/theme.cjs +0 -1
  41. package/theme.mjs +0 -74
  42. package/utils.cjs +0 -1
  43. /package/{box.module.css.mjs → box.module.css.js} +0 -0
  44. /package/{utils.mjs → utils.js} +0 -0
package/box.js ADDED
@@ -0,0 +1,7 @@
1
+ import r from "./components/dox.js";
2
+ import "react";
3
+ import "./utils.js";
4
+ import "./theme.js";
5
+ export {
6
+ r as default
7
+ };
@@ -0,0 +1,6 @@
1
+ import "./doxSvg.js";
2
+ import "react/jsx-runtime";
3
+ import "react";
4
+ import "./dox.js";
5
+ import "../utils.js";
6
+ import "../theme.js";
@@ -1,8 +1,8 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import { forwardRef as i } from "react";
3
- import m from "./dox.mjs";
4
- import { O as p } from "../utils.mjs";
5
- import "../theme.mjs";
3
+ import m from "./dox.js";
4
+ import { O as p } from "../utils.js";
5
+ import "../theme.js";
6
6
  const s = ["type", "onClick", "disabled"];
7
7
  function e(o, t) {
8
8
  const r = p.buildProps(o, s);
@@ -1,10 +1,10 @@
1
1
  import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as c } from "react";
3
- import t from "./dox.mjs";
4
- import { O as a } from "../utils.mjs";
5
- import l from "./flex.mjs";
6
- import { c as d } from "../box.module.css.mjs";
7
- import "../theme.mjs";
3
+ import t from "./dox.js";
4
+ import { O as a } from "../utils.js";
5
+ import l from "./flex.js";
6
+ import { c as d } from "../box.module.css.js";
7
+ import "../theme.js";
8
8
  const p = [
9
9
  "name",
10
10
  "onInput",
@@ -0,0 +1,5 @@
1
+ import "react/jsx-runtime";
2
+ import "./dox.js";
3
+ import "react";
4
+ import "../utils.js";
5
+ import "../theme.js";
@@ -1,6 +1,6 @@
1
1
  import O, { useMemo as j, useLayoutEffect as I, useEffect as _, forwardRef as D, useState as P } from "react";
2
- import { I as M, C as W } from "../utils.mjs";
3
- import { useTheme as G } from "../theme.mjs";
2
+ import { I as M, C as W } from "../utils.js";
3
+ import { useTheme as G } from "../theme.js";
4
4
  var e;
5
5
  ((a) => {
6
6
  ((r) => {
@@ -1,8 +1,8 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as f } from "react";
3
- import g from "./dox.mjs";
4
- import "../utils.mjs";
5
- import "../theme.mjs";
3
+ import g from "./dox.js";
4
+ import "../utils.js";
5
+ import "../theme.js";
6
6
  function n(o, r) {
7
7
  const { viewBox: t = "0 0 24 24", width: p = "1.5rem", height: i, props: m, ...s } = o;
8
8
  return /* @__PURE__ */ e(
@@ -1,8 +1,8 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import { forwardRef as f } from "react";
3
- import n from "./dox.mjs";
4
- import "../utils.mjs";
5
- import "../theme.mjs";
3
+ import n from "./dox.js";
4
+ import "../utils.js";
5
+ import "../theme.js";
6
6
  function l(o, r) {
7
7
  const { inline: t, ...e } = o;
8
8
  return /* @__PURE__ */ i(n, { ref: r, display: t ? "inline-flex" : "flex", ...e });
@@ -0,0 +1,5 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "./dox.js";
4
+ import "../utils.js";
5
+ import "../theme.js";
@@ -1,8 +1,8 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
2
  import { forwardRef as n } from "react";
3
- import p from "./dox.mjs";
4
- import "../utils.mjs";
5
- import "../theme.mjs";
3
+ import p from "./dox.js";
4
+ import "../utils.js";
5
+ import "../theme.js";
6
6
  function f(r, i) {
7
7
  const { inline: o, ...t } = r;
8
8
  return /* @__PURE__ */ m(p, { ref: i, display: o ? "inline-grid" : "grid", ...t });
@@ -1,8 +1,8 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as n } from "react";
3
- import a from "./dox.mjs";
4
- import { O as i } from "../utils.mjs";
5
- import "../theme.mjs";
3
+ import a from "./dox.js";
4
+ import { O as i } from "../utils.js";
5
+ import "../theme.js";
6
6
  const d = [
7
7
  "name",
8
8
  "onInput",
@@ -1,8 +1,8 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { forwardRef as a } from "react";
3
- import n from "./dox.mjs";
4
- import { O as m } from "../utils.mjs";
5
- import "../theme.mjs";
3
+ import n from "./dox.js";
4
+ import { O as m } from "../utils.js";
5
+ import "../theme.js";
6
6
  const s = [
7
7
  "name",
8
8
  "onInput",
@@ -1,8 +1,8 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as n } from "react";
3
- import a from "./dox.mjs";
4
- import { O as p } from "../utils.mjs";
5
- import "../theme.mjs";
3
+ import a from "./dox.js";
4
+ import { O as p } from "../utils.js";
5
+ import "../theme.js";
6
6
  const i = [
7
7
  "name",
8
8
  "onInput",
@@ -0,0 +1,6 @@
1
+ import "react/jsx-runtime";
2
+ import "react-dom";
3
+ import "./dox.js";
4
+ import "react";
5
+ import "../utils.js";
6
+ import "../theme.js";
package/package.json CHANGED
@@ -1,33 +1,28 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.6.9",
4
- "main": "./box.cjs",
5
- "module": "./box.mjs",
3
+ "version": "1.7.0",
4
+ "main": "./box.js",
5
+ "module": "./box.js",
6
6
  "types": "./box.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./box.mjs",
10
- "require": "./box.cjs",
9
+ "import": "./box.js",
10
+ "require": "./box.js",
11
11
  "types": "./box.d.ts"
12
12
  },
13
13
  "./style.css": "./style.css",
14
14
  "./theme": {
15
- "import": "./theme.mjs",
16
- "require": "./theme.cjs",
15
+ "import": "./theme.js",
16
+ "require": "./theme.js",
17
17
  "types": "./theme.d.ts"
18
18
  },
19
19
  "./types": {
20
20
  "types": "./types.d.ts"
21
21
  },
22
22
  "./components/*": {
23
- "import": "./components/*.mjs",
24
- "require": "./components/*.cjs",
23
+ "import": "./components/*.js",
24
+ "require": "./components/*.js",
25
25
  "types": "./components/*.d.ts"
26
- },
27
- "./plugins": {
28
- "import": "./plugins.mjs",
29
- "require": "./plugins.cjs",
30
- "types": "./plugins.d.ts"
31
26
  }
32
27
  },
33
28
  "scripts": {
package/theme.d.ts CHANGED
@@ -20,8 +20,20 @@ export interface ThemeSetup {
20
20
  checkbox?: ThemeComponentStyles;
21
21
  radioButton?: ThemeComponentStyles;
22
22
  }
23
+ interface BoxAugmentedProps {
24
+ colors: Record<string, string>;
25
+ shadows: Record<string, string>;
26
+ backgrounds: Record<string, string>;
27
+ }
23
28
  declare namespace Theme {
24
29
  function setup(styles: ThemeSetup): void;
30
+ function setupAugmentedProps(props: BoxAugmentedProps, options?: {
31
+ namespacePath?: string;
32
+ }): {
33
+ variables: string;
34
+ themeCss: string;
35
+ boxDts: string;
36
+ };
25
37
  }
26
38
  export default Theme;
27
39
  type ReservedComponentName = Exclude<string, keyof Omit<ThemeSetup, 'components'>>;
@@ -1,12 +1,61 @@
1
- var c;
2
- ((i) => {
3
- function h(r) {
4
- const _ = Object.entries(r.colors).map(([o, e]) => `--color${o}: ${e};`).join(`
5
- `), t = Object.entries(r.shadows).map(([o, e]) => `--shadow${o}: ${e};`).join(`
6
- `), n = Object.entries(r.backgrounds).map(([o, e]) => `--background${o}: ${e};`).join(`
7
- `), l = [":root {"];
8
- _ && l.push(` ${_}`), t && l.push(` ${t}`), n && l.push(` ${n}`), l.push("}");
9
- const $ = Object.keys(r.colors).map((o) => `
1
+ import { useMemo as g } from "react";
2
+ const $ = {
3
+ button: {
4
+ styles: {
5
+ display: "inline-block",
6
+ p: 3,
7
+ cursor: "pointer",
8
+ b: 1,
9
+ borderRadius: 1
10
+ },
11
+ disabled: {
12
+ cursor: "default"
13
+ }
14
+ },
15
+ checkbox: {
16
+ styles: {
17
+ display: "inline-block",
18
+ b: 1,
19
+ p: 2
20
+ }
21
+ },
22
+ radioButton: {
23
+ styles: {
24
+ display: "inline-block",
25
+ b: 1,
26
+ p: 2
27
+ }
28
+ },
29
+ textbox: {
30
+ styles: {
31
+ display: "inline-block",
32
+ b: 1,
33
+ borderRadius: 1,
34
+ p: 3
35
+ }
36
+ },
37
+ textarea: {
38
+ styles: {
39
+ display: "inline-block",
40
+ b: 1,
41
+ borderRadius: 1
42
+ }
43
+ }
44
+ };
45
+ let _ = $;
46
+ var u;
47
+ ((h) => {
48
+ function d(r) {
49
+ _ = r, i();
50
+ }
51
+ h.setup = d;
52
+ function b(r, e) {
53
+ const t = Object.entries(r.colors).map(([o, c]) => `--color${o}: ${c};`).join(`
54
+ `), l = Object.entries(r.shadows).map(([o, c]) => `--shadow${o}: ${c};`).join(`
55
+ `), n = Object.entries(r.backgrounds).map(([o, c]) => `--background${o}: ${c};`).join(`
56
+ `), s = [":root {"];
57
+ t && s.push(` ${t}`), l && s.push(` ${l}`), n && s.push(` ${n}`), s.push("}");
58
+ const a = Object.keys(r.colors).map((o) => `
10
59
  .color_${o},
11
60
  .color_h_${o}:hover,
12
61
  ._h:hover>.color_h_${o} {
@@ -125,7 +174,7 @@ var c;
125
174
  line {
126
175
  stroke: var(--color${o});
127
176
  }
128
- }`), s = Object.keys(r.shadows).map((o) => `
177
+ }`), y = Object.keys(r.shadows).map((o) => `
129
178
  .shadow_${o},
130
179
  .shadow_h_${o}:hover,
131
180
  ._h:hover>.shadow_h_${o} {
@@ -139,7 +188,7 @@ var c;
139
188
 
140
189
  .shadow_a_${o}:active {
141
190
  box-shadow: var(--shadow${o});
142
- }`), b = Object.keys(r.backgrounds).map((o) => `
191
+ }`), f = Object.keys(r.backgrounds).map((o) => `
143
192
  .bg_${o},
144
193
  .bg_h_${o}:hover,
145
194
  ._h:hover>.bg_h_${o} {
@@ -153,12 +202,14 @@ var c;
153
202
 
154
203
  .bg_a_${o}:active {
155
204
  background: var(--background${o});
156
- }`), p = Object.keys(r.colors).map((o) => `'${o}'`).join(" | "), u = Object.keys(r.backgrounds).map((o) => `'${o}'`).join(" | "), C = Object.keys(r.shadows).map((o) => `'${o}'`).join(" | "), d = `import '@cronocode/react-box';
205
+ }`), p = [...a, ...y, ...f].join(`
206
+ `) + `
207
+ `, C = Object.keys(r.colors).map((o) => `'${o}'`).join(" | "), v = Object.keys(r.backgrounds).map((o) => `'${o}'`).join(" | "), k = Object.keys(r.shadows).map((o) => `'${o}'`).join(" | "), T = `import '@cronocode/react-box';
157
208
 
158
- declare module '@cronocode/react-box/types' {
159
- type ColorType = ${p};
160
- type BackgroundType = ${u};
161
- type ShadowType = ${C};
209
+ declare module '${(e == null ? void 0 : e.namespacePath) ?? "@cronocode/react-box/types"}' {
210
+ type ColorType = ${C};
211
+ type BackgroundType = ${v};
212
+ type ShadowType = ${k};
162
213
 
163
214
  namespace Augmented {
164
215
  interface BoxProps {
@@ -170,10 +221,6 @@ var c;
170
221
  bgColorH?: ColorType;
171
222
  bgColorF?: ColorType;
172
223
  bgColorA?: ColorType;
173
- backgroundColor?: ColorType;
174
- backgroundColorH?: ColorType;
175
- backgroundColorF?: ColorType;
176
- backgroundColorA?: ColorType;
177
224
  borderColor?: ColorType;
178
225
  borderColorH?: ColorType;
179
226
  borderColorF?: ColorType;
@@ -182,10 +229,6 @@ var c;
182
229
  outlineColorH?: ColorType;
183
230
  outlineColorF?: ColorType;
184
231
  outlineColorA?: ColorType;
185
- bg?: BackgroundType;
186
- bgH?: BackgroundType;
187
- bgF?: BackgroundType;
188
- bgA?: BackgroundType;
189
232
  background?: BackgroundType;
190
233
  backgroundH?: BackgroundType;
191
234
  backgroundF?: BackgroundType;
@@ -210,12 +253,33 @@ var c;
210
253
  }
211
254
  `;
212
255
  return {
213
- themeCss: [l.join(`
214
- `), ...$, ...s, ...b].join(`
215
- `) + `
216
- `,
217
- boxDts: d
256
+ variables: s.join(`
257
+ `),
258
+ themeCss: p,
259
+ boxDts: T
218
260
  };
219
261
  }
220
- i.boxTheme = h;
221
- })(c || (c = {}));
262
+ h.setupAugmentedProps = b;
263
+ function i() {
264
+ Object.keys($).forEach((e) => {
265
+ const t = _[e], l = $[e];
266
+ t ? (t.styles = { ...l.styles, ...t.styles }, t.disabled && l.disabled && (t.disabled = { ...l.disabled, ...t.disabled })) : _[e] = $[e];
267
+ });
268
+ }
269
+ })(u || (u = {}));
270
+ function j(h) {
271
+ const { clean: d, disabled: b, theme: i, component: r } = h;
272
+ return g(() => {
273
+ var l, n, s;
274
+ if (d)
275
+ return;
276
+ let e = _[r] ?? ((l = _.components) == null ? void 0 : l[r]);
277
+ if (!e)
278
+ return;
279
+ let t = i ? { ...e.styles, ...(n = e.themes) == null ? void 0 : n[i].styles } : e.styles;
280
+ return b ? i ? { ...t, ...e.disabled, ...(s = e.themes) == null ? void 0 : s[i].disabled } : { ...t, ...e.disabled } : t;
281
+ }, [r, d, b, i]);
282
+ }
283
+ export {
284
+ j as useTheme
285
+ };
package/box.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./components/dox.cjs");require("react");require("./utils.cjs");require("./theme.cjs");exports.default=e.default;
package/box.mjs DELETED
@@ -1,7 +0,0 @@
1
- import r from "./components/dox.mjs";
2
- import "react";
3
- import "./utils.mjs";
4
- import "./theme.mjs";
5
- export {
6
- r as default
7
- };