@wrdagency/blockout 0.1.5 → 0.1.6

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.
@@ -1,15 +1,22 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { cn as o } from "../../utils/css.js";
3
- import '../../assets/button.css';const c = (t) => {
4
- const n = o(
5
- t.className,
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { cn as p } from "../../utils/css.js";
3
+ import '../../assets/button.css';const l = (e) => {
4
+ const {
5
+ className: s,
6
+ wide: m,
7
+ size: r,
8
+ variant: a,
9
+ as: c,
10
+ ...t
11
+ } = e, n = p(
12
+ s,
6
13
  "component-button",
7
- `component-button--${t.variant || "primary"}`,
8
- `component-button--${t.size || "medium"}`,
9
- t.wide && "component-button--wide"
14
+ `component-button--${a || "primary"}`,
15
+ `component-button--${r || "medium"}`,
16
+ m && "component-button--wide"
10
17
  );
11
- return t.as === "link" ? /* @__PURE__ */ e("a", { ...t, className: n }) : /* @__PURE__ */ e("button", { type: "button", ...t, className: n });
18
+ return c === "link" ? /* @__PURE__ */ o("a", { ...t, className: n }) : /* @__PURE__ */ o("button", { type: "button", ...t, className: n });
12
19
  };
13
20
  export {
14
- c as Button
21
+ l as Button
15
22
  };
@@ -410,7 +410,6 @@ const j = /* @__PURE__ */ x(Z), de = (s) => {
410
410
  onChange: d = S,
411
411
  ...c
412
412
  } = p, t = L(() => j(a), [a]);
413
- console.log(t);
414
413
  function l(u) {
415
414
  if (t.length !== 1)
416
415
  return /* @__PURE__ */ v(A, { ...u });
@@ -1,9 +1,9 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
- import { DateComponent, DateString } from './types';
2
+ import { DateComponent, DateFormat, DateString } from './types';
3
3
  interface DateComponentInputProps extends InputHTMLAttributes<HTMLInputElement> {
4
4
  component: DateComponent;
5
- separator: string;
6
- components: DateComponent[];
5
+ dataFormat: DateFormat;
6
+ viewFormat: DateFormat;
7
7
  value: DateString;
8
8
  onChangeValue: (value: string) => void;
9
9
  }
@@ -1,42 +1,42 @@
1
1
  import { jsx as x } from "react/jsx-runtime";
2
- import { forwardRef as C } from "react";
3
- import { parseDateString as D, formatDateString as v } from "./types.js";
4
- const w = C((m, p) => {
2
+ import { forwardRef as V } from "react";
3
+ import { parseDateString as f, getComponentMaxValue as v, getComponentMinValue as D, getComponentMaxLength as M, getComponentPlaceholder as w, formatDateString as F } from "./types.js";
4
+ const j = V((r, m) => {
5
5
  const {
6
6
  component: e,
7
- separator: t,
8
- components: n,
9
- value: s,
10
- onChangeValue: u,
11
- autoComplete: c,
12
- ...l
13
- } = m, o = D(s, n, t), i = o[e], d = e === "day" ? "DD" : e === "month" ? "MM" : "YY", a = e === "day" || e === "month" ? 1 : 0, r = e === "day" ? 31 : e === "month" ? 12 : 99, h = (g) => {
14
- const f = {
15
- ...o,
16
- [e]: g.currentTarget.value
7
+ dataFormat: t,
8
+ viewFormat: L,
9
+ value: p,
10
+ onChangeValue: l,
11
+ autoComplete: u,
12
+ ...c
13
+ } = r, n = f(p, t), s = n[e], i = w(e), o = D(e), a = v(e), g = M(e), C = (d) => {
14
+ const h = {
15
+ ...n,
16
+ [e]: d.currentTarget.value
17
17
  };
18
- u(v(f, n, t));
18
+ l(F(h, t));
19
19
  };
20
20
  return /* @__PURE__ */ x(
21
21
  "input",
22
22
  {
23
- ref: p,
24
- value: i,
23
+ ref: m,
24
+ value: s,
25
25
  className: "component-date-control__input",
26
26
  inputMode: "numeric",
27
- autoComplete: c + "-" + e,
28
- placeholder: d,
29
- maxLength: 2,
27
+ autoComplete: u + "-" + e,
28
+ placeholder: i,
30
29
  step: 1,
31
- "aria-valuemin": a,
32
- min: a,
33
- max: r,
34
- "aria-valuemax": r,
35
- onChange: h,
36
- ...l
30
+ maxLength: g,
31
+ "aria-valuemin": o,
32
+ min: o,
33
+ max: a,
34
+ "aria-valuemax": a,
35
+ onChange: C,
36
+ ...c
37
37
  }
38
38
  );
39
39
  });
40
40
  export {
41
- w as DateComponentInput
41
+ j as DateComponentInput
42
42
  };
@@ -1,12 +1,14 @@
1
1
  import { HTMLInputAutoCompleteAttribute } from 'react';
2
2
  import { ControlFC } from '../base-control/props';
3
- import { DateComponent, DateString } from './types';
3
+ import { DateFormat, DateString } from './types';
4
4
  interface DateControlProps {
5
5
  value?: DateString;
6
6
  onChangeValue?: (value: DateString) => void;
7
7
  autoComplete?: HTMLInputAutoCompleteAttribute;
8
- components?: DateComponent[];
8
+ dataFormat?: DateFormat;
9
+ viewFormat?: DateFormat;
9
10
  separator?: string;
11
+ fullYear?: boolean;
10
12
  }
11
13
  export declare const DateControl: ControlFC<DateControlProps>;
12
14
  export {};
@@ -1,36 +1,38 @@
1
- import { jsx as o, jsxs as d, Fragment as f } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as d, Fragment as C } from "react/jsx-runtime";
2
+ import { createElement as g } from "react";
2
3
  import { useSplitInput as h } from "../../../hooks/input.js";
3
- import "react";
4
- import { noop as C } from "../../../utils/noop.js";
5
- import { BaseControl as g } from "../base-control/index.js";
6
- import { useBaseControlProps as x } from "../base-control/props.js";
4
+ import { noop as F } from "../../../utils/noop.js";
5
+ import { BaseControl as x } from "../base-control/index.js";
6
+ import { useBaseControlProps as D } from "../base-control/props.js";
7
7
  import { DateComponentInput as P } from "./component.js";
8
- import '../../../assets/index6.css';const b = (n) => {
9
- const { baseProps: a, controlProps: p } = x(n, {
8
+ import { getDefaultFormat as a } from "./types.js";
9
+ import '../../../assets/index6.css';const w = (n) => {
10
+ const { baseProps: m, controlProps: p } = D(n, {
10
11
  className: "component-date-control"
11
12
  }), { register: s } = h(), {
12
- value: m = "",
13
- onChangeValue: l = C,
14
- autoComplete: c,
15
- separator: t = "-",
16
- components: r = ["day", "month", "year"]
13
+ value: l = "",
14
+ onChangeValue: c = F,
15
+ autoComplete: i,
16
+ dataFormat: f = a(),
17
+ viewFormat: o = a()
17
18
  } = p;
18
- return /* @__PURE__ */ o(g, { ...a, children: r.map((i, e, u) => /* @__PURE__ */ d(f, { children: [
19
- /* @__PURE__ */ o(
19
+ return /* @__PURE__ */ e(x, { ...m, children: o.components.map((t, r, u) => /* @__PURE__ */ d(C, { children: [
20
+ /* @__PURE__ */ g(
20
21
  P,
21
22
  {
22
- ...s(e),
23
- component: i,
24
- separator: t,
25
- components: r,
26
- value: m,
27
- onChangeValue: l,
28
- autoComplete: c
23
+ ...s(r),
24
+ key: t,
25
+ component: t,
26
+ dataFormat: f,
27
+ viewFormat: o,
28
+ value: l,
29
+ onChangeValue: c,
30
+ autoComplete: i
29
31
  }
30
32
  ),
31
- u.length - 1 !== e && /* @__PURE__ */ o("span", { className: "component-date-control__separator", children: t })
33
+ u.length - 1 !== r && /* @__PURE__ */ e("span", { className: "component-date-control__separator", children: o.separator })
32
34
  ] })) });
33
35
  };
34
36
  export {
35
- b as DateControl
37
+ w as DateControl
36
38
  };
@@ -1,5 +1,14 @@
1
- export type DateComponent = "day" | "month" | "year";
1
+ export type DateComponent = "day" | "month" | "year" | "fullYear";
2
2
  export type DateString = string;
3
+ export type DateFormat = {
4
+ components: DateComponent[];
5
+ separator: string;
6
+ };
3
7
  export type ParsedDate = Partial<Record<DateComponent, string>>;
4
- export declare function parseDateString(value: DateString | undefined, components: DateComponent[], separator: string): ParsedDate;
5
- export declare function formatDateString(value: ParsedDate, components: DateComponent[], separator: string): DateString;
8
+ export declare function getDefaultFormat(): DateFormat;
9
+ export declare function parseDateString(value: DateString | undefined, format: DateFormat): ParsedDate;
10
+ export declare function formatDateString(value: ParsedDate, format: DateFormat): DateString;
11
+ export declare function getComponentMaxLength(component: DateComponent): 4 | 2;
12
+ export declare function getComponentMinValue(component: DateComponent): 1 | 0 | 1900;
13
+ export declare function getComponentMaxValue(component: DateComponent): 12 | 31 | 99 | 3000;
14
+ export declare function getComponentPlaceholder(component: DateComponent): "DD" | "MM" | "YY" | "YYYY";
@@ -1,20 +1,61 @@
1
- function o(t, n, r) {
2
- const e = (t || "").split(r);
3
- return n.reduce(
4
- (a, i, c) => ({
5
- ...a,
6
- [i]: e[c]
1
+ function i() {
2
+ return {
3
+ components: ["fullYear", "month", "day"],
4
+ separator: "-"
5
+ };
6
+ }
7
+ function l(e, r) {
8
+ const { separator: n, components: a } = r, u = (e || "").split(n);
9
+ return a.reduce(
10
+ (t, o, c) => ({
11
+ ...t,
12
+ [o]: u[c]
7
13
  }),
8
14
  {}
9
15
  );
10
16
  }
11
- function p(t, n, r) {
12
- const e = /\D/g;
13
- return n.map(function(a) {
14
- return (t[a] || "").replace(e, "").substring(0, 2);
15
- }).join(r);
17
+ function f(e, r) {
18
+ const { separator: n, components: a } = r, u = /\D/g;
19
+ return a.map(function(t) {
20
+ return (e[t] || "").replace(u, "").substring(0, s(t));
21
+ }).join(n);
22
+ }
23
+ function s(e) {
24
+ return e === "fullYear" ? 4 : 2;
25
+ }
26
+ function p(e) {
27
+ return e === "year" ? 0 : e === "fullYear" ? 1900 : 1;
28
+ }
29
+ function g(e) {
30
+ switch (e) {
31
+ case "day":
32
+ return 31;
33
+ case "month":
34
+ return 12;
35
+ case "year":
36
+ return 99;
37
+ case "fullYear":
38
+ return 3e3;
39
+ }
40
+ }
41
+ function m(e) {
42
+ switch (e) {
43
+ case "day":
44
+ return "DD";
45
+ case "month":
46
+ return "MM";
47
+ case "year":
48
+ return "YY";
49
+ case "fullYear":
50
+ return "YYYY";
51
+ }
16
52
  }
17
53
  export {
18
- p as formatDateString,
19
- o as parseDateString
54
+ f as formatDateString,
55
+ s as getComponentMaxLength,
56
+ g as getComponentMaxValue,
57
+ p as getComponentMinValue,
58
+ m as getComponentPlaceholder,
59
+ i as getDefaultFormat,
60
+ l as parseDateString
20
61
  };
@@ -6,44 +6,51 @@ import '../../../assets/style4.css';import '../../../assets/style3.css';import '
6
6
  /* empty css */
7
7
  import { VisuallyHidden as N } from "../../../primitives/visually-hidden/index.js";
8
8
  import { normalizeOption as k } from "../../../types/options.js";
9
- import { BaseControl as x } from "../base-control/index.js";
10
- import { useBaseControlProps as P } from "../base-control/props.js";
11
- function M(p) {
12
- const { baseProps: a, controlProps: m } = P(p, {
9
+ import { BaseControl as v } from "../base-control/index.js";
10
+ import { useBaseControlProps as x } from "../base-control/props.js";
11
+ function M(a) {
12
+ const { baseProps: p, controlProps: m } = x(a, {
13
13
  className: "component-toggle-group-control"
14
14
  }), {
15
- id: g,
15
+ id: u,
16
16
  value: n,
17
- options: l,
17
+ options: t,
18
18
  multiple: r = !1,
19
- onChange: u = s,
20
- onChangeValue: t = s,
19
+ onChange: g = s,
20
+ onChangeValue: l = s,
21
21
  ...d
22
22
  } = m, _ = (o) => {
23
- u(o);
23
+ g(o);
24
24
  const i = o.currentTarget.value;
25
- r ? o.currentTarget.checked ? t([...n, i]) : t(n.filter((C) => C !== i)) : t(o.target.value);
26
- }, h = (o) => r ? n.includes(o) : n === o, f = b(() => l.map(k), [l]);
27
- return /* @__PURE__ */ e(x, { ...a, children: /* @__PURE__ */ e("div", { className: "component-toggle-group-control__options", children: f.map((o) => /* @__PURE__ */ c("label", { className: "component-toggle-group-control__option", children: [
28
- /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(
29
- "input",
30
- {
31
- className: "component-toggle-group-control__option__input",
32
- type: r ? "checkbox" : "radio",
33
- value: o.value,
34
- name: g,
35
- disabled: o.disabled,
36
- checked: h(o.value),
37
- onChange: _,
38
- ...d
39
- }
40
- ) }),
41
- /* @__PURE__ */ c("span", { className: "component-toggle-group-control__option__label", children: [
42
- o.icon,
43
- o.label
44
- ] }),
45
- o.description && /* @__PURE__ */ e("p", { className: "component-toggle-group-control__option__description", children: o.description })
46
- ] })) }) });
25
+ r ? o.currentTarget.checked ? l([...n, i]) : l(n.filter((C) => C !== i)) : l(o.target.value);
26
+ }, h = (o) => r ? n.includes(o) : n === o, f = b(() => t.map(k), [t]);
27
+ return /* @__PURE__ */ e(v, { ...p, children: /* @__PURE__ */ e("div", { className: "component-toggle-group-control__options", children: f.map((o) => /* @__PURE__ */ c(
28
+ "label",
29
+ {
30
+ className: "component-toggle-group-control__option",
31
+ children: [
32
+ /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(
33
+ "input",
34
+ {
35
+ className: "component-toggle-group-control__option__input",
36
+ type: r ? "checkbox" : "radio",
37
+ value: o.value,
38
+ name: u,
39
+ disabled: o.disabled,
40
+ checked: h(o.value),
41
+ onChange: _,
42
+ ...d
43
+ }
44
+ ) }),
45
+ /* @__PURE__ */ c("span", { className: "component-toggle-group-control__option__label", children: [
46
+ o.icon,
47
+ o.label
48
+ ] }),
49
+ o.description && /* @__PURE__ */ e("p", { className: "component-toggle-group-control__option__description", children: o.description })
50
+ ]
51
+ },
52
+ o.value
53
+ )) }) });
47
54
  }
48
55
  export {
49
56
  M as ToggleGroupControl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrdagency/blockout",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "A React component library created by WRD.agency",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",