@cronocode/react-box 1.6.8 → 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 (45) 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/theme.js +285 -0
  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 -1
  39. package/plugins.d.ts +0 -2
  40. package/plugins.mjs +0 -1
  41. package/theme.cjs +0 -1
  42. package/theme.mjs +0 -74
  43. package/utils/utils.cjs +0 -1
  44. /package/{box.module.css.mjs → box.module.css.js} +0 -0
  45. /package/{utils/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/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/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/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/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/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/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/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/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/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.8",
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'>>;
package/theme.js ADDED
@@ -0,0 +1,285 @@
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) => `
59
+ .color_${o},
60
+ .color_h_${o}:hover,
61
+ ._h:hover>.color_h_${o} {
62
+ color: var(--color${o});
63
+ }
64
+
65
+ .color_f_${o}:focus-within,
66
+ ._f:focus-within>.color_f_${o} {
67
+ color: var(--color${o});
68
+ }
69
+
70
+ .color_a_${o}:active {
71
+ color: var(--color${o});
72
+ }
73
+
74
+ .bgColor_${o},
75
+ .bgColor_h_${o}:hover,
76
+ ._h:hover>.bgColor_h_${o} {
77
+ background-color: var(--color${o});
78
+ }
79
+
80
+ .bgColor_f_${o}:focus-within,
81
+ ._f:focus-within>.bgColor_f_${o} {
82
+ background-color: var(--color${o});
83
+ }
84
+
85
+ .bgColor_a_${o}:active {
86
+ background-color: var(--color${o});
87
+ }
88
+
89
+ .borderColor_${o},
90
+ .borderColor_h_${o}:hover,
91
+ ._h:hover>.borderColor_h_${o} {
92
+ border-color: var(--color${o});
93
+ }
94
+
95
+ .borderColor_f_${o}:focus-within,
96
+ ._f:focus-within>.borderColor_f_${o} {
97
+ border-color: var(--color${o});
98
+ }
99
+
100
+ .borderColor_a_${o}:active {
101
+ border-color: var(--color${o});
102
+ }
103
+
104
+ .outlineColor_${o},
105
+ .outlineColor_h_${o}:hover,
106
+ ._h:hover>.outlineColor_h_${o} {
107
+ outline-color: var(--color${o});
108
+ }
109
+
110
+ .outlineColor_f_${o}:focus-within,
111
+ ._f:focus-within>.outlineColor_f_${o} {
112
+ outline-color: var(--color${o});
113
+ }
114
+
115
+ .outlineColor_a_${o}:active {
116
+ outline-color: var(--color${o});
117
+ }
118
+
119
+ .fill_${o},
120
+ .fill_h_${o}:hover,
121
+ ._h:hover>.fill_h_${o} {
122
+ path,
123
+ circle,
124
+ rect,
125
+ line {
126
+ fill: var(--color${o});
127
+ }
128
+ }
129
+
130
+ .fill_f_${o}:focus-within,
131
+ ._f:focus-within>.fill_f_${o} {
132
+ path,
133
+ circle,
134
+ rect,
135
+ line {
136
+ fill: var(--color${o});
137
+ }
138
+ }
139
+
140
+ .fill_a_${o}:active {
141
+ path,
142
+ circle,
143
+ rect,
144
+ line {
145
+ fill: var(--color${o});
146
+ }
147
+ }
148
+
149
+ .stroke_${o},
150
+ .stroke_h_${o}:hover,
151
+ ._h:hover>.stroke_h_${o} {
152
+ path,
153
+ circle,
154
+ rect,
155
+ line {
156
+ stroke: var(--color${o});
157
+ }
158
+ }
159
+
160
+ .stroke_f_${o}:focus-within,
161
+ ._f:focus-within>.stroke_f_${o} {
162
+ path,
163
+ circle,
164
+ rect,
165
+ line {
166
+ stroke: var(--color${o});
167
+ }
168
+ }
169
+
170
+ .stroke_a_${o}:active {
171
+ path,
172
+ circle,
173
+ rect,
174
+ line {
175
+ stroke: var(--color${o});
176
+ }
177
+ }`), y = Object.keys(r.shadows).map((o) => `
178
+ .shadow_${o},
179
+ .shadow_h_${o}:hover,
180
+ ._h:hover>.shadow_h_${o} {
181
+ box-shadow: var(--shadow${o});
182
+ }
183
+
184
+ .shadow_f_${o}:focus-within,
185
+ ._f:focus-within>.shadow_f_${o} {
186
+ box-shadow: var(--shadow${o});
187
+ }
188
+
189
+ .shadow_a_${o}:active {
190
+ box-shadow: var(--shadow${o});
191
+ }`), f = Object.keys(r.backgrounds).map((o) => `
192
+ .bg_${o},
193
+ .bg_h_${o}:hover,
194
+ ._h:hover>.bg_h_${o} {
195
+ background: var(--background${o});
196
+ }
197
+
198
+ .bg_f_${o}:focus-within,
199
+ ._f:focus-within>.bg_f_${o} {
200
+ background: var(--background${o});
201
+ }
202
+
203
+ .bg_a_${o}:active {
204
+ background: var(--background${o});
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';
208
+
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};
213
+
214
+ namespace Augmented {
215
+ interface BoxProps {
216
+ color?: ColorType;
217
+ colorH?: ColorType;
218
+ colorF?: ColorType;
219
+ colorA?: ColorType;
220
+ bgColor?: ColorType;
221
+ bgColorH?: ColorType;
222
+ bgColorF?: ColorType;
223
+ bgColorA?: ColorType;
224
+ borderColor?: ColorType;
225
+ borderColorH?: ColorType;
226
+ borderColorF?: ColorType;
227
+ borderColorA?: ColorType;
228
+ outlineColor?: ColorType;
229
+ outlineColorH?: ColorType;
230
+ outlineColorF?: ColorType;
231
+ outlineColorA?: ColorType;
232
+ background?: BackgroundType;
233
+ backgroundH?: BackgroundType;
234
+ backgroundF?: BackgroundType;
235
+ backgroundA?: BackgroundType;
236
+ shadow?: ShadowType;
237
+ shadowH?: ShadowType;
238
+ shadowF?: ShadowType;
239
+ shadowA?: ShadowType;
240
+ }
241
+
242
+ interface SvgProps {
243
+ fill?: ColorType;
244
+ fillH?: ColorType;
245
+ fillF?: ColorType;
246
+ fillA?: ColorType;
247
+ stroke?: ColorType;
248
+ strokeH?: ColorType;
249
+ strokeF?: ColorType;
250
+ strokeA?: ColorType;
251
+ }
252
+ }
253
+ }
254
+ `;
255
+ return {
256
+ variables: s.join(`
257
+ `),
258
+ themeCss: p,
259
+ boxDts: T
260
+ };
261
+ }
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/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/utils.mjs";
4
- import "./theme.mjs";
5
- export {
6
- r as default
7
- };