@tachui/primitives 0.8.0-alpha → 0.8.5-alpha

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,6 +1,6 @@
1
- import { withModifiers as y, createSignal as b, createEffect as u, h as p, text as g, ComponentWithCSSClasses as E, isSignal as h } from "@tachui/core";
2
- var v = Object.defineProperty, S = (t, e, s) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, o = (t, e, s) => S(t, typeof e != "symbol" ? e + "" : e, s);
3
- class F {
1
+ import { withModifiers as v, createSignal as g, createEffect as c, h as p, text as y, clonePropsPreservingReactivity as x, resetLifecycleState as E, ComponentWithCSSClasses as F, isSignal as h } from "@tachui/core";
2
+ var C = Object.defineProperty, w = (t, e, s) => e in t ? C(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, o = (t, e, s) => w(t, typeof e != "symbol" ? e + "" : e, s);
3
+ class u {
4
4
  constructor(e) {
5
5
  this.props = e, o(this, "type", "component"), o(this, "id"), o(this, "mounted", !1), o(this, "cleanup", []), o(this, "formElement", null), o(this, "validationErrors"), o(this, "setValidationErrors"), o(this, "setIsValid"), o(this, "handleSubmit", async (n) => {
6
6
  if (n.preventDefault(), this.props.validateOnSubmit !== !1) {
@@ -18,8 +18,8 @@ class F {
18
18
  this.setValidationErrors(n);
19
19
  }
20
20
  }), this.id = `form-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
21
- const [s, r] = b([]), [, i] = b(!0);
22
- this.validationErrors = s, this.setValidationErrors = r, this.setIsValid = i, u(() => {
21
+ const [s, r] = g([]), [, i] = g(!0);
22
+ this.validationErrors = s, this.setValidationErrors = r, this.setIsValid = i, c(() => {
23
23
  const n = this.validationErrors(), a = n.length === 0;
24
24
  this.setIsValid(a), this.props.onValidationChange && this.props.onValidationChange(a, n);
25
25
  });
@@ -118,7 +118,7 @@ class F {
118
118
  marginBottom: "8px"
119
119
  }
120
120
  },
121
- g("Please fix the following errors:")
121
+ y("Please fix the following errors:")
122
122
  ),
123
123
  p(
124
124
  "ul",
@@ -131,7 +131,7 @@ class F {
131
131
  }
132
132
  },
133
133
  ...e.map(
134
- (s) => p("li", { key: s.field }, g(s.message))
134
+ (s) => p("li", { key: s.field }, y(s.message))
135
135
  )
136
136
  )
137
137
  );
@@ -162,12 +162,25 @@ class F {
162
162
  )
163
163
  ];
164
164
  }
165
+ clone(e = {}) {
166
+ return e.deep ? this.deepClone() : this.shallowClone();
167
+ }
168
+ shallowClone() {
169
+ const e = x(this.props), s = new u(e);
170
+ return E(s), s;
171
+ }
172
+ deepClone() {
173
+ const e = x(this.props, {
174
+ deep: !0
175
+ }), s = new u(e);
176
+ return E(s), s;
177
+ }
165
178
  }
166
179
  function d(t, e = {}) {
167
- const s = { ...e, children: t }, r = new F(s);
168
- return y(r);
180
+ const s = { ...e, children: t }, r = new u(s);
181
+ return v(r);
169
182
  }
170
- const B = {
183
+ const I = {
171
184
  /**
172
185
  * Automatic form styling (default)
173
186
  */
@@ -192,7 +205,7 @@ const B = {
192
205
  Plain(t, e = {}) {
193
206
  return d(t, { ...e, style: "plain" });
194
207
  }
195
- }, I = {
208
+ }, P = {
196
209
  /**
197
210
  * Common validation rules
198
211
  */
@@ -225,7 +238,7 @@ const B = {
225
238
  }
226
239
  };
227
240
  var V = Object.defineProperty, T = (t, e, s) => e in t ? V(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, l = (t, e, s) => T(t, typeof e != "symbol" ? e + "" : e, s);
228
- const c = {
241
+ const m = {
229
242
  colors: {
230
243
  background: "#FFFFFF",
231
244
  border: "#D1D1D6",
@@ -244,9 +257,9 @@ const c = {
244
257
  fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
245
258
  transition: "border-color 0.2s ease, background-color 0.2s ease"
246
259
  };
247
- class C extends E {
260
+ class B extends F {
248
261
  constructor(e) {
249
- super(), l(this, "type", "component"), l(this, "id"), l(this, "props"), l(this, "theme", c), l(this, "inputElement", null), l(this, "handleInput", (s) => {
262
+ super(), l(this, "type", "component"), l(this, "id"), l(this, "props"), l(this, "theme", m), l(this, "inputElement", null), l(this, "handleInput", (s) => {
250
263
  const i = s.target.value;
251
264
  this.setText(i), this.props.onChange && this.props.onChange(i);
252
265
  }), l(this, "handleKeyDown", (s) => {
@@ -295,9 +308,9 @@ class C extends E {
295
308
  };
296
309
  }
297
310
  render() {
298
- const e = this.getText(), s = this.getPlaceholder(), r = this.getInputType(), i = this.isDisabled(), n = this.isReadonly(), a = ["tachui-basic-input"], x = this.createClassString(this.props, a), m = p("input", {
311
+ const e = this.getText(), s = this.getPlaceholder(), r = this.getInputType(), i = this.isDisabled(), n = this.isReadonly(), a = ["tachui-basic-input"], S = this.createClassString(this.props, a), f = p("input", {
299
312
  id: this.id,
300
- className: x,
313
+ className: S,
301
314
  type: r,
302
315
  value: e,
303
316
  placeholder: s,
@@ -311,20 +324,20 @@ class C extends E {
311
324
  onfocus: this.handleFocus,
312
325
  onblur: this.handleBlur
313
326
  });
314
- return this.inputElement = m.element, u(() => {
327
+ return this.inputElement = f.element, c(() => {
315
328
  if (this.inputElement && h(this.props.text)) {
316
- const f = this.getText();
317
- this.inputElement.value !== f && (this.inputElement.value = f);
329
+ const b = this.getText();
330
+ this.inputElement.value !== b && (this.inputElement.value = b);
318
331
  }
319
- }), u(() => {
332
+ }), c(() => {
320
333
  this.inputElement && (h(this.props.placeholder) || h(this.props.inputType) || h(this.props.disabled)) && (h(this.props.placeholder) && (this.inputElement.placeholder = this.getPlaceholder()), h(this.props.inputType) && (this.inputElement.type = this.getInputType()), h(this.props.disabled) && (this.inputElement.disabled = this.isDisabled()));
321
- }), [m];
334
+ }), [f];
322
335
  }
323
336
  }
324
- function D(t) {
325
- return y(new C(t));
337
+ function $(t) {
338
+ return v(new B(t));
326
339
  }
327
- const $ = {
340
+ const L = {
328
341
  /**
329
342
  * Create a search input
330
343
  */
@@ -370,21 +383,21 @@ const $ = {
370
383
  placeholder: "Enter phone number"
371
384
  };
372
385
  }
373
- }, _ = {
374
- theme: c,
386
+ }, R = {
387
+ theme: m,
375
388
  /**
376
389
  * Create a custom theme
377
390
  */
378
391
  createTheme(t) {
379
- return { ...c, ...t };
392
+ return { ...m, ...t };
380
393
  }
381
394
  };
382
395
  export {
383
396
  d as B,
384
- F as a,
385
- B as b,
386
- I as c,
387
- D as d,
388
- _ as e,
389
- $ as f
397
+ u as a,
398
+ I as b,
399
+ P as c,
400
+ $ as d,
401
+ R as e,
402
+ L as f
390
403
  };