laif-ds 0.2.46 → 0.2.47

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,5 +1,8 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
+ import { __require as t } from "../node_modules/eventemitter3/index2.js";
4
+ var r = t();
5
+ const m = /* @__PURE__ */ e(r);
3
6
  export {
4
- e as __module
7
+ m as default
5
8
  };
@@ -1,8 +1,5 @@
1
1
  "use client";
2
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
3
- import { __require as t } from "../node_modules/eventemitter3/index2.js";
4
- var r = t();
5
- const m = /* @__PURE__ */ e(r);
2
+ var e = { exports: {} };
6
3
  export {
7
- m as default
4
+ e as __module
8
5
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- var e = {};
2
+ var e = { exports: {} };
3
3
  export {
4
- e as __exports
4
+ e as __module
5
5
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ var e = {};
3
3
  export {
4
- e as __module
4
+ e as __exports
5
5
  };
@@ -24,6 +24,7 @@ export interface AppFormItem {
24
24
  | "switch"
25
25
  | "slider"; // Field type
26
26
  name: string; // Field name (used for form state and validation)
27
+ inputType?: string; // HTML input type for "input" component (e.g. "text", "email", "password", "number")
27
28
  defaultValue?: string | boolean | number | string[] | Date | number[]; // Initial value
28
29
  options?: AppSelectOption[]; // Options for select/multiselect/radio
29
30
  disabled?: boolean; // Disables the field
@@ -88,15 +89,15 @@ export function SubmitInsideVsOutside() {
88
89
 
89
90
  ## Props
90
91
 
91
- | Prop | Type | Default | Description |
92
- | --------------- | -------------------------- | --------- | ---------------------------------------- |
93
- | `items` | `AppFormItem[]` | **required** | Array of form field configurations |
94
- | `form` | `UseFormReturn<any>` | **required** | React Hook Form instance |
95
- | `cols` | `"1" \| "2" \| "3"` | `"2"` | Number of grid columns |
96
- | `submitText` | `string` | `"Invia"` | Text for submit button |
97
- | `onSubmit` | `(data: any) => void` | `undefined` | Form submission callback |
98
- | `isSubmitting` | `boolean` | `false` | Shows loading state on submit button |
99
- | `showSubmitButton` | `boolean` | `false` | Renders an internal submit button at the end of the form |
92
+ | Prop | Type | Default | Description |
93
+ | ------------------ | --------------------- | ------------ | -------------------------------------------------------- |
94
+ | `items` | `AppFormItem[]` | **required** | Array of form field configurations |
95
+ | `form` | `UseFormReturn<any>` | **required** | React Hook Form instance |
96
+ | `cols` | `"1" \| "2" \| "3"` | `"2"` | Number of grid columns |
97
+ | `submitText` | `string` | `"Invia"` | Text for submit button |
98
+ | `onSubmit` | `(data: any) => void` | `undefined` | Form submission callback |
99
+ | `isSubmitting` | `boolean` | `false` | Shows loading state on submit button |
100
+ | `showSubmitButton` | `boolean` | `false` | Renders an internal submit button at the end of the form |
100
101
 
101
102
  ---
102
103
 
@@ -114,30 +115,41 @@ export function SubmitInsideVsOutside() {
114
115
  ## Field Types
115
116
 
116
117
  ### input
117
- Standard text input field
118
+
119
+ Standard text input field. When `component: "input"`, you can use the `inputType` property to control the underlying HTML input type (e.g. `"text"`, `"email"`, `"password"`, `"number"`, `"url"`).
120
+
121
+ For a complete showcase of different input types, see the Storybook story `UI/AppForm/DifferentInputTypes`.
118
122
 
119
123
  ### textarea
124
+
120
125
  Multi-line text area
121
126
 
122
127
  ### select
128
+
123
129
  Single selection dropdown using AppSelect
124
130
 
125
131
  ### multiselect
132
+
126
133
  Multiple selection dropdown using AppSelect with `multiple` prop
127
134
 
128
135
  ### datepicker
136
+
129
137
  Date picker component with optional range selection via `calendarRange`
130
138
 
131
139
  ### radio
140
+
132
141
  Radio button group with options
133
142
 
134
143
  ### checkbox
144
+
135
145
  Single checkbox with label
136
146
 
137
147
  ### switch
148
+
138
149
  Toggle switch with label and optional caption
139
150
 
140
151
  ### slider
152
+
141
153
  Range slider with min/max/step configuration
142
154
 
143
155
  ---
@@ -167,6 +179,7 @@ export function BasicForm() {
167
179
  label: "Email",
168
180
  component: "input",
169
181
  name: "email",
182
+ inputType: "email",
170
183
  placeholder: "Enter your email",
171
184
  },
172
185
  {
@@ -1,25 +1,25 @@
1
1
  "use client";
2
- import { jsxs as n, jsx as a } from "react/jsx-runtime";
2
+ import { jsxs as l, jsx as a } from "react/jsx-runtime";
3
3
  import { cn as o } from "../../lib/utils.js";
4
4
  import { Controller as V } from "../../node_modules/react-hook-form/dist/index.esm.js";
5
- import { AppSelect as m } from "./app-select.js";
5
+ import { AppSelect as v } from "./app-select.js";
6
6
  import { Button as j } from "./button.js";
7
7
  import { Checkbox as A } from "./checkbox.js";
8
8
  import { DatePicker as F } from "./date-picker.js";
9
9
  import { Input as I } from "./input.js";
10
10
  import { Label as t } from "./label.js";
11
11
  import { RadioGroup as R, RadioGroupItem as B } from "./radio-group.js";
12
- import { Slider as $ } from "./slider.js";
13
- import { Switch as D } from "./switch.js";
14
- import { Textarea as G } from "./textarea.js";
12
+ import { Slider as T } from "./slider.js";
13
+ import { Switch as $ } from "./switch.js";
14
+ import { Textarea as D } from "./textarea.js";
15
15
  import { Typo as i } from "./typo.js";
16
16
  const X = ({
17
- items: h,
18
- cols: v = "2",
17
+ items: p,
18
+ cols: m = "2",
19
19
  form: b,
20
20
  submitText: g = "Invia",
21
21
  onSubmit: x,
22
- isSubmitting: p = !1,
22
+ isSubmitting: h = !1,
23
23
  showSubmitButton: C = !1
24
24
  }) => {
25
25
  const {
@@ -34,18 +34,19 @@ const X = ({
34
34
  name: e.name,
35
35
  control: N,
36
36
  render: ({ field: r }) => {
37
- const s = /* @__PURE__ */ n("div", { className: "mb-2 flex items-center justify-between", children: [
37
+ const s = /* @__PURE__ */ l("div", { className: "mb-2 flex items-center justify-between", children: [
38
38
  /* @__PURE__ */ a(t, { children: e.label }),
39
39
  d && /* @__PURE__ */ a("span", { className: "text-d-destructive text-xs", children: d })
40
40
  ] });
41
41
  switch (e.component) {
42
42
  case "input":
43
- return /* @__PURE__ */ n("div", { children: [
43
+ return /* @__PURE__ */ l("div", { children: [
44
44
  s,
45
45
  /* @__PURE__ */ a(
46
46
  I,
47
47
  {
48
48
  ...r,
49
+ type: e.inputType,
49
50
  placeholder: e.placeholder,
50
51
  className: o(d && "border-d-destructive"),
51
52
  disabled: e.disabled
@@ -53,10 +54,10 @@ const X = ({
53
54
  )
54
55
  ] });
55
56
  case "textarea":
56
- return /* @__PURE__ */ n("div", { children: [
57
+ return /* @__PURE__ */ l("div", { children: [
57
58
  s,
58
59
  /* @__PURE__ */ a(
59
- G,
60
+ D,
60
61
  {
61
62
  ...r,
62
63
  placeholder: e.placeholder,
@@ -66,18 +67,18 @@ const X = ({
66
67
  )
67
68
  ] });
68
69
  case "radio":
69
- return /* @__PURE__ */ n("div", { children: [
70
+ return /* @__PURE__ */ l("div", { children: [
70
71
  s,
71
72
  /* @__PURE__ */ a(
72
73
  R,
73
74
  {
74
75
  value: r.value != null ? String(r.value) : "",
75
- onValueChange: (l) => r.onChange(l),
76
+ onValueChange: (n) => r.onChange(n),
76
77
  className: "space-y-2",
77
78
  disabled: e.disabled,
78
- children: (e.options ?? []).map((l) => {
79
- const u = `${e.name}-${l.value}`;
80
- return /* @__PURE__ */ n(
79
+ children: (e.options ?? []).map((n) => {
80
+ const u = `${e.name}-${n.value}`;
81
+ return /* @__PURE__ */ l(
81
82
  "div",
82
83
  {
83
84
  className: "flex items-center gap-2",
@@ -86,7 +87,7 @@ const X = ({
86
87
  B,
87
88
  {
88
89
  id: u,
89
- value: String(l.value),
90
+ value: String(n.value),
90
91
  disabled: e.disabled
91
92
  }
92
93
  ),
@@ -98,25 +99,25 @@ const X = ({
98
99
  "cursor-pointer",
99
100
  e.disabled && "cursor-not-allowed opacity-60"
100
101
  ),
101
- children: l.label
102
+ children: n.label
102
103
  }
103
104
  )
104
105
  ]
105
106
  },
106
- l.value
107
+ n.value
107
108
  );
108
109
  })
109
110
  }
110
111
  )
111
112
  ] });
112
113
  case "select":
113
- return /* @__PURE__ */ n("div", { children: [
114
+ return /* @__PURE__ */ l("div", { children: [
114
115
  s,
115
116
  /* @__PURE__ */ a(
116
- m,
117
+ v,
117
118
  {
118
119
  ...r,
119
- onValueChange: (l) => r.onChange(l),
120
+ onValueChange: (n) => r.onChange(n),
120
121
  options: e.options ?? [],
121
122
  placeholder: e.placeholder,
122
123
  disabled: e.disabled
@@ -124,14 +125,14 @@ const X = ({
124
125
  )
125
126
  ] });
126
127
  case "multiselect":
127
- return /* @__PURE__ */ n("div", { children: [
128
+ return /* @__PURE__ */ l("div", { children: [
128
129
  s,
129
130
  /* @__PURE__ */ a(
130
- m,
131
+ v,
131
132
  {
132
133
  ...r,
133
134
  multiple: !0,
134
- onValueChange: (l) => r.onChange(l),
135
+ onValueChange: (n) => r.onChange(n),
135
136
  options: e.options ?? [],
136
137
  placeholder: e.placeholder,
137
138
  disabled: e.disabled
@@ -139,13 +140,13 @@ const X = ({
139
140
  )
140
141
  ] });
141
142
  case "datepicker":
142
- return /* @__PURE__ */ n("div", { className: "relative", children: [
143
+ return /* @__PURE__ */ l("div", { className: "relative", children: [
143
144
  s,
144
145
  /* @__PURE__ */ a(
145
146
  F,
146
147
  {
147
148
  value: r.value,
148
- onChange: e.disabled || e.calendarRange ? void 0 : (l) => r.onChange(l),
149
+ onChange: e.disabled || e.calendarRange ? void 0 : (n) => r.onChange(n),
149
150
  placeholder: e.placeholder,
150
151
  disabled: e.disabled,
151
152
  customCalendarProps: e.disabled ? {
@@ -154,20 +155,20 @@ const X = ({
154
155
  } : e.calendarRange ? {
155
156
  mode: "range",
156
157
  selected: r.value,
157
- onSelect: (l) => r.onChange(l)
158
+ onSelect: (n) => r.onChange(n)
158
159
  } : void 0
159
160
  }
160
161
  )
161
162
  ] });
162
163
  case "checkbox":
163
- return /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
164
- /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
164
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
165
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
165
166
  /* @__PURE__ */ a(
166
167
  A,
167
168
  {
168
169
  ...r,
169
170
  id: e.name,
170
- onCheckedChange: (l) => r.onChange(l),
171
+ onCheckedChange: (n) => r.onChange(n),
171
172
  defaultChecked: !!e.defaultValue,
172
173
  disabled: e.disabled
173
174
  }
@@ -195,9 +196,9 @@ const X = ({
195
196
  )
196
197
  ] });
197
198
  case "switch":
198
- return /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
199
- /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
200
- /* @__PURE__ */ n("div", { children: [
199
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
200
+ /* @__PURE__ */ l("div", { className: "flex items-center justify-between", children: [
201
+ /* @__PURE__ */ l("div", { children: [
201
202
  /* @__PURE__ */ a(t, { htmlFor: e.name, children: e.label }),
202
203
  e.caption && /* @__PURE__ */ a(
203
204
  i,
@@ -209,11 +210,11 @@ const X = ({
209
210
  )
210
211
  ] }),
211
212
  /* @__PURE__ */ a(
212
- D,
213
+ $,
213
214
  {
214
215
  id: e.name,
215
216
  checked: !!r.value,
216
- onCheckedChange: (l) => r.onChange(l),
217
+ onCheckedChange: (n) => r.onChange(n),
217
218
  disabled: e.disabled
218
219
  }
219
220
  )
@@ -221,13 +222,13 @@ const X = ({
221
222
  d && /* @__PURE__ */ a("span", { className: "text-d-destructive text-xs", children: d })
222
223
  ] });
223
224
  case "slider":
224
- return /* @__PURE__ */ n("div", { children: [
225
+ return /* @__PURE__ */ l("div", { children: [
225
226
  s,
226
227
  /* @__PURE__ */ a(
227
- $,
228
+ T,
228
229
  {
229
230
  value: Array.isArray(r.value) ? r.value : [r.value || e.min || 0],
230
- onValueChange: (l) => r.onChange(l[0]),
231
+ onValueChange: (n) => r.onChange(n[0]),
231
232
  min: e.min ?? 0,
232
233
  max: e.max ?? 100,
233
234
  step: e.step ?? 1,
@@ -249,11 +250,11 @@ const X = ({
249
250
  }
250
251
  ) });
251
252
  };
252
- return /* @__PURE__ */ n("form", { onSubmit: y((e) => x?.(e)), children: [
253
- /* @__PURE__ */ a("div", { className: o("grid gap-4", `grid-cols-${v}`), children: h.map((e, c) => /* @__PURE__ */ a(
253
+ return /* @__PURE__ */ l("form", { onSubmit: y((e) => x?.(e)), children: [
254
+ /* @__PURE__ */ a("div", { className: o("grid gap-4", `grid-cols-${m}`), children: p.map((e, c) => /* @__PURE__ */ a(
254
255
  "div",
255
256
  {
256
- className: o(c === h.length - 1 && "col-span-full"),
257
+ className: o(c === p.length - 1 && "col-span-full"),
257
258
  children: w(e)
258
259
  },
259
260
  e.name
@@ -262,8 +263,8 @@ const X = ({
262
263
  j,
263
264
  {
264
265
  type: "submit",
265
- disabled: !S || !k || p,
266
- isLoading: p,
266
+ disabled: !S || !k || h,
267
+ isLoading: h,
267
268
  children: g
268
269
  }
269
270
  ) })
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import { ClassValue } from 'clsx';
8
8
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
9
9
  import { ColumnDef } from '@tanstack/react-table';
10
10
  import { Command as Command_2 } from 'cmdk';
11
+ import { ComponentProps } from 'react';
11
12
  import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
12
13
  import { ControllerProps } from 'react-hook-form';
13
14
  import { DayPicker } from 'react-day-picker';
@@ -152,6 +153,7 @@ export declare interface AppFormItem {
152
153
  label: string;
153
154
  component: "input" | "select" | "textarea" | "checkbox" | "multiselect" | "datepicker" | "radio" | "switch" | "slider";
154
155
  name: string;
156
+ inputType?: ComponentProps<"input">["type"];
155
157
  defaultValue?: string | boolean | number | string[] | Date | number[];
156
158
  options?: AppSelectOption[];
157
159
  disabled?: boolean;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../_virtual/index3.js";
2
+ import e from "../../_virtual/index2.js";
3
3
  export {
4
4
  e as EventEmitter,
5
5
  e as default
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as x } from "../../_virtual/index7.js";
2
+ import { __module as x } from "../../_virtual/index6.js";
3
3
  var w;
4
4
  function O() {
5
5
  return w ? x.exports : (w = 1, (function(d) {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../../../_virtual/index3.js";
2
+ import e from "../../../../_virtual/index2.js";
3
3
  var r = new e(), n = "recharts.syncEvent.tooltip";
4
4
  export {
5
5
  n as TOOLTIP_SYNC_EVENT,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __exports as r } from "../../../_virtual/index6.js";
2
+ import { __exports as r } from "../../../_virtual/index7.js";
3
3
  import { __require as c } from "../../inline-style-parser/index.js";
4
4
  var f;
5
5
  function j() {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as e } from "../../../_virtual/index2.js";
2
+ import { __module as e } from "../../../_virtual/index3.js";
3
3
  import { __require as i } from "../cjs/use-sync-external-store-shim.production.js";
4
4
  import { __require as o } from "../cjs/use-sync-external-store-shim.development.js";
5
5
  var r;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.2.46",
4
+ "version": "0.2.47",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",