@konstructio/ui 0.1.2-alpha.97 → 0.1.2-alpha.99

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,208 @@
1
+ import { o as F } from "./chunk-cI0lbGMq.js";
2
+ import { t as q } from "./prop-types-CE0Kfmwk.js";
3
+ import { t as _ } from "./dist-EV-1XXQr.js";
4
+ import { t as m } from "./utils-COaoD3PI.js";
5
+ import { Typography as C } from "./components/Typography/Typography.js";
6
+ import { buttonVariants as z, counterVariants as A, labelVariants as G } from "./components/Counter/Counter.variants.js";
7
+ import v, { forwardRef as x, useCallback as b, useId as H, useState as J } from "react";
8
+ import { jsx as c, jsxs as y } from "react/jsx-runtime";
9
+ var u = /* @__PURE__ */ F(q());
10
+ function w() {
11
+ return w = Object.assign || function(t) {
12
+ for (var i = 1; i < arguments.length; i++) {
13
+ var n = arguments[i];
14
+ for (var e in n) Object.prototype.hasOwnProperty.call(n, e) && (t[e] = n[e]);
15
+ }
16
+ return t;
17
+ }, w.apply(this, arguments);
18
+ }
19
+ function K(t, i) {
20
+ if (t == null) return {};
21
+ var n = Q(t, i), e, r;
22
+ if (Object.getOwnPropertySymbols) {
23
+ var o = Object.getOwnPropertySymbols(t);
24
+ for (r = 0; r < o.length; r++)
25
+ e = o[r], !(i.indexOf(e) >= 0) && Object.prototype.propertyIsEnumerable.call(t, e) && (n[e] = t[e]);
26
+ }
27
+ return n;
28
+ }
29
+ function Q(t, i) {
30
+ if (t == null) return {};
31
+ var n = {}, e = Object.keys(t), r, o;
32
+ for (o = 0; o < e.length; o++)
33
+ r = e[o], !(i.indexOf(r) >= 0) && (n[r] = t[r]);
34
+ return n;
35
+ }
36
+ var N = x(function(t, i) {
37
+ var n = t.color, e = n === void 0 ? "currentColor" : n, r = t.size, o = r === void 0 ? 24 : r, d = K(t, ["color", "size"]);
38
+ return /* @__PURE__ */ v.createElement("svg", w({
39
+ ref: i,
40
+ xmlns: "http://www.w3.org/2000/svg",
41
+ width: o,
42
+ height: o,
43
+ viewBox: "0 0 24 24",
44
+ fill: "none",
45
+ stroke: e,
46
+ strokeWidth: "2",
47
+ strokeLinecap: "round",
48
+ strokeLinejoin: "round"
49
+ }, d), /* @__PURE__ */ v.createElement("line", {
50
+ x1: "5",
51
+ y1: "12",
52
+ x2: "19",
53
+ y2: "12"
54
+ }));
55
+ });
56
+ N.propTypes = {
57
+ color: u.default.string,
58
+ size: u.default.oneOfType([u.default.string, u.default.number])
59
+ };
60
+ N.displayName = "Minus";
61
+ function j() {
62
+ return j = Object.assign || function(t) {
63
+ for (var i = 1; i < arguments.length; i++) {
64
+ var n = arguments[i];
65
+ for (var e in n) Object.prototype.hasOwnProperty.call(n, e) && (t[e] = n[e]);
66
+ }
67
+ return t;
68
+ }, j.apply(this, arguments);
69
+ }
70
+ function U(t, i) {
71
+ if (t == null) return {};
72
+ var n = X(t, i), e, r;
73
+ if (Object.getOwnPropertySymbols) {
74
+ var o = Object.getOwnPropertySymbols(t);
75
+ for (r = 0; r < o.length; r++)
76
+ e = o[r], !(i.indexOf(e) >= 0) && Object.prototype.propertyIsEnumerable.call(t, e) && (n[e] = t[e]);
77
+ }
78
+ return n;
79
+ }
80
+ function X(t, i) {
81
+ if (t == null) return {};
82
+ var n = {}, e = Object.keys(t), r, o;
83
+ for (o = 0; o < e.length; o++)
84
+ r = e[o], !(i.indexOf(r) >= 0) && (n[r] = t[r]);
85
+ return n;
86
+ }
87
+ var k = x(function(t, i) {
88
+ var n = t.color, e = n === void 0 ? "currentColor" : n, r = t.size, o = r === void 0 ? 24 : r, d = U(t, ["color", "size"]);
89
+ return /* @__PURE__ */ v.createElement("svg", j({
90
+ ref: i,
91
+ xmlns: "http://www.w3.org/2000/svg",
92
+ width: o,
93
+ height: o,
94
+ viewBox: "0 0 24 24",
95
+ fill: "none",
96
+ stroke: e,
97
+ strokeWidth: "2",
98
+ strokeLinecap: "round",
99
+ strokeLinejoin: "round"
100
+ }, d), /* @__PURE__ */ v.createElement("line", {
101
+ x1: "12",
102
+ y1: "5",
103
+ x2: "12",
104
+ y2: "19"
105
+ }), /* @__PURE__ */ v.createElement("line", {
106
+ x1: "5",
107
+ y1: "12",
108
+ x2: "19",
109
+ y2: "12"
110
+ }));
111
+ });
112
+ k.propTypes = {
113
+ color: u.default.string,
114
+ size: u.default.oneOfType([u.default.string, u.default.number])
115
+ };
116
+ k.displayName = "Plus";
117
+ var at = x(({ canDecrement: t = !0, canIncrement: i = !0, className: n, decrementButtonClassName: e, editable: r = !1, incrementButtonClassName: o, isRequired: d, label: h, labelWrapperClassName: E, max: f = -1 / 0, min: p = 1 / 0, name: I, theme: L, value: M, onChange: s }, $) => {
118
+ const W = H(), l = M ?? 0, [S, g] = J(null), T = S ?? String(l), V = b(() => {
119
+ let a = 0;
120
+ p === 1 / 0 ? a = l - 1 : a = Math.max(p, l - 1), g(null), s?.({ target: { value: a } });
121
+ }, [
122
+ l,
123
+ p,
124
+ s
125
+ ]), B = b(() => {
126
+ let a = 0;
127
+ f === -1 / 0 ? a = l + 1 : a = Math.min(f, l + 1), g(null), s?.({ target: { value: a } });
128
+ }, [
129
+ l,
130
+ f,
131
+ s
132
+ ]), D = b((a) => {
133
+ const O = a.target.value;
134
+ if (g(O), O === "") return;
135
+ const P = Number(O);
136
+ Number.isFinite(P) && s?.({ target: { value: P } });
137
+ }, [s]), R = b(() => {
138
+ g(null);
139
+ const a = Math.min(f === -1 / 0 ? 1 / 0 : f, Math.max(p === 1 / 0 ? -1 / 0 : p, l));
140
+ a !== l && s?.({ target: { value: a } });
141
+ }, [
142
+ l,
143
+ p,
144
+ f,
145
+ s
146
+ ]);
147
+ return /* @__PURE__ */ y("div", {
148
+ className: "flex flex-col gap-2",
149
+ "data-theme": L,
150
+ children: [h ? /* @__PURE__ */ c("div", {
151
+ className: m(E),
152
+ children: /* @__PURE__ */ y(C, {
153
+ component: "label",
154
+ htmlFor: I ?? W,
155
+ variant: "labelLarge",
156
+ className: m(G()),
157
+ children: [
158
+ h,
159
+ " ",
160
+ d && /* @__PURE__ */ c("span", {
161
+ className: "text-red-600 dark:text-red-500",
162
+ children: "*"
163
+ })
164
+ ]
165
+ })
166
+ }) : null, /* @__PURE__ */ y("div", {
167
+ className: "flex items-center",
168
+ role: "presentation",
169
+ children: [
170
+ /* @__PURE__ */ y("button", {
171
+ type: "button",
172
+ onClick: V,
173
+ className: m(z({
174
+ button: "rigth",
175
+ className: e
176
+ })),
177
+ disabled: !t,
178
+ children: [/* @__PURE__ */ c(N, { className: "w-4 h-4" }), /* @__PURE__ */ c(_, { children: "Decrement" })]
179
+ }),
180
+ /* @__PURE__ */ c("input", {
181
+ ref: $,
182
+ type: "number",
183
+ value: r ? T : l,
184
+ name: I,
185
+ className: m(A({ className: n })),
186
+ ...r ? {
187
+ onChange: D,
188
+ onBlur: R
189
+ } : { readOnly: !0 },
190
+ "aria-label": typeof h == "string" ? h : "number input"
191
+ }),
192
+ /* @__PURE__ */ y("button", {
193
+ type: "button",
194
+ onClick: B,
195
+ className: m(z({
196
+ button: "left",
197
+ className: o
198
+ })),
199
+ disabled: !i,
200
+ children: [/* @__PURE__ */ c(k, { className: "w-4 h-4" }), /* @__PURE__ */ c(_, { children: "Increment" })]
201
+ })
202
+ ]
203
+ })]
204
+ });
205
+ });
206
+ export {
207
+ at as t
208
+ };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { t as e } from "../../Counter-C1o8YZoR.js";
2
+ import { t as e } from "../../Counter-bTFm7xa3.js";
3
3
  export {
4
4
  e as Counter
5
5
  };
@@ -1,13 +1,13 @@
1
1
  import { t as r } from "../../../../utils-COaoD3PI.js";
2
2
  import { n as A } from "../../../../table.provider-BPlFpIAe.js";
3
3
  import { useTableContext as B } from "../../contexts/table.hook.js";
4
- import { Skeleton as F } from "../Skeleton/Skeleton.js";
5
- import { ExpandableRow as H } from "../ExpandableRow/ExpandableRow.js";
4
+ import { Skeleton as H } from "../Skeleton/Skeleton.js";
5
+ import { ExpandableRow as L } from "../ExpandableRow/ExpandableRow.js";
6
6
  import { Fragment as M } from "react";
7
7
  import { jsx as e, jsxs as O } from "react/jsx-runtime";
8
8
  var W = ({ isLoading: h, showPagination: l, emptyState: p }) => {
9
- const { table: m, pageSize: k, tableLoading: N, enableExpandedRow: w, classNameExpandedRow: R, classNameExpandedCell: E, classNameExpandedContent: v, enableHoverRow: g, classNameHoverRow: C, classNameActiveExpandedRow: y, renderExpandedRow: u, isBorderOnAdjacentCell: D, isExpandColumnVisible: j } = B();
10
- if (h || N) return /* @__PURE__ */ e(F, {
9
+ const { table: m, pageSize: k, tableFetching: N, enableExpandedRow: w, classNameExpandedRow: R, classNameExpandedCell: E, classNameExpandedContent: v, enableHoverRow: g, classNameHoverRow: C, classNameActiveExpandedRow: y, renderExpandedRow: u, isBorderOnAdjacentCell: D, isExpandColumnVisible: j } = B();
10
+ if (h || N) return /* @__PURE__ */ e(H, {
11
11
  numberOfRows: k,
12
12
  table: m
13
13
  });
@@ -33,7 +33,7 @@ var W = ({ isLoading: h, showPagination: l, emptyState: p }) => {
33
33
  return /* @__PURE__ */ e("tbody", {
34
34
  className: r("text-slate-800", "text-sm", "font-normal", "relative", "dark:border-x"),
35
35
  children: a.map((n, c) => {
36
- const { id: b, original: i, getVisibleCells: z } = n, { meta: o = {} } = i, s = z(), t = w && n.getIsExpanded(), L = !!o.expandedRow || !!u, x = s[0]?.column.id !== "__expand" || j ? 0 : D ? 1 : null;
36
+ const { id: b, original: i, getVisibleCells: z } = n, { meta: o = {} } = i, s = z(), t = w && n.getIsExpanded(), F = !!o.expandedRow || !!u, x = s[0]?.column.id !== "__expand" || j ? 0 : D ? 1 : null;
37
37
  return /* @__PURE__ */ O(M, { children: [/* @__PURE__ */ e("tr", {
38
38
  className: r({ "group/row": g }, "border-b", "border-b-gray-200", "dark:text-metal-50", "dark:border-b-metal-700", "bg-transparent", o.className),
39
39
  "data-row-id": b,
@@ -54,7 +54,7 @@ var W = ({ isLoading: h, showPagination: l, emptyState: p }) => {
54
54
  children: A(d.columnDef.cell, V())
55
55
  }, S);
56
56
  })
57
- }), L && /* @__PURE__ */ e(H, {
57
+ }), F && /* @__PURE__ */ e(L, {
58
58
  classNameExpandedCell: E,
59
59
  classNameExpandedContent: v,
60
60
  classNameExpandedRow: R,
@@ -2,7 +2,7 @@ import { t as o } from "../Checkbox-BvRmHWxk.js";
2
2
  import { t as m } from "../DropdownButton-CWwjA3zI.js";
3
3
  import { t as p } from "../Breadcrumb-xLKDl92B.js";
4
4
  import { t as a } from "../Input-BZG7N8m1.js";
5
- import { t as n } from "../Counter-C1o8YZoR.js";
5
+ import { t as n } from "../Counter-bTFm7xa3.js";
6
6
  import { Alert as l } from "./Alert/Alert.js";
7
7
  import { Button as g } from "./Button/Button.js";
8
8
  import { AlertDialog as c } from "./AlertDialog/AlertDialog.js";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { t as o } from "./Checkbox-BvRmHWxk.js";
2
2
  import { t as m } from "./DropdownButton-CWwjA3zI.js";
3
3
  import { t as e } from "./Breadcrumb-xLKDl92B.js";
4
4
  import { t as a } from "./Input-BZG7N8m1.js";
5
- import { t as n } from "./Counter-C1o8YZoR.js";
5
+ import { t as n } from "./Counter-bTFm7xa3.js";
6
6
  import { i as l, t as d } from "./utils-COaoD3PI.js";
7
7
  import { Alert as g } from "./components/Alert/Alert.js";
8
8
  import { Button as c } from "./components/Button/Button.js";
@@ -24,6 +24,8 @@ export interface Props extends VariantProps<typeof counterVariants> {
24
24
  className?: string;
25
25
  /** CSS classes for decrement button */
26
26
  decrementButtonClassName?: string;
27
+ /** Allow typing values directly into the input. Defaults to false (read-only) */
28
+ editable?: boolean;
27
29
  /** CSS classes for increment button */
28
30
  incrementButtonClassName?: string;
29
31
  /** Initial value (deprecated, use value) */
package/dist/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@konstructio/ui",
3
3
  "description": "A set of reusable and customizable React components built for konstruct.io",
4
4
  "private": false,
5
- "version": "0.1.2-alpha.96",
5
+ "version": "0.1.2-alpha.98",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@konstructio/ui",
3
3
  "description": "A set of reusable and customizable React components built for konstruct.io",
4
4
  "private": false,
5
- "version": "0.1.2-alpha.97",
5
+ "version": "0.1.2-alpha.99",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
@@ -1,191 +0,0 @@
1
- import { o as W } from "./chunk-cI0lbGMq.js";
2
- import { t as M } from "./prop-types-CE0Kfmwk.js";
3
- import { t as j } from "./dist-EV-1XXQr.js";
4
- import { t as f } from "./utils-COaoD3PI.js";
5
- import { Typography as T } from "./components/Typography/Typography.js";
6
- import { buttonVariants as k, counterVariants as V, labelVariants as C } from "./components/Counter/Counter.variants.js";
7
- import m, { forwardRef as b, useCallback as N, useId as R } from "react";
8
- import { jsx as u, jsxs as p } from "react/jsx-runtime";
9
- var l = /* @__PURE__ */ W(M());
10
- function h() {
11
- return h = Object.assign || function(e) {
12
- for (var o = 1; o < arguments.length; o++) {
13
- var r = arguments[o];
14
- for (var t in r) Object.prototype.hasOwnProperty.call(r, t) && (e[t] = r[t]);
15
- }
16
- return e;
17
- }, h.apply(this, arguments);
18
- }
19
- function S(e, o) {
20
- if (e == null) return {};
21
- var r = B(e, o), t, n;
22
- if (Object.getOwnPropertySymbols) {
23
- var i = Object.getOwnPropertySymbols(e);
24
- for (n = 0; n < i.length; n++)
25
- t = i[n], !(o.indexOf(t) >= 0) && Object.prototype.propertyIsEnumerable.call(e, t) && (r[t] = e[t]);
26
- }
27
- return r;
28
- }
29
- function B(e, o) {
30
- if (e == null) return {};
31
- var r = {}, t = Object.keys(e), n, i;
32
- for (i = 0; i < t.length; i++)
33
- n = t[i], !(o.indexOf(n) >= 0) && (r[n] = e[n]);
34
- return r;
35
- }
36
- var O = b(function(e, o) {
37
- var r = e.color, t = r === void 0 ? "currentColor" : r, n = e.size, i = n === void 0 ? 24 : n, a = S(e, ["color", "size"]);
38
- return /* @__PURE__ */ m.createElement("svg", h({
39
- ref: o,
40
- xmlns: "http://www.w3.org/2000/svg",
41
- width: i,
42
- height: i,
43
- viewBox: "0 0 24 24",
44
- fill: "none",
45
- stroke: t,
46
- strokeWidth: "2",
47
- strokeLinecap: "round",
48
- strokeLinejoin: "round"
49
- }, a), /* @__PURE__ */ m.createElement("line", {
50
- x1: "5",
51
- y1: "12",
52
- x2: "19",
53
- y2: "12"
54
- }));
55
- });
56
- O.propTypes = {
57
- color: l.default.string,
58
- size: l.default.oneOfType([l.default.string, l.default.number])
59
- };
60
- O.displayName = "Minus";
61
- function g() {
62
- return g = Object.assign || function(e) {
63
- for (var o = 1; o < arguments.length; o++) {
64
- var r = arguments[o];
65
- for (var t in r) Object.prototype.hasOwnProperty.call(r, t) && (e[t] = r[t]);
66
- }
67
- return e;
68
- }, g.apply(this, arguments);
69
- }
70
- function D(e, o) {
71
- if (e == null) return {};
72
- var r = q(e, o), t, n;
73
- if (Object.getOwnPropertySymbols) {
74
- var i = Object.getOwnPropertySymbols(e);
75
- for (n = 0; n < i.length; n++)
76
- t = i[n], !(o.indexOf(t) >= 0) && Object.prototype.propertyIsEnumerable.call(e, t) && (r[t] = e[t]);
77
- }
78
- return r;
79
- }
80
- function q(e, o) {
81
- if (e == null) return {};
82
- var r = {}, t = Object.keys(e), n, i;
83
- for (i = 0; i < t.length; i++)
84
- n = t[i], !(o.indexOf(n) >= 0) && (r[n] = e[n]);
85
- return r;
86
- }
87
- var w = b(function(e, o) {
88
- var r = e.color, t = r === void 0 ? "currentColor" : r, n = e.size, i = n === void 0 ? 24 : n, a = D(e, ["color", "size"]);
89
- return /* @__PURE__ */ m.createElement("svg", g({
90
- ref: o,
91
- xmlns: "http://www.w3.org/2000/svg",
92
- width: i,
93
- height: i,
94
- viewBox: "0 0 24 24",
95
- fill: "none",
96
- stroke: t,
97
- strokeWidth: "2",
98
- strokeLinecap: "round",
99
- strokeLinejoin: "round"
100
- }, a), /* @__PURE__ */ m.createElement("line", {
101
- x1: "12",
102
- y1: "5",
103
- x2: "12",
104
- y2: "19"
105
- }), /* @__PURE__ */ m.createElement("line", {
106
- x1: "5",
107
- y1: "12",
108
- x2: "19",
109
- y2: "12"
110
- }));
111
- });
112
- w.propTypes = {
113
- color: l.default.string,
114
- size: l.default.oneOfType([l.default.string, l.default.number])
115
- };
116
- w.displayName = "Plus";
117
- var X = b(({ canDecrement: e = !0, canIncrement: o = !0, className: r, decrementButtonClassName: t, incrementButtonClassName: n, isRequired: i, label: a, labelWrapperClassName: P, max: y = -1 / 0, min: v = 1 / 0, name: x, theme: _, value: z, onChange: d }, I) => {
118
- const E = R(), s = z ?? 0, L = N(() => {
119
- let c = 0;
120
- v === 1 / 0 ? c = s - 1 : c = Math.max(v, s - 1), d?.({ target: { value: c } });
121
- }, [
122
- s,
123
- v,
124
- d
125
- ]), $ = N(() => {
126
- let c = 0;
127
- y === -1 / 0 ? c = s + 1 : c = Math.min(y, s + 1), d?.({ target: { value: c } });
128
- }, [
129
- s,
130
- y,
131
- d
132
- ]);
133
- return /* @__PURE__ */ p("div", {
134
- className: "flex flex-col gap-2",
135
- "data-theme": _,
136
- children: [a ? /* @__PURE__ */ u("div", {
137
- className: f(P),
138
- children: /* @__PURE__ */ p(T, {
139
- component: "label",
140
- htmlFor: x ?? E,
141
- variant: "labelLarge",
142
- className: f(C()),
143
- children: [
144
- a,
145
- " ",
146
- i && /* @__PURE__ */ u("span", {
147
- className: "text-red-600 dark:text-red-500",
148
- children: "*"
149
- })
150
- ]
151
- })
152
- }) : null, /* @__PURE__ */ p("div", {
153
- className: "flex items-center",
154
- role: "presentation",
155
- children: [
156
- /* @__PURE__ */ p("button", {
157
- type: "button",
158
- onClick: L,
159
- className: f(k({
160
- button: "rigth",
161
- className: t
162
- })),
163
- disabled: !e,
164
- children: [/* @__PURE__ */ u(O, { className: "w-4 h-4" }), /* @__PURE__ */ u(j, { children: "Decrement" })]
165
- }),
166
- /* @__PURE__ */ u("input", {
167
- ref: I,
168
- type: "number",
169
- value: s,
170
- name: x,
171
- className: f(V({ className: r })),
172
- readOnly: !0,
173
- "aria-label": typeof a == "string" ? a : "number input"
174
- }),
175
- /* @__PURE__ */ p("button", {
176
- type: "button",
177
- onClick: $,
178
- className: f(k({
179
- button: "left",
180
- className: n
181
- })),
182
- disabled: !o,
183
- children: [/* @__PURE__ */ u(w, { className: "w-4 h-4" }), /* @__PURE__ */ u(j, { children: "Increment" })]
184
- })
185
- ]
186
- })]
187
- });
188
- });
189
- export {
190
- X as t
191
- };