@cronocode/react-box 1.7.1 → 1.7.3

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.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
+ "type": "module",
4
5
  "main": "./box.js",
5
6
  "module": "./box.js",
6
7
  "types": "./box.d.ts",
@@ -10,14 +11,18 @@
10
11
  "require": "./box.js",
11
12
  "types": "./box.d.ts"
12
13
  },
13
- "./style.css": "./style.css",
14
14
  "./theme": {
15
15
  "import": "./theme.js",
16
16
  "require": "./theme.js",
17
17
  "types": "./theme.d.ts"
18
18
  },
19
- "./types": {
20
- "types": "./types.d.ts"
19
+ "./core/types": {
20
+ "types": "./core/types.d.ts"
21
+ },
22
+ "./ssg": {
23
+ "import": "./ssg.js",
24
+ "require": "./ssg.js",
25
+ "types": "./ssg.d.ts"
21
26
  },
22
27
  "./components/*": {
23
28
  "import": "./components/*.js",
@@ -30,7 +35,7 @@
30
35
  "build:pages": "vite build ./pages --config ./pages.vite.config.ts --outDir ../dist --mode production",
31
36
  "preview": "vite preview",
32
37
  "build": "vite build",
33
- "postbuild": "cp package.json dist & cp LICENSE dist & cp README.md dist & rm ./dist/index.d.ts & rm ./dist/index.js",
38
+ "postbuild": "cp package.json dist & cp LICENSE dist & cp README.md dist",
34
39
  "build:dev": "vite build --mode dev",
35
40
  "compile": "tsc --noEmit --skipLibCheck",
36
41
  "test": "echo \"Error: no test specified\" && exit 1"
package/ssg.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import StylesContext from './core/stylesContext';
2
+ declare const flushStyles: typeof StylesContext.flush;
3
+ export { flushStyles };
package/ssg.js ADDED
@@ -0,0 +1,6 @@
1
+ import { S as t } from "./core.js";
2
+ import "react";
3
+ const { flush: e } = t;
4
+ export {
5
+ e as flushStyles
6
+ };
package/theme.d.ts CHANGED
@@ -1,46 +1,2 @@
1
- import { BoxStyles } from './types';
2
- export interface ThemeStyles {
3
- styles: BoxStyles;
4
- disabled?: BoxStyles;
5
- }
6
- export interface ThemeComponentStyles {
7
- styles: BoxStyles;
8
- disabled?: BoxStyles;
9
- themes?: {
10
- [name: string]: ThemeStyles;
11
- };
12
- }
13
- export interface ThemeSetup {
14
- components?: {
15
- [name: string]: ThemeComponentStyles;
16
- };
17
- button?: ThemeComponentStyles;
18
- textbox?: ThemeComponentStyles;
19
- textarea?: ThemeComponentStyles;
20
- checkbox?: ThemeComponentStyles;
21
- radioButton?: ThemeComponentStyles;
22
- }
23
- interface BoxAugmentedProps {
24
- colors: Record<string, string>;
25
- shadows: Record<string, string>;
26
- backgrounds: Record<string, string>;
27
- }
28
- declare namespace Theme {
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
- };
37
- }
1
+ import Theme from './core/theme';
38
2
  export default Theme;
39
- type ReservedComponentName = Exclude<string, keyof Omit<ThemeSetup, 'components'>>;
40
- export interface ThemeComponentProps {
41
- clean?: boolean;
42
- disabled?: boolean;
43
- component?: ReservedComponentName;
44
- theme?: string;
45
- }
46
- export declare function useTheme(props: ThemeComponentProps): BoxStyles | undefined;
package/theme.js CHANGED
@@ -1,287 +1,5 @@
1
- import { useMemo as g } from "react";
2
- const b = {
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 _ = b;
46
- var u;
47
- ((h) => {
48
- function d(r) {
49
- _ = r, i();
50
- }
51
- h.setup = d;
52
- function $(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 = $;
263
- function i() {
264
- Object.keys(b).forEach((e) => {
265
- const t = _[e], l = b[e];
266
- t ? (t.styles = { ...l.styles, ...t.styles }, t.disabled && l.disabled && (t.disabled = { ...l.disabled, ...t.disabled })) : _[e] = b[e];
267
- });
268
- }
269
- })(u || (u = {}));
270
- const j = u;
271
- function x(h) {
272
- const { clean: d, disabled: $, theme: i, component: r } = h;
273
- return g(() => {
274
- var l, n, s;
275
- if (d)
276
- return;
277
- let e = _[r] ?? ((l = _.components) == null ? void 0 : l[r]);
278
- if (!e)
279
- return;
280
- let t = i ? { ...e.styles, ...(n = e.themes) == null ? void 0 : n[i].styles } : e.styles;
281
- return $ ? i ? { ...t, ...e.disabled, ...(s = e.themes) == null ? void 0 : s[i].disabled } : { ...t, ...e.disabled } : t;
282
- }, [r, d, $, i]);
283
- }
1
+ import { T as m } from "./core.js";
2
+ import "react";
284
3
  export {
285
- j as T,
286
- x as u
4
+ m as default
287
5
  };
package/utils.js CHANGED
@@ -1,107 +1,70 @@
1
- import { useMemo as x } from "react";
2
- var p;
3
- ((c) => {
4
- function i(...u) {
5
- return u.reduce((n, o) => o ? typeof o == "string" ? (n.push(o), n) : Array.isArray(o) ? (n.push(...i(...o)), n) : (Object.entries(o).forEach(([r, e]) => {
6
- e && n.push(r);
7
- }), n) : n, []);
8
- }
9
- c.classNames = i;
10
- })(p || (p = {}));
11
- const y = p;
12
- class I {
13
- constructor() {
14
- this._index = 0, this._cache = {};
15
- }
16
- getIdentity(i) {
17
- return this._cache[i] || (this._cache[i] = this.getByIndex(this._index++)), this._cache[i];
18
- }
19
- getByIndex(i) {
20
- const { first: u, next: n } = m, o = i - u.length;
21
- if (o < 0)
22
- return u[i];
23
- const r = Math.floor(o / n.length), e = o - r * n.length;
24
- return this.getByIndex(r) + n[e];
25
- }
26
- }
27
- const m = {
28
- first: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
29
- next: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
30
- };
31
1
  var l;
32
- ((c) => {
33
- function i(n, ...o) {
34
- const r = { ...n }, e = {};
35
- return o.forEach((t) => {
36
- t in r && (e[t] = r[t], delete r[t]);
37
- }), [e, r];
2
+ ((f) => {
3
+ function a(c, ...s) {
4
+ const e = { ...c }, t = {};
5
+ return s.forEach((r) => {
6
+ r in e && (t[r] = e[r], delete e[r]);
7
+ }), [t, e];
38
8
  }
39
- c.moveToTagProps = i;
40
- function u(n, o, r) {
41
- const e = { ...n }, t = e.props || {};
42
- return o.forEach((s) => {
43
- if (s in e) {
44
- if (t[s] = e[s], s === "disabled")
9
+ f.moveToTagProps = a;
10
+ function p(c, s, e) {
11
+ const t = { ...c }, r = t.props || {};
12
+ return s.forEach((o) => {
13
+ if (o in t) {
14
+ if (r[o] = t[o], o === "disabled")
45
15
  return;
46
- delete e[s];
16
+ delete t[o];
47
17
  }
48
- }), r && Object.entries(r).forEach(([s, f]) => {
49
- t[s] = f;
50
- }), e.props = t, e;
18
+ }), e && Object.entries(e).forEach(([o, i]) => {
19
+ r[o] = i;
20
+ }), t.props = r, t;
51
21
  }
52
- c.buildProps = u;
22
+ f.buildProps = p;
53
23
  })(l || (l = {}));
54
- const E = l;
55
- var g;
56
- ((c) => {
57
- function i(n) {
58
- const o = Array.from(n.elements).reduce((r, e) => {
59
- const t = e.name;
60
- return t && (r[t] || (r[t] = []), r[t].push(e)), r;
61
- }, {});
62
- return Object.entries(o).reduce((r, [e, t]) => {
63
- if (t.length === 1) {
64
- const s = t[0];
65
- u(r, e, s.type === "checkbox" || s.type === "radio" ? s.checked : s.value);
24
+ const m = l;
25
+ var h;
26
+ ((f) => {
27
+ function a(c) {
28
+ const s = Array.from(c.elements).reduce(
29
+ (e, t) => {
30
+ const r = t.name;
31
+ return r && (e[r] || (e[r] = []), e[r].push(t)), e;
32
+ },
33
+ {}
34
+ );
35
+ return Object.entries(s).reduce((e, [t, r]) => {
36
+ if (r.length === 1) {
37
+ const o = r[0];
38
+ p(e, t, o.type === "checkbox" || o.type === "radio" ? o.checked : o.value);
66
39
  } else {
67
- const s = t.reduce((f, d) => (d.type === "checkbox" || d.type === "radio" ? d.checked && f.push(d.value) : f.push(d.value), f), []);
68
- u(r, e, s);
40
+ const o = r.reduce((i, n) => (n.type === "checkbox" || n.type === "radio" ? n.checked && i.push(n.value) : i.push(n.value), i), []);
41
+ p(e, t, o);
69
42
  }
70
- return r;
43
+ return e;
71
44
  }, {});
72
45
  }
73
- c.getFormEntries = i;
74
- function u(n, o, r) {
75
- if (o.includes(".")) {
76
- const e = o.split(".");
77
- let t = n;
78
- e.forEach((s, f) => {
79
- if (e.length > f + 1) {
80
- const d = s.match(/^(.+)\[(\d)\]$/);
81
- if (d) {
82
- const [, h, a] = d;
83
- t[h] = t[h] || [], t[h][a] = t[h][a] || {}, t = t[h][a];
46
+ f.getFormEntries = a;
47
+ function p(c, s, e) {
48
+ if (s.includes(".")) {
49
+ const t = s.split(".");
50
+ let r = c;
51
+ t.forEach((o, i) => {
52
+ if (t.length > i + 1) {
53
+ const n = o.match(/^(.+)\[(\d)\]$/);
54
+ if (n) {
55
+ const [, u, d] = n;
56
+ r[u] = r[u] || [], r[u][d] = r[u][d] || {}, r = r[u][d];
84
57
  } else
85
- t[s] = t[s] || {}, t = t[s];
58
+ r[o] = r[o] || {}, r = r[o];
86
59
  } else
87
- t[s] = r;
60
+ r[o] = e;
88
61
  });
89
62
  } else
90
- n[o] = r;
63
+ c[s] = e;
91
64
  }
92
- })(g || (g = {}));
93
- const P = g;
94
- function v() {
95
- return x(() => {
96
- const c = "crono-box";
97
- let i = document.getElementById(c);
98
- return i || (i = document.createElement("div"), i.id = c, document.body.appendChild(i)), i;
99
- }, []);
100
- }
65
+ })(h || (h = {}));
66
+ const P = h;
101
67
  export {
102
- y as C,
103
68
  P as F,
104
- I,
105
- E as O,
106
- v as u
69
+ m as O
107
70
  };