@stamcat/craftsman 0.0.23-alpha.15 → 0.0.23-alpha.18

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.
@@ -0,0 +1,2 @@
1
+ export * from './src/components/index.js'
2
+ export {}
package/Components.esm.js CHANGED
@@ -1,5 +1,14 @@
1
- import { Button as e } from "./src/components/Button.esm.js";
2
- import { Input as t } from "./src/components/Input.esm.js";
3
- import { Loader as n } from "./src/components/Loader.esm.js";
4
- import { Modal as r } from "./src/components/Modal.esm.js";
5
- export { e as Button, t as Input, n as Loader, r as Modal };
1
+ import { __exportAll as e } from "./_virtual/_rolldown/runtime.esm.js";
2
+ import { Button as t } from "./src/components/Button.esm.js";
3
+ import { Input as n } from "./src/components/Input.esm.js";
4
+ import { Loader as r } from "./src/components/Loader.esm.js";
5
+ import { Modal as i } from "./src/components/Modal.esm.js";
6
+ //#region src/components/index.ts
7
+ var a = /* @__PURE__ */ e({
8
+ Button: () => t,
9
+ Input: () => n,
10
+ Loader: () => r,
11
+ Modal: () => i
12
+ });
13
+ //#endregion
14
+ export { t as Button, n as Input, r as Loader, i as Modal, a as components_exports };
package/Styles.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './src/styles/index.js'
2
+ export {}
package/Styles.esm.js ADDED
@@ -0,0 +1,7 @@
1
+ import { defaultColors as e, defaultWidths as t } from "./src/styles/utilities/constants.esm.js";
2
+ import { getCraftsmanConfig as n, resetCraftsmanConfig as r, setCraftsmanConfig as i } from "./src/styles/utilities/config.esm.js";
3
+ import { breakpoint as a, media as o, width as s, widths as c } from "./src/styles/utilities/layout.esm.js";
4
+ import { color as l, colors as u, hexToRgba as d } from "./src/styles/utilities/color.esm.js";
5
+ import { CraftsmanThemeProvider as f, themeBuilder as p } from "./src/styles/theme/theme.esm.js";
6
+ import { globalStyles as m } from "./src/styles/global/globalStyles.esm.js";
7
+ export { f as CraftsmanThemeProvider, a as breakpoint, l as color, u as colors, e as defaultColors, t as defaultWidths, n as getCraftsmanConfig, m as globalStyles, d as hexToRgba, o as media, r as resetCraftsmanConfig, i as setCraftsmanConfig, p as themeBuilder, s as width, c as widths };
package/Utilities.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './src/utilities/index.js'
2
+ export {}
@@ -0,0 +1,2 @@
1
+ import { isEmpty as e, validateEmail as t } from "./src/utilities/validations.esm.js";
2
+ export { e as isEmpty, t as validateEmail };
@@ -0,0 +1,11 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, t = (t, n) => {
3
+ let r = {};
4
+ for (var i in t) e(r, i, {
5
+ get: t[i],
6
+ enumerable: !0
7
+ });
8
+ return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ };
10
+ //#endregion
11
+ export { t as __exportAll };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamcat/craftsman",
3
- "version": "0.0.23-alpha.15",
3
+ "version": "0.0.23-alpha.18",
4
4
  "type": "module",
5
5
  "description": "A powerful, lightweight framework for design systems",
6
6
  "repository": {
@@ -43,6 +43,14 @@
43
43
  "types": "./src/components/index.d.ts",
44
44
  "default": "./Components.esm.js"
45
45
  },
46
+ "./styles": {
47
+ "types": "./src/styles/index.d.ts",
48
+ "default": "./Styles.esm.js"
49
+ },
50
+ "./utilities": {
51
+ "types": "./src/utilities/index.d.ts",
52
+ "default": "./Utilities.esm.js"
53
+ },
46
54
  "./Button": {
47
55
  "types": "./src/components/Button.d.ts",
48
56
  "default": "./src/components/Button.esm.js"
@@ -1,27 +1,30 @@
1
1
  import { isEmpty as e } from "../utilities/validations.esm.js";
2
- import { css as t, useTheme as n } from "@emotion/react";
2
+ import { ThemeContext as t, css as n } from "@emotion/react";
3
3
  import r from "@emotion/styled";
4
4
  import { Fragment as i, jsx as a } from "react/jsx-runtime";
5
5
  //#region src/components/Button.tsx
6
6
  var o = r.button`
7
7
  ${(e) => e.styles}
8
- ${((e) => e.size && t`
8
+ ${((e) => e.size && n`
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 = (t) => {
14
- let { type: r = "button", variant: s = "default", className: c, size: l, ...u } = t, d = typeof l == "number" ? Math.min(10, Math.max(.1, l)) : void 0, f = n(), p = typeof f?.components?.button == "string" ? f.components.button : void 0, m = [
15
- s === "default" ? void 0 : s,
16
- p,
17
- c
18
- ].filter(Boolean).join(" ") || void 0;
19
- return e(t.children) ? /* @__PURE__ */ a(i, {}) : /* @__PURE__ */ a(o, {
20
- type: r,
21
- size: d,
22
- className: m,
23
- ...u
24
- });
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
+ } });
25
28
  };
26
29
  //#endregion
27
30
  export { s as Button };
@@ -0,0 +1,58 @@
1
+ import { typography as e } from "./typography.esm.js";
2
+ import { css as t } from "@emotion/react";
3
+ import n from "zod";
4
+ n.enum([
5
+ "primary",
6
+ "default",
7
+ "text"
8
+ ]);
9
+ var r = t`
10
+ --btn-pad-y: calc(var(--w-gutter) * 0.5);
11
+ --btn-pad-x: calc(var(--w-gutter) * 0.75);
12
+ --btn-border-radius: calc(var(--w-gutter) * 0.75);
13
+ ${e.body}
14
+ border: none;
15
+ cursor: pointer;
16
+ display: inline-flex;
17
+ flex-flow: row wrap;
18
+ align-items: center;
19
+ font-weight: 500;
20
+ transition: 0.125s;
21
+ padding: var(--btn-pad-y) var(--btn-pad-x);
22
+ border-radius: var(--btn-border-radius);
23
+ border: 1px solid var(--blue600);
24
+ background-color: var(--white);
25
+ &:not(:disabled):not(.disabled):hover {
26
+ background-color: var(--blue200);
27
+ }
28
+ &.text {
29
+ padding: 0;
30
+ border: none;
31
+ background: none;
32
+ &:not(:disabled):not(.disabled):hover {
33
+ color: var(--blue800);
34
+ background-color: transparent;
35
+ text-decoration: underline;
36
+ }
37
+ }
38
+ &:disabled,
39
+ &.disabled {
40
+ cursor: not-allowed;
41
+ border-color: var(--grey200);
42
+ color: var(--grey400);
43
+ &.primary {
44
+ border-color: var(--grey200);
45
+ background-color: var(--grey400);
46
+ color: var(--grey200);
47
+ }
48
+ }
49
+ &.primary {
50
+ color: var(--white);
51
+ background-color: var(--blue500);
52
+ &:not(:disabled):not(.disabled):hover {
53
+ background-color: var(--blue700);
54
+ }
55
+ }
56
+ `;
57
+ //#endregion
58
+ export { r as button };
@@ -0,0 +1,21 @@
1
+ import { css as e } from "@emotion/react";
2
+ //#region src/styles/global/components/code.ts
3
+ var t = e`
4
+ background-color: var(--grey200);
5
+ color: var(--grey800);
6
+ padding: calc(var(--w-gutter) * 0.125) calc(var(--w-gutter) * 0.25);
7
+ margin: calc(var(--w-gutter) * 0.125);
8
+ display: inline-block;
9
+ &:has(pre) {
10
+ padding: var(--w-gutter);
11
+ border-radius: calc(var(--w-gutter) * 0.5);
12
+ background-color: var(--grey800);
13
+ color: var(--grey200);
14
+ }
15
+
16
+ &:has(pre) pre {
17
+ margin: 0;
18
+ }
19
+ `;
20
+ //#endregion
21
+ export { t as code };
@@ -0,0 +1,54 @@
1
+ import { breakpoint as e } from "../../utilities/layout.esm.js";
2
+ import { css as t } from "@emotion/react";
3
+ //#region src/styles/global/components/typography.ts
4
+ var n = {
5
+ body: t`
6
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
7
+ color: var(--text);
8
+ line-height: 1.5;
9
+ font-weight: 400;
10
+ font-size: var(--w-text);
11
+ `,
12
+ h1: t`
13
+ font-size: calc(var(--w-text) * 3.125);
14
+ line-height: 1.2;
15
+ `,
16
+ h2: t`
17
+ font-size: calc(var(--w-text) * 2.625);
18
+ font-weight: 625;
19
+ line-height: 1.1;
20
+ `,
21
+ h3: t`
22
+ font-size: calc(var(--w-text) * 1.625);
23
+ line-height: 1.1;
24
+ `,
25
+ h4: t`
26
+ font-size: calc(var(--w-text) * 1.25);
27
+ line-height: 1.1;
28
+ margin: calc(var(--w-gutter) * 0.5) 0px;
29
+ ${e("mobileOnly", t`
30
+ font-size: var(--w-text);
31
+ `)}
32
+ `,
33
+ h5: t`
34
+ font-size: var(--w-text);
35
+ line-height: 1.2;
36
+ `,
37
+ h6: t`
38
+ font-size: calc(var(--w-text) * 0.875);
39
+ line-height: 1.2;
40
+ font-weight: 600;
41
+ `,
42
+ p: t`
43
+ font-style: normal;
44
+ font-size: var(--w-text);
45
+ line-height: 1.5;
46
+ margin: 0;
47
+ ${e("mobileOnly", t`
48
+ line-height: 1.5;
49
+ font-size: calc(var(--w-text) * 0.875);
50
+ `)}
51
+ `
52
+ }, r = Object.entries(n).map(([e, n]) => t({ [e]: n }));
53
+ //#endregion
54
+ export { n as typography, r as typographyStyles };
@@ -0,0 +1,64 @@
1
+ import { colors as e, widths as t } from "./variables.esm.js";
2
+ import { typographyStyles as n } from "./components/typography.esm.js";
3
+ import { button as r } from "./components/button.esm.js";
4
+ import { code as i } from "./components/code.esm.js";
5
+ import { css as a } from "@emotion/react";
6
+ //#region src/styles/global/globalStyles.ts
7
+ var o = a`
8
+ :root {
9
+ ${t}
10
+ ${e}
11
+ color-scheme: light dark;
12
+ font-synthesis: none;
13
+ text-rendering: optimizeLegibility;
14
+ -webkit-font-smoothing: antialiased;
15
+ -moz-osx-font-smoothing: grayscale;
16
+ }
17
+ /* Scrollbar container */
18
+ ::-webkit-scrollbar {
19
+ width: 4px; /* vertical scrollbar width */
20
+ height: 4px; /* horizontal scrollbar height */
21
+ }
22
+
23
+ /* Scrollbar track */
24
+ ::-webkit-scrollbar-track {
25
+ background: #ddd;
26
+ }
27
+
28
+ /* Scrollbar thumb */
29
+ ::-webkit-scrollbar-thumb {
30
+ background: #000;
31
+ border-radius: 6px;
32
+ }
33
+
34
+ /* On hover */
35
+ ::-webkit-scrollbar-thumb:hover {
36
+ background: #555;
37
+ }
38
+ body {
39
+ background-color: #fff;
40
+ /* Enable smooth scrolling on mobile */
41
+ -webkit-overflow-scrolling: touch;
42
+ /* Prevent scroll chaining issues in iframes */
43
+ overscroll-behavior: contain;
44
+ margin: 0;
45
+ padding: 0;
46
+ }
47
+ fieldset {
48
+ padding: 0px;
49
+ border: 0px;
50
+ }
51
+ code {
52
+ ${i}
53
+ }
54
+ button {
55
+ ${r}
56
+ }
57
+ ul {
58
+ margin: 0;
59
+ padding: 0;
60
+ }
61
+ ${n}
62
+ `;
63
+ //#endregion
64
+ export { o as globalStyles };
@@ -0,0 +1,6 @@
1
+ import { widths as e } from "../utilities/layout.esm.js";
2
+ import { colors as t } from "../utilities/color.esm.js";
3
+ //#region src/styles/global/variables.ts
4
+ var n = Object.entries(t).map(([e, t]) => `--${e}: ${t};`).join("\n"), r = Object.entries(e).map(([e, t]) => `--w-${e}: ${t}px;`).join("\n");
5
+ //#endregion
6
+ export { n as colors, r as widths };
@@ -0,0 +1,7 @@
1
+ export * from './utilities/color';
2
+ export * from './utilities/config';
3
+ export * from './utilities/constants';
4
+ export * from './utilities/layout';
5
+ export * from './utilities/types';
6
+ export * from './theme/theme';
7
+ export * from './global/globalStyles';
@@ -0,0 +1,12 @@
1
+ import { components_exports as e } from "../../../Components.esm.js";
2
+ import { htmlTagNames as t } from "./constants.esm.js";
3
+ //#region src/styles/theme/components.ts
4
+ function n(e) {
5
+ return e.charAt(0).toLowerCase() + e.slice(1);
6
+ }
7
+ function r(e) {
8
+ return t.has(e) ? e : `.${e}`;
9
+ }
10
+ var i = Object.keys(e).map(n), a = Object.fromEntries(i.map((e) => [e, r(e)]));
11
+ //#endregion
12
+ export { a as componentSelectors };
@@ -0,0 +1,4 @@
1
+ //#region src/styles/theme/constants.ts
2
+ var e = /* @__PURE__ */ new Set(/* @__PURE__ */ "a.abbr.address.area.article.aside.audio.b.base.bdi.bdo.blockquote.body.br.button.canvas.caption.cite.code.col.colgroup.data.datalist.dd.del.details.dfn.dialog.div.dl.dt.em.embed.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.iframe.img.input.ins.kbd.label.legend.li.link.main.map.mark.menu.meta.meter.nav.noscript.object.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.script.section.select.slot.small.source.span.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.title.tr.track.u.ul.var.video.wbr".split("."));
3
+ //#endregion
4
+ export { e as htmlTagNames };
@@ -0,0 +1,29 @@
1
+ import { isEmpty as e } from "../../utilities/validations.esm.js";
2
+ import { componentSelectors as t } from "./components.esm.js";
3
+ import { toCSSObject as n } from "./utilities.esm.js";
4
+ import { colors as r } from "../global/variables.esm.js";
5
+ import { ThemeProvider as i, css as a } from "@emotion/react";
6
+ import { createElement as o } from "react";
7
+ //#region src/styles/theme/theme.ts
8
+ function s(e) {
9
+ let r = [];
10
+ return Object.keys(t).forEach((i) => {
11
+ let o = e?.[i];
12
+ !o || typeof o == "string" || r.push(a({ [t[i]]: { ...o ? n(o) : {} } }));
13
+ }), r;
14
+ }
15
+ function c({ theme: t, children: n }) {
16
+ return o(i, { theme: e(t) ? {} : t }, n);
17
+ }
18
+ function l(e) {
19
+ return a([
20
+ r,
21
+ a({ ":root": {
22
+ ...e.colors,
23
+ ...e.root
24
+ } }),
25
+ ...s(e.components)
26
+ ]);
27
+ }
28
+ //#endregion
29
+ export { c as CraftsmanThemeProvider, l as themeBuilder };
@@ -0,0 +1,25 @@
1
+ //#region src/styles/theme/utilities.ts
2
+ function e(e) {
3
+ return "styles" in e && "name" in e;
4
+ }
5
+ function t(e) {
6
+ let t = {}, n = e;
7
+ for (; n;) {
8
+ let e = n.styles.split(";").map((e) => e.trim()).filter((e) => e && !e.startsWith("label:"));
9
+ for (let n of e) {
10
+ let e = n.indexOf(":");
11
+ if (e === -1) continue;
12
+ let r = n.slice(0, e).trim(), i = n.slice(e + 1).trim();
13
+ if (!r || !i) continue;
14
+ let a = r.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
15
+ t[a] = i;
16
+ }
17
+ n = n.next;
18
+ }
19
+ return t;
20
+ }
21
+ function n(n) {
22
+ return e(n) ? t(n) : n;
23
+ }
24
+ //#endregion
25
+ export { n as toCSSObject };
@@ -15,11 +15,27 @@ function i(e) {
15
15
  desktopMax: e.extDesktop - 1e-5
16
16
  };
17
17
  }
18
- function a() {
18
+ function a(e) {
19
+ let t = Object.entries(e.colors ?? {}).reduce((e, [t, n]) => (typeof n == "string" && (e[t] = n), e), {}), n = e.widths ? { ...e.widths } : {};
20
+ r = {
21
+ colors: {
22
+ ...r.colors,
23
+ ...t
24
+ },
25
+ widths: {
26
+ ...r.widths,
27
+ ...n
28
+ }
29
+ };
30
+ }
31
+ function o() {
32
+ r = { ...n };
33
+ }
34
+ function s() {
19
35
  return {
20
36
  colors: { ...r.colors },
21
37
  widths: i(r.widths)
22
38
  };
23
39
  }
24
40
  //#endregion
25
- export { a as getCraftsmanConfig };
41
+ export { s as getCraftsmanConfig, o as resetCraftsmanConfig, a as setCraftsmanConfig };
@@ -41,8 +41,15 @@ var n = [
41
41
  get desktopOnly() {
42
42
  return `(min-width: ${r.desktop}px) and (max-width: ${r.desktopMax}px)`;
43
43
  }
44
- }, a = (e, n) => t`@media ${i[e]} {
44
+ }, a = (e, t = 1, n = !0) => {
45
+ let i = 0;
46
+ if (e === "column") {
47
+ let e = t - 1;
48
+ i = r.gutter * e;
49
+ }
50
+ return `${r[e] * t + i}${n ? "px" : ""}`;
51
+ }, o = (e, n) => t`@media ${i[e]} {
45
52
  ${n}
46
53
  }`;
47
54
  //#endregion
48
- export { a as breakpoint, i as media, r as widths };
55
+ export { o as breakpoint, i as media, a as width, r as widths };
@@ -0,0 +1 @@
1
+ export * from './validations';
@@ -3,5 +3,9 @@
3
3
  function e(e) {
4
4
  return e == null || typeof e == "object" && Object.keys(e).length === 0 || typeof e == "string" && e.trim().length === 0 || typeof e == "string" && e === " ";
5
5
  }
6
+ /* #__PURE__ */
7
+ function t(e) {
8
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
9
+ }
6
10
  //#endregion
7
- export { e as isEmpty };
11
+ export { e as isEmpty, t as validateEmail };