@tachui/primitives 0.8.0-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.
Files changed (49) hide show
  1. package/LICENSE +363 -0
  2. package/README.md +458 -0
  3. package/dist/BasicInput-CWFHw9rL.js +390 -0
  4. package/dist/Divider-DWgDKavU.js +474 -0
  5. package/dist/HTML-aWcvQ0VC.js +321 -0
  6. package/dist/Picker-DrZ7ibdt.js +1675 -0
  7. package/dist/Text-DYyFBJ6i.js +165 -0
  8. package/dist/controls/Button.d.ts +250 -0
  9. package/dist/controls/Button.d.ts.map +1 -0
  10. package/dist/controls/Link.d.ts +365 -0
  11. package/dist/controls/Link.d.ts.map +1 -0
  12. package/dist/controls/Picker.d.ts +153 -0
  13. package/dist/controls/Picker.d.ts.map +1 -0
  14. package/dist/controls/Toggle.d.ts +207 -0
  15. package/dist/controls/Toggle.d.ts.map +1 -0
  16. package/dist/controls/index.d.ts +8 -0
  17. package/dist/controls/index.d.ts.map +1 -0
  18. package/dist/controls/index.js +18 -0
  19. package/dist/display/HTML.d.ts +120 -0
  20. package/dist/display/HTML.d.ts.map +1 -0
  21. package/dist/display/Image.d.ts +192 -0
  22. package/dist/display/Image.d.ts.map +1 -0
  23. package/dist/display/Text.d.ts +269 -0
  24. package/dist/display/Text.d.ts.map +1 -0
  25. package/dist/display/index.d.ts +7 -0
  26. package/dist/display/index.d.ts.map +1 -0
  27. package/dist/display/index.js +21 -0
  28. package/dist/forms/BasicForm.d.ts +141 -0
  29. package/dist/forms/BasicForm.d.ts.map +1 -0
  30. package/dist/forms/BasicInput.d.ts +116 -0
  31. package/dist/forms/BasicInput.d.ts.map +1 -0
  32. package/dist/forms/index.d.ts +6 -0
  33. package/dist/forms/index.d.ts.map +1 -0
  34. package/dist/forms/index.js +10 -0
  35. package/dist/index.d.ts +11 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +485 -0
  38. package/dist/layout/Divider.d.ts +168 -0
  39. package/dist/layout/Divider.d.ts.map +1 -0
  40. package/dist/layout/Spacer.d.ts +35 -0
  41. package/dist/layout/Spacer.d.ts.map +1 -0
  42. package/dist/layout/Stack.d.ts +74 -0
  43. package/dist/layout/Stack.d.ts.map +1 -0
  44. package/dist/layout/index.d.ts +7 -0
  45. package/dist/layout/index.d.ts.map +1 -0
  46. package/dist/layout/index.js +15 -0
  47. package/dist/validation.d.ts +91 -0
  48. package/dist/validation.d.ts.map +1 -0
  49. package/package.json +82 -0
@@ -0,0 +1,321 @@
1
+ import { withModifiers as a, ComponentWithCSSClasses as b, processElementOverride as w, createSignal as y, useLifecycle as C, ImageAsset as v, registerComponentWithLifecycleHooks as T, h as p, createEffect as E, ConcatenatedComponent as g, text as R } from "@tachui/core";
2
+ import { aspectRatio as S } from "@tachui/modifiers";
3
+ var I = Object.defineProperty, P = (t, e, i) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, c = (t, e, i) => P(t, typeof e != "symbol" ? e + "" : e, i);
4
+ class m extends b {
5
+ constructor(e) {
6
+ super(), this.props = e, c(this, "type", "component"), c(this, "id"), c(this, "mounted", !1), c(this, "cleanup", []), c(this, "effectiveTag"), c(this, "validationResult"), c(this, "loadingStateSignal"), c(this, "setLoadingState"), this.id = `image-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
7
+ const i = w("Image", "img", this.props.element);
8
+ this.effectiveTag = i.tag, this.validationResult = i.validation;
9
+ const o = this.props.src ? "idle" : "error", [n, r] = y(o);
10
+ this.loadingStateSignal = n, this.setLoadingState = r, C(this, {
11
+ onDOMReady: (s, f) => {
12
+ this.props.src instanceof v && f instanceof HTMLImageElement && this.setupImageAssetReactivityForDOMElement(
13
+ this.props.src,
14
+ f
15
+ );
16
+ }
17
+ }), T(this);
18
+ }
19
+ /**
20
+ * Set loading state and notify callback
21
+ */
22
+ setLoadingStateWithCallback(e) {
23
+ this.setLoadingState(e), this.props.onLoadingStateChange && this.props.onLoadingStateChange(e);
24
+ }
25
+ /**
26
+ * Render the image component with reactive content handling
27
+ */
28
+ render() {
29
+ const e = this.loadingStateSignal();
30
+ if (e === "loading" && this.props.placeholder) {
31
+ if (typeof this.props.placeholder == "string")
32
+ return [p("img", {
33
+ class: "tachui-image-placeholder",
34
+ src: this.props.placeholder,
35
+ alt: "Loading..."
36
+ })];
37
+ if (this.props.placeholder && typeof this.props.placeholder == "object")
38
+ return this.props.placeholder.render();
39
+ }
40
+ if (e === "error" && this.props.errorPlaceholder) {
41
+ if (typeof this.props.errorPlaceholder == "string")
42
+ return [p("img", {
43
+ class: "tachui-image-error",
44
+ src: this.props.errorPlaceholder,
45
+ alt: "Error loading image"
46
+ })];
47
+ if (this.props.errorPlaceholder && typeof this.props.errorPlaceholder == "object")
48
+ return this.props.errorPlaceholder.render();
49
+ }
50
+ const i = this.props.src instanceof v ? this.props.src.resolve() : this.props.src, o = ["tachui-image"], n = this.createClassString(this.props, o), r = p(this.effectiveTag, {
51
+ className: n,
52
+ src: i,
53
+ // Pass resolved src for initial render
54
+ alt: this.props.alt,
55
+ // Pass reactive alt directly
56
+ loading: this.props.loadingStrategy || "lazy",
57
+ crossorigin: this.props.crossOrigin,
58
+ decoding: this.props.decoding || "async",
59
+ fetchpriority: this.props.fetchPriority
60
+ });
61
+ return r.componentMetadata = {
62
+ id: this.id,
63
+ type: "Image",
64
+ originalType: "Image",
65
+ overriddenTo: this.effectiveTag !== "img" ? this.effectiveTag : void 0,
66
+ validationResult: this.validationResult
67
+ }, [r];
68
+ }
69
+ /**
70
+ * Set up ImageAsset reactivity for a real DOM element (called from onDOMReady)
71
+ */
72
+ setupImageAssetReactivityForDOMElement(e, i) {
73
+ const o = E(() => {
74
+ const n = e.resolve();
75
+ i.src = n, this.setLoadingStateWithCallback("loading");
76
+ });
77
+ this.cleanup.push(() => o.dispose());
78
+ }
79
+ // ============================================================================
80
+ // Concatenation Support (Phase 3.1)
81
+ // ============================================================================
82
+ /**
83
+ * Concatenate this image with another concatenatable component
84
+ */
85
+ concat(e) {
86
+ const i = this.toSegment(), o = e.toSegment(), n = {
87
+ totalSegments: e instanceof g ? e.segments.length + 1 : 2,
88
+ accessibilityRole: e instanceof g ? this.mergeAccessibilityRoles(
89
+ "group",
90
+ e.metadata.accessibilityRole
91
+ ) : this.determineAccessibilityRole(e),
92
+ semanticStructure: "inline"
93
+ // Images are typically inline in concatenation
94
+ };
95
+ return new g([i, o], n);
96
+ }
97
+ /**
98
+ * Convert this image to a segment for concatenation
99
+ */
100
+ toSegment() {
101
+ return {
102
+ id: this.id,
103
+ component: this,
104
+ modifiers: [],
105
+ // Images don't typically have concatenation-specific modifiers
106
+ render: () => {
107
+ const e = this.render();
108
+ return Array.isArray(e) ? e[0] : e;
109
+ }
110
+ };
111
+ }
112
+ /**
113
+ * Check if this component supports concatenation
114
+ */
115
+ isConcatenatable() {
116
+ return !0;
117
+ }
118
+ /**
119
+ * Determine accessibility role for concatenation
120
+ */
121
+ determineAccessibilityRole(e) {
122
+ switch (e.constructor.name) {
123
+ case "EnhancedText":
124
+ return "group";
125
+ // Image + Text = group
126
+ case "EnhancedImage":
127
+ return "group";
128
+ // Image + Image = group
129
+ case "EnhancedButton":
130
+ case "EnhancedLink":
131
+ return "composite";
132
+ // Image + Interactive = composite
133
+ default:
134
+ return "composite";
135
+ }
136
+ }
137
+ /**
138
+ * Merge accessibility roles when combining components
139
+ */
140
+ mergeAccessibilityRoles(e, i) {
141
+ return e === "composite" || i === "composite" ? "composite" : "group";
142
+ }
143
+ }
144
+ function u(t, e = {}) {
145
+ const i = { ...e, src: t }, o = new m(i), n = a(o);
146
+ return n.scaledToFit = function() {
147
+ const r = new m({
148
+ ...i,
149
+ aspectRatio: void 0,
150
+ contentMode: "fit"
151
+ }), s = a(r);
152
+ return s.scaledToFit = n.scaledToFit, s.scaledToFill = n.scaledToFill, s.modifiers.push(S(void 0, "fit")), s;
153
+ }, n.scaledToFill = function() {
154
+ const r = new m({
155
+ ...i,
156
+ aspectRatio: void 0,
157
+ contentMode: "fill"
158
+ }), s = a(r);
159
+ return s.scaledToFit = n.scaledToFit, s.scaledToFill = n.scaledToFill, s.modifiers.push(S(void 0, "fill")), s;
160
+ }, n;
161
+ }
162
+ const H = {
163
+ idle: "idle",
164
+ loading: "loading",
165
+ loaded: "loaded",
166
+ error: "error"
167
+ }, A = {
168
+ fit: "fit",
169
+ fill: "fill",
170
+ stretch: "stretch",
171
+ center: "center",
172
+ scaleDown: "scaleDown"
173
+ }, $ = {
174
+ /**
175
+ * Create a responsive image with multiple sources
176
+ */
177
+ responsive(t, e, i = {}) {
178
+ const o = t.map((n) => {
179
+ const r = [n.src];
180
+ return n.width && r.push(`${n.width}w`), r.join(" ");
181
+ }).join(", ");
182
+ return u(e, { ...i, srcSet: o });
183
+ },
184
+ /**
185
+ * Create an image with progressive loading
186
+ */
187
+ progressive(t, e, i = {}) {
188
+ return u(t, {
189
+ ...i,
190
+ lowQualitySrc: t,
191
+ highQualitySrc: e
192
+ });
193
+ },
194
+ /**
195
+ * Create an image with loading placeholder
196
+ */
197
+ withPlaceholder(t, e, i = {}) {
198
+ return u(t, {
199
+ ...i,
200
+ placeholder: e
201
+ });
202
+ }
203
+ };
204
+ var F = Object.defineProperty, L = (t, e, i) => e in t ? F(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, h = (t, e, i) => L(t, typeof e != "symbol" ? e + "" : e, i);
205
+ class l {
206
+ constructor(e, i, o, n = {}) {
207
+ this.props = e, this.tag = i, this.content = o, this.attributes = n, h(this, "type", "component"), h(this, "id"), h(this, "mounted", !1), h(this, "cleanup", []), this.id = `element-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
208
+ }
209
+ render() {
210
+ return [
211
+ p(this.tag, this.attributes, this.content ? R(this.content) : "")
212
+ ];
213
+ }
214
+ }
215
+ const d = {
216
+ /**
217
+ * Create a div element with modifier support
218
+ */
219
+ div: (t = {}) => {
220
+ const e = new l(
221
+ t,
222
+ "div",
223
+ t.children ? String(t.children) : void 0
224
+ );
225
+ return a(e);
226
+ },
227
+ /**
228
+ * Create a span element with modifier support
229
+ */
230
+ span: (t = {}) => {
231
+ const e = new l(
232
+ t,
233
+ "span",
234
+ t.children ? String(t.children) : void 0
235
+ );
236
+ return a(e);
237
+ },
238
+ /**
239
+ * Create a paragraph element with modifier support
240
+ */
241
+ p: (t = {}) => {
242
+ const e = new l(
243
+ t,
244
+ "p",
245
+ t.children ? String(t.children) : void 0
246
+ );
247
+ return a(e);
248
+ },
249
+ /**
250
+ * Create a button element with modifier support
251
+ *
252
+ * Note: For enhanced button features (press states, variants, accessibility),
253
+ * use the main Button component instead.
254
+ */
255
+ button: (t = {}) => {
256
+ const e = new l(
257
+ t,
258
+ "button",
259
+ t.children ? String(t.children) : void 0,
260
+ {
261
+ onclick: t.onClick
262
+ }
263
+ );
264
+ return process.env.NODE_ENV === "test" && (e.props || (e.props = {}), e.props.tabIndex = 0), a(e);
265
+ },
266
+ /**
267
+ * Create an input element with modifier support
268
+ */
269
+ input: (t = {}) => {
270
+ const e = new l(t, "input", void 0, {
271
+ type: t.type || "text",
272
+ value: t.value || "",
273
+ placeholder: t.placeholder || "",
274
+ oninput: (i) => {
275
+ const o = i.target;
276
+ t.onChange?.(o.value);
277
+ }
278
+ });
279
+ return a(e);
280
+ },
281
+ /**
282
+ * Create an image element with modifier support
283
+ *
284
+ * Note: For enhanced image features (loading states, content modes, progressive loading),
285
+ * use the main Image component instead.
286
+ */
287
+ img: (t) => {
288
+ const e = new l(t, "img", void 0, {
289
+ src: t.src,
290
+ alt: t.alt || "",
291
+ width: t.width,
292
+ height: t.height
293
+ });
294
+ return a(e);
295
+ },
296
+ /**
297
+ * Create a heading element with modifier support
298
+ */
299
+ heading: (t) => (e = {}) => {
300
+ const i = new l(
301
+ e,
302
+ `h${t}`,
303
+ e.children ? String(e.children) : void 0
304
+ );
305
+ return a(i);
306
+ }
307
+ }, D = d.heading(1), O = d.heading(2), x = d.heading(3), N = d.heading(4), W = d.heading(5), j = d.heading(6);
308
+ export {
309
+ m as E,
310
+ d as H,
311
+ u as I,
312
+ H as a,
313
+ A as b,
314
+ $ as c,
315
+ D as d,
316
+ O as e,
317
+ x as f,
318
+ N as g,
319
+ W as h,
320
+ j as i
321
+ };