@stamcat/craftsman 0.0.23-alpha.21 → 0.0.23-alpha.23

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,6 @@
1
1
  {
2
2
  "name": "@stamcat/craftsman",
3
- "version": "0.0.23-alpha.21",
3
+ "version": "0.0.23-alpha.23",
4
4
  "type": "module",
5
5
  "description": "A powerful, lightweight framework for design systems",
6
6
  "repository": {
@@ -1,30 +1,23 @@
1
1
  import { isEmpty as e } from "../utilities/validations.esm.js";
2
- import { ThemeContext as t, css as n } from "@emotion/react";
3
- import r from "@emotion/styled";
4
- import { Fragment as i, jsx as a } from "react/jsx-runtime";
2
+ import { css as t } from "@emotion/react";
3
+ import n from "@emotion/styled";
4
+ import { Fragment as r, jsx as i } from "react/jsx-runtime";
5
5
  //#region src/components/Button.tsx
6
- var o = r.button`
6
+ var a = n.button`
7
7
  ${(e) => e.styles}
8
- ${((e) => e.size && n`
8
+ ${((e) => e.size && t`
9
9
  border-radius: calc(var(--btn-border-radius) * ${e.size});
10
10
  padding: calc(var(--btn-pad-y) * ${e.size}) calc(var(--btn-pad-x) * ${e.size});
11
11
  font-size: max(10px, calc(var(--w-text) * ${e.size}));
12
12
  `)}
13
- `, s = (n) => {
14
- let { type: r = "button", variant: s = "default", className: c, size: l, ...u } = n, d = typeof l == "number" ? Math.min(10, Math.max(.1, l)) : void 0;
15
- return e(n.children) ? /* @__PURE__ */ a(i, {}) : /* @__PURE__ */ a(t.Consumer, { children: (e) => {
16
- let t = e, n = typeof t?.components?.button == "string" ? t.components.button : void 0, i = [
17
- s === "default" ? void 0 : s,
18
- n,
19
- c
20
- ].filter(Boolean).join(" ") || void 0;
21
- return /* @__PURE__ */ a(o, {
22
- type: r,
23
- size: d,
24
- className: i,
25
- ...u
26
- });
27
- } });
13
+ `, o = (t) => {
14
+ let { type: n = "button", variant: o = "default", className: s, size: c, ...l } = t, u = typeof c == "number" ? Math.min(10, Math.max(.1, c)) : void 0, d = [o === "default" ? void 0 : o, s].filter(Boolean).join(" ") || void 0;
15
+ return e(t.children) ? /* @__PURE__ */ i(r, {}) : /* @__PURE__ */ i(a, {
16
+ type: n,
17
+ size: u,
18
+ className: d,
19
+ ...l
20
+ });
28
21
  };
29
22
  //#endregion
30
- export { s as Button };
23
+ export { o as Button };
@@ -1,6 +1,10 @@
1
+ import { CraftsmanStyleConfig } from '../utilities/types';
2
+ import { Theme } from '../theme/types';
1
3
  type StyleProviderProps = {
2
4
  key?: string;
3
5
  children?: React.ReactNode;
6
+ config?: CraftsmanStyleConfig;
7
+ theme?: Theme;
4
8
  };
5
- export declare function NextJSProvider({ children, key }: StyleProviderProps): import("react").JSX.Element;
9
+ export declare function NextJSProvider({ children, key, config, theme }: StyleProviderProps): import("react").JSX.Element;
6
10
  export {};
@@ -1,13 +1,17 @@
1
1
  "use client";
2
- import { CacheProvider as e } from "@emotion/react";
3
- import { jsx as t } from "react/jsx-runtime";
4
- import { useState as n } from "react";
5
- import r from "@emotion/cache";
6
- import { useServerInsertedHTML as i } from "next/navigation";
2
+ import { setCraftsmanConfig as e } from "../utilities/config.esm.js";
3
+ import { CraftsmanThemeProvider as t, themeBuilder as n } from "../theme/theme.esm.js";
4
+ import { globalStyles as r } from "../global/globalStyles.esm.js";
5
+ import { CacheProvider as i, Global as a } from "@emotion/react";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
+ import { useState as c } from "react";
8
+ import l from "@emotion/cache";
9
+ import { useServerInsertedHTML as u } from "next/navigation";
7
10
  //#region src/styles/components/NextJSProvider.tsx
8
- function a({ children: a, key: o = "app" }) {
9
- let [{ cache: s, flush: c }] = n(() => {
10
- let e = r({ key: o });
11
+ function d({ children: d, key: f = "app", config: p, theme: m }) {
12
+ p && e(p);
13
+ let [{ cache: h, flush: g }] = c(() => {
14
+ let e = l({ key: f });
11
15
  e.compat = !0;
12
16
  let t = e.insert, n = [];
13
17
  return e.insert = (...r) => {
@@ -21,19 +25,22 @@ function a({ children: a, key: o = "app" }) {
21
25
  }
22
26
  };
23
27
  });
24
- return i(() => {
25
- let e = c();
28
+ return u(() => {
29
+ let e = g();
26
30
  if (e.length === 0) return null;
27
- let n = "";
28
- for (let t of e) n += s.inserted[t];
29
- return /* @__PURE__ */ t("style", {
30
- "data-emotion": `${s.key} ${e.join(" ")}`,
31
- dangerouslySetInnerHTML: { __html: n }
31
+ let t = "";
32
+ for (let n of e) t += h.inserted[n];
33
+ return /* @__PURE__ */ o("style", {
34
+ "data-emotion": `${h.key} ${e.join(" ")}`,
35
+ dangerouslySetInnerHTML: { __html: t }
32
36
  });
33
- }), /* @__PURE__ */ t(e, {
34
- value: s,
35
- children: a
37
+ }), /* @__PURE__ */ o(i, {
38
+ value: h,
39
+ children: /* @__PURE__ */ s(t, {
40
+ theme: m || {},
41
+ children: [/* @__PURE__ */ o(a, { styles: (e) => [r, n(e)] }), d]
42
+ })
36
43
  });
37
44
  }
38
45
  //#endregion
39
- export { a as NextJSProvider };
46
+ export { d as NextJSProvider };
@@ -1,9 +1,7 @@
1
1
  //#region src/utilities/validations.ts
2
- /* #__PURE__ */
3
2
  function e(e) {
4
3
  return e == null || typeof e == "object" && Object.keys(e).length === 0 || typeof e == "string" && e.trim().length === 0 || typeof e == "string" && e === " ";
5
4
  }
6
- /* #__PURE__ */
7
5
  function t(e) {
8
6
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
9
7
  }