@tachui/modifiers 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 (131) hide show
  1. package/LICENSE +363 -0
  2. package/README.md +322 -0
  3. package/dist/allows-hit-testing-DscPrcOw.js +464 -0
  4. package/dist/allows-hit-testing-DscPrcOw.js.map +1 -0
  5. package/dist/appearance/background.d.ts +38 -0
  6. package/dist/appearance/background.d.ts.map +1 -0
  7. package/dist/appearance/border.d.ts +78 -0
  8. package/dist/appearance/border.d.ts.map +1 -0
  9. package/dist/appearance/clip-shape.d.ts +23 -0
  10. package/dist/appearance/clip-shape.d.ts.map +1 -0
  11. package/dist/appearance/clipped.d.ts +21 -0
  12. package/dist/appearance/clipped.d.ts.map +1 -0
  13. package/dist/appearance/foreground.d.ts +19 -0
  14. package/dist/appearance/foreground.d.ts.map +1 -0
  15. package/dist/appearance/index.d.ts +11 -0
  16. package/dist/appearance/index.d.ts.map +1 -0
  17. package/dist/appearance/index.js +34 -0
  18. package/dist/appearance/index.js.map +1 -0
  19. package/dist/attributes/aria.d.ts +101 -0
  20. package/dist/attributes/aria.d.ts.map +1 -0
  21. package/dist/attributes/css-properties.d.ts +229 -0
  22. package/dist/attributes/css-properties.d.ts.map +1 -0
  23. package/dist/attributes/html.d.ts +108 -0
  24. package/dist/attributes/html.d.ts.map +1 -0
  25. package/dist/attributes/index.d.ts +12 -0
  26. package/dist/attributes/index.d.ts.map +1 -0
  27. package/dist/base-CkGf4b9G.js +786 -0
  28. package/dist/base-CkGf4b9G.js.map +1 -0
  29. package/dist/base.d.ts +154 -0
  30. package/dist/base.d.ts.map +1 -0
  31. package/dist/base.js +842 -0
  32. package/dist/base.js.map +1 -0
  33. package/dist/basic/base.d.ts +147 -0
  34. package/dist/basic/base.d.ts.map +1 -0
  35. package/dist/basic/index.d.ts +9 -0
  36. package/dist/basic/index.d.ts.map +1 -0
  37. package/dist/basic/margin.d.ts +266 -0
  38. package/dist/basic/margin.d.ts.map +1 -0
  39. package/dist/basic/margin.js +160 -0
  40. package/dist/basic/margin.js.map +1 -0
  41. package/dist/basic/padding.d.ts +258 -0
  42. package/dist/basic/padding.d.ts.map +1 -0
  43. package/dist/basic/padding.js +155 -0
  44. package/dist/basic/padding.js.map +1 -0
  45. package/dist/basic/size.d.ts +113 -0
  46. package/dist/basic/size.d.ts.map +1 -0
  47. package/dist/basic/size.js +78 -0
  48. package/dist/basic/size.js.map +1 -0
  49. package/dist/clipped-CCW8gJqJ.js +282 -0
  50. package/dist/clipped-CCW8gJqJ.js.map +1 -0
  51. package/dist/css-CJEXRr6H.js +124 -0
  52. package/dist/css-CJEXRr6H.js.map +1 -0
  53. package/dist/elements/decorative.d.ts +109 -0
  54. package/dist/elements/decorative.d.ts.map +1 -0
  55. package/dist/elements/index.d.ts +6 -0
  56. package/dist/elements/index.d.ts.map +1 -0
  57. package/dist/elements/pseudo-elements.d.ts +145 -0
  58. package/dist/elements/pseudo-elements.d.ts.map +1 -0
  59. package/dist/font-3qM2Z97N.js +135 -0
  60. package/dist/font-3qM2Z97N.js.map +1 -0
  61. package/dist/index.d.ts +20 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +885 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/interaction/allows-hit-testing.d.ts +31 -0
  66. package/dist/interaction/allows-hit-testing.d.ts.map +1 -0
  67. package/dist/interaction/focusable.d.ts +33 -0
  68. package/dist/interaction/focusable.d.ts.map +1 -0
  69. package/dist/interaction/focused.d.ts +28 -0
  70. package/dist/interaction/focused.d.ts.map +1 -0
  71. package/dist/interaction/index.d.ts +11 -0
  72. package/dist/interaction/index.d.ts.map +1 -0
  73. package/dist/interaction/index.js +32 -0
  74. package/dist/interaction/index.js.map +1 -0
  75. package/dist/interaction/keyboard-shortcut.d.ts +30 -0
  76. package/dist/interaction/keyboard-shortcut.d.ts.map +1 -0
  77. package/dist/interaction/on-continuous-hover.d.ts +41 -0
  78. package/dist/interaction/on-continuous-hover.d.ts.map +1 -0
  79. package/dist/interaction/on-long-press-gesture.d.ts +26 -0
  80. package/dist/interaction/on-long-press-gesture.d.ts.map +1 -0
  81. package/dist/interaction/scroll.d.ts +143 -0
  82. package/dist/interaction/scroll.d.ts.map +1 -0
  83. package/dist/layout/aspect-ratio.d.ts +65 -0
  84. package/dist/layout/aspect-ratio.d.ts.map +1 -0
  85. package/dist/layout/fixed-size.d.ts +49 -0
  86. package/dist/layout/fixed-size.d.ts.map +1 -0
  87. package/dist/layout/flexbox.d.ts +253 -0
  88. package/dist/layout/flexbox.d.ts.map +1 -0
  89. package/dist/layout/index.d.ts +19 -0
  90. package/dist/layout/index.d.ts.map +1 -0
  91. package/dist/layout/index.js +30 -0
  92. package/dist/layout/index.js.map +1 -0
  93. package/dist/layout/offset.d.ts +44 -0
  94. package/dist/layout/offset.d.ts.map +1 -0
  95. package/dist/layout/overlay.d.ts +26 -0
  96. package/dist/layout/overlay.d.ts.map +1 -0
  97. package/dist/layout/position.d.ts +55 -0
  98. package/dist/layout/position.d.ts.map +1 -0
  99. package/dist/layout/scale-effect.d.ts +51 -0
  100. package/dist/layout/scale-effect.d.ts.map +1 -0
  101. package/dist/layout/z-index.d.ts +65 -0
  102. package/dist/layout/z-index.d.ts.map +1 -0
  103. package/dist/overlay-DDiSLprp.js +774 -0
  104. package/dist/overlay-DDiSLprp.js.map +1 -0
  105. package/dist/responsive/index.d.ts +10 -0
  106. package/dist/responsive/index.d.ts.map +1 -0
  107. package/dist/types.d.ts +598 -0
  108. package/dist/types.d.ts.map +1 -0
  109. package/dist/types.js +5 -0
  110. package/dist/types.js.map +1 -0
  111. package/dist/typography/font.d.ts +24 -0
  112. package/dist/typography/font.d.ts.map +1 -0
  113. package/dist/typography/index.d.ts +9 -0
  114. package/dist/typography/index.d.ts.map +1 -0
  115. package/dist/typography/index.js +30 -0
  116. package/dist/typography/index.js.map +1 -0
  117. package/dist/typography/text.d.ts +70 -0
  118. package/dist/typography/text.d.ts.map +1 -0
  119. package/dist/typography/text.js +129 -0
  120. package/dist/typography/text.js.map +1 -0
  121. package/dist/typography/typography.d.ts +52 -0
  122. package/dist/typography/typography.d.ts.map +1 -0
  123. package/dist/utility/css.d.ts +86 -0
  124. package/dist/utility/css.d.ts.map +1 -0
  125. package/dist/utility/index.d.ts +6 -0
  126. package/dist/utility/index.d.ts.map +1 -0
  127. package/dist/utility/index.js +17 -0
  128. package/dist/utility/index.js.map +1 -0
  129. package/dist/utility/utility.d.ts +69 -0
  130. package/dist/utility/utility.d.ts.map +1 -0
  131. package/package.json +117 -0
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Padding Modifier - Best-in-class internal spacing within elements
3
+ *
4
+ * Comprehensive interface for element padding with full SwiftUI compatibility,
5
+ * CSS-in-JS support, reactive values, design system presets, and RTL awareness.
6
+ */
7
+ import type { DOMNode } from '@tachui/core/runtime/types';
8
+ import { BaseModifier } from './base';
9
+ import type { ModifierContext, ReactiveModifierProps } from '@tachui/core/modifiers/types';
10
+ export type PaddingValue = number | string | `${number}px` | `${number}rem` | `${number}em` | `${number}%` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | 'auto';
11
+ export type PaddingOptions = {
12
+ all: PaddingValue;
13
+ vertical?: never;
14
+ horizontal?: never;
15
+ top?: never;
16
+ right?: never;
17
+ bottom?: never;
18
+ left?: never;
19
+ leading?: never;
20
+ trailing?: never;
21
+ } | {
22
+ all?: never;
23
+ vertical: PaddingValue;
24
+ horizontal: PaddingValue;
25
+ top?: never;
26
+ right?: never;
27
+ bottom?: never;
28
+ left?: never;
29
+ leading?: never;
30
+ trailing?: never;
31
+ } | {
32
+ all?: never;
33
+ vertical?: PaddingValue;
34
+ horizontal?: PaddingValue;
35
+ top?: PaddingValue;
36
+ right?: PaddingValue;
37
+ bottom?: PaddingValue;
38
+ left?: PaddingValue;
39
+ leading?: never;
40
+ trailing?: never;
41
+ } | {
42
+ all?: never;
43
+ vertical?: PaddingValue;
44
+ horizontal?: PaddingValue;
45
+ top?: PaddingValue;
46
+ leading?: PaddingValue;
47
+ trailing?: PaddingValue;
48
+ bottom?: PaddingValue;
49
+ right?: never;
50
+ left?: never;
51
+ };
52
+ export type ReactivePaddingOptions = ReactiveModifierProps<PaddingOptions>;
53
+ export declare class PaddingModifier extends BaseModifier<PaddingOptions> {
54
+ readonly type = "padding";
55
+ readonly priority = 45;
56
+ constructor(options: ReactivePaddingOptions);
57
+ apply(_node: DOMNode, context: ModifierContext): DOMNode | undefined;
58
+ private computePaddingStyles;
59
+ }
60
+ /**
61
+ * Create a padding modifier with comprehensive flexibility
62
+ *
63
+ * Best-in-class implementation with full type safety, SwiftUI compatibility,
64
+ * and modern CSS unit support.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * // All sides equal
69
+ * .padding({ all: 16 })
70
+ * .padding(16) // Shorthand
71
+ *
72
+ * // Symmetric spacing
73
+ * .padding({ vertical: 12, horizontal: 8 })
74
+ *
75
+ * // Individual sides with modern CSS units
76
+ * .padding({ top: '1rem', bottom: 16, left: '2vw', right: 12 })
77
+ *
78
+ * // SwiftUI-style leading/trailing
79
+ * .padding({ leading: 16, trailing: 8, vertical: 12 })
80
+ *
81
+ * // Mixed approach with overrides
82
+ * .padding({ horizontal: 16, top: 8, bottom: 24 })
83
+ *
84
+ * // Modern CSS units
85
+ * .padding({ all: '1rem' })
86
+ * .padding({ vertical: '2vh', horizontal: '10vw' })
87
+ * ```
88
+ */
89
+ export declare function padding(options: ReactivePaddingOptions): PaddingModifier;
90
+ export declare function padding(all: PaddingValue): PaddingModifier;
91
+ /**
92
+ * Convenience function for top padding only
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * .paddingTop(16)
97
+ * .paddingTop('1rem')
98
+ * .paddingTop('2vh')
99
+ * ```
100
+ */
101
+ export declare function paddingTop(value: PaddingValue): PaddingModifier;
102
+ /**
103
+ * Convenience function for bottom padding only
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * .paddingBottom(24)
108
+ * .paddingBottom('2rem')
109
+ * ```
110
+ */
111
+ export declare function paddingBottom(value: PaddingValue): PaddingModifier;
112
+ /**
113
+ * Convenience function for left padding only
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * .paddingLeft(12)
118
+ * .paddingLeft('1rem')
119
+ * ```
120
+ */
121
+ export declare function paddingLeft(value: PaddingValue): PaddingModifier;
122
+ /**
123
+ * Convenience function for right padding only
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * .paddingRight(12)
128
+ * .paddingRight('1rem')
129
+ * ```
130
+ */
131
+ export declare function paddingRight(value: PaddingValue): PaddingModifier;
132
+ /**
133
+ * SwiftUI-style leading padding (left in LTR, right in RTL)
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * .paddingLeading(16)
138
+ * .paddingLeading('1rem')
139
+ * ```
140
+ */
141
+ export declare function paddingLeading(value: PaddingValue): PaddingModifier;
142
+ /**
143
+ * SwiftUI-style trailing padding (right in LTR, left in RTL)
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * .paddingTrailing(8)
148
+ * .paddingTrailing('0.5rem')
149
+ * ```
150
+ */
151
+ export declare function paddingTrailing(value: PaddingValue): PaddingModifier;
152
+ /**
153
+ * Convenience function for left and right padding
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * .paddingHorizontal(20)
158
+ * .paddingHorizontal('2rem')
159
+ * .paddingHorizontal('5vw')
160
+ * ```
161
+ */
162
+ export declare function paddingHorizontal(value: PaddingValue): PaddingModifier;
163
+ /**
164
+ * Convenience function for top and bottom padding
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * .paddingVertical(16)
169
+ * .paddingVertical('1rem')
170
+ * .paddingVertical('3vh')
171
+ * ```
172
+ */
173
+ export declare function paddingVertical(value: PaddingValue): PaddingModifier;
174
+ /**
175
+ * Design system padding presets for consistent spacing
176
+ *
177
+ * Based on modern design system principles with t-shirt sizing
178
+ * and semantic naming for common UI patterns.
179
+ */
180
+ export declare const paddingPresets: {
181
+ /**
182
+ * Extra small padding (4px) - For tight spacing
183
+ */
184
+ readonly xs: () => PaddingModifier;
185
+ /**
186
+ * Small padding (8px) - For compact components
187
+ */
188
+ readonly sm: () => PaddingModifier;
189
+ /**
190
+ * Medium padding (12px) - Default comfortable spacing
191
+ */
192
+ readonly md: () => PaddingModifier;
193
+ /**
194
+ * Large padding (16px) - For prominent components
195
+ */
196
+ readonly lg: () => PaddingModifier;
197
+ /**
198
+ * Extra large padding (24px) - For emphasis
199
+ */
200
+ readonly xl: () => PaddingModifier;
201
+ /**
202
+ * Extra extra large padding (32px) - For major sections
203
+ */
204
+ readonly xxl: () => PaddingModifier;
205
+ /**
206
+ * Huge padding (48px) - For hero sections
207
+ */
208
+ readonly xxxl: () => PaddingModifier;
209
+ /**
210
+ * Button padding preset (horizontal: 16, vertical: 8)
211
+ * Optimized for interactive elements
212
+ */
213
+ readonly button: () => PaddingModifier;
214
+ /**
215
+ * Small button padding (horizontal: 12, vertical: 6)
216
+ */
217
+ readonly buttonSm: () => PaddingModifier;
218
+ /**
219
+ * Large button padding (horizontal: 24, vertical: 12)
220
+ */
221
+ readonly buttonLg: () => PaddingModifier;
222
+ /**
223
+ * Card padding preset (all: 16)
224
+ * Standard for card-like containers
225
+ */
226
+ readonly card: () => PaddingModifier;
227
+ /**
228
+ * Compact card padding (all: 12)
229
+ */
230
+ readonly cardSm: () => PaddingModifier;
231
+ /**
232
+ * Spacious card padding (all: 24)
233
+ */
234
+ readonly cardLg: () => PaddingModifier;
235
+ /**
236
+ * Section padding preset (horizontal: 20, vertical: 12)
237
+ * For content sections and layout blocks
238
+ */
239
+ readonly section: () => PaddingModifier;
240
+ /**
241
+ * Page padding preset (horizontal: 24, vertical: 16)
242
+ * For top-level page containers
243
+ */
244
+ readonly page: () => PaddingModifier;
245
+ /**
246
+ * Form field padding (horizontal: 12, vertical: 8)
247
+ */
248
+ readonly field: () => PaddingModifier;
249
+ /**
250
+ * Navigation item padding (horizontal: 16, vertical: 8)
251
+ */
252
+ readonly nav: () => PaddingModifier;
253
+ /**
254
+ * List item padding (horizontal: 16, vertical: 12)
255
+ */
256
+ readonly listItem: () => PaddingModifier;
257
+ };
258
+ //# sourceMappingURL=padding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"padding.d.ts","sourceRoot":"","sources":["../../src/basic/padding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACtB,MAAM,8BAA8B,CAAA;AAIrC,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,MAAM,GACN,GAAG,MAAM,IAAI,GACb,GAAG,MAAM,KAAK,GACd,GAAG,MAAM,IAAI,GACb,GAAG,MAAM,GAAG,GACZ,GAAG,MAAM,IAAI,GACb,GAAG,MAAM,IAAI,GACb,GAAG,MAAM,MAAM,GACf,GAAG,MAAM,MAAM,GACf,MAAM,CAAA;AAGV,MAAM,MAAM,cAAc,GACtB;IACE,GAAG,EAAE,YAAY,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,GAAG,CAAC,EAAE,KAAK,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB,GACD;IACE,GAAG,CAAC,EAAE,KAAK,CAAA;IACX,QAAQ,EAAE,YAAY,CAAA;IACtB,UAAU,EAAE,YAAY,CAAA;IACxB,GAAG,CAAC,EAAE,KAAK,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,IAAI,CAAC,EAAE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AAG,EAAE,YAAY,GAAG,eAAe,CAAA;AAU3D;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAElE;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEtE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAKH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEK,CAAA"}
@@ -0,0 +1,155 @@
1
+ var l = Object.defineProperty;
2
+ var f = (t, o, i) => o in t ? l(t, o, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[o] = i;
3
+ var g = (t, o, i) => f(t, typeof o != "symbol" ? o + "" : o, i);
4
+ import { B as c } from "../base-CkGf4b9G.js";
5
+ import { isSignal as u, isComputed as m } from "@tachui/core/reactive";
6
+ class r extends c {
7
+ // Optimized priority for internal spacing (before margin at 50)
8
+ constructor(i) {
9
+ super(i);
10
+ g(this, "type", "padding");
11
+ g(this, "priority", 45);
12
+ }
13
+ apply(i, d) {
14
+ if (!d.element) return;
15
+ const a = this.computePaddingStyles(this.properties);
16
+ this.applyStyles(d.element, a);
17
+ }
18
+ computePaddingStyles(i) {
19
+ const d = {}, a = (n) => u(n) || m(n) ? n : typeof n == "number" ? `${n}px` : n === "auto" ? n : typeof n == "string" ? /^-?\d*\.?\d+(px|rem|em|%|vw|vh|vmin|vmax)$/.test(n) ? n : `${n}px` : String(n);
20
+ if ("all" in i && i.all !== void 0)
21
+ d.padding = a(i.all);
22
+ else {
23
+ if ("vertical" in i && i.vertical !== void 0) {
24
+ const n = a(i.vertical);
25
+ d.paddingTop = n, d.paddingBottom = n;
26
+ }
27
+ if ("horizontal" in i && i.horizontal !== void 0) {
28
+ const n = a(i.horizontal);
29
+ d.paddingLeft = n, d.paddingRight = n;
30
+ }
31
+ "top" in i && i.top !== void 0 && (d.paddingTop = a(i.top)), "right" in i && i.right !== void 0 && (d.paddingRight = a(i.right)), "bottom" in i && i.bottom !== void 0 && (d.paddingBottom = a(i.bottom)), "left" in i && i.left !== void 0 && (d.paddingLeft = a(i.left)), "leading" in i && i.leading !== void 0 && (d.paddingLeft = a(i.leading)), "trailing" in i && i.trailing !== void 0 && (d.paddingRight = a(i.trailing));
32
+ }
33
+ return d;
34
+ }
35
+ }
36
+ function e(t) {
37
+ return typeof t == "number" || typeof t == "string" ? new r({ all: t }) : new r(t);
38
+ }
39
+ function z(t) {
40
+ return new r({ top: t });
41
+ }
42
+ function s(t) {
43
+ return new r({ bottom: t });
44
+ }
45
+ function w(t) {
46
+ return new r({ left: t });
47
+ }
48
+ function b(t) {
49
+ return new r({ right: t });
50
+ }
51
+ function L(t) {
52
+ return new r({ leading: t });
53
+ }
54
+ function S(t) {
55
+ return new r({ trailing: t });
56
+ }
57
+ function R(t) {
58
+ return new r({ horizontal: t });
59
+ }
60
+ function B(t) {
61
+ return new r({ vertical: t });
62
+ }
63
+ const P = {
64
+ /**
65
+ * Extra small padding (4px) - For tight spacing
66
+ */
67
+ xs: () => e(4),
68
+ /**
69
+ * Small padding (8px) - For compact components
70
+ */
71
+ sm: () => e(8),
72
+ /**
73
+ * Medium padding (12px) - Default comfortable spacing
74
+ */
75
+ md: () => e(12),
76
+ /**
77
+ * Large padding (16px) - For prominent components
78
+ */
79
+ lg: () => e(16),
80
+ /**
81
+ * Extra large padding (24px) - For emphasis
82
+ */
83
+ xl: () => e(24),
84
+ /**
85
+ * Extra extra large padding (32px) - For major sections
86
+ */
87
+ xxl: () => e(32),
88
+ /**
89
+ * Huge padding (48px) - For hero sections
90
+ */
91
+ xxxl: () => e(48),
92
+ // Semantic presets for common UI patterns
93
+ /**
94
+ * Button padding preset (horizontal: 16, vertical: 8)
95
+ * Optimized for interactive elements
96
+ */
97
+ button: () => e({ horizontal: 16, vertical: 8 }),
98
+ /**
99
+ * Small button padding (horizontal: 12, vertical: 6)
100
+ */
101
+ buttonSm: () => e({ horizontal: 12, vertical: 6 }),
102
+ /**
103
+ * Large button padding (horizontal: 24, vertical: 12)
104
+ */
105
+ buttonLg: () => e({ horizontal: 24, vertical: 12 }),
106
+ /**
107
+ * Card padding preset (all: 16)
108
+ * Standard for card-like containers
109
+ */
110
+ card: () => e(16),
111
+ /**
112
+ * Compact card padding (all: 12)
113
+ */
114
+ cardSm: () => e(12),
115
+ /**
116
+ * Spacious card padding (all: 24)
117
+ */
118
+ cardLg: () => e(24),
119
+ /**
120
+ * Section padding preset (horizontal: 20, vertical: 12)
121
+ * For content sections and layout blocks
122
+ */
123
+ section: () => e({ horizontal: 20, vertical: 12 }),
124
+ /**
125
+ * Page padding preset (horizontal: 24, vertical: 16)
126
+ * For top-level page containers
127
+ */
128
+ page: () => e({ horizontal: 24, vertical: 16 }),
129
+ /**
130
+ * Form field padding (horizontal: 12, vertical: 8)
131
+ */
132
+ field: () => e({ horizontal: 12, vertical: 8 }),
133
+ /**
134
+ * Navigation item padding (horizontal: 16, vertical: 8)
135
+ */
136
+ nav: () => e({ horizontal: 16, vertical: 8 }),
137
+ /**
138
+ * List item padding (horizontal: 16, vertical: 12)
139
+ */
140
+ listItem: () => e({ horizontal: 16, vertical: 12 })
141
+ };
142
+ export {
143
+ r as PaddingModifier,
144
+ e as padding,
145
+ s as paddingBottom,
146
+ R as paddingHorizontal,
147
+ L as paddingLeading,
148
+ w as paddingLeft,
149
+ P as paddingPresets,
150
+ b as paddingRight,
151
+ z as paddingTop,
152
+ S as paddingTrailing,
153
+ B as paddingVertical
154
+ };
155
+ //# sourceMappingURL=padding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"padding.js","sources":["../../src/basic/padding.ts"],"sourcesContent":["/**\n * Padding Modifier - Best-in-class internal spacing within elements\n *\n * Comprehensive interface for element padding with full SwiftUI compatibility,\n * CSS-in-JS support, reactive values, design system presets, and RTL awareness.\n */\n\nimport type { DOMNode } from '@tachui/core/runtime/types'\nimport { BaseModifier } from './base'\nimport type {\n ModifierContext,\n ReactiveModifierProps,\n} from '@tachui/core/modifiers/types'\nimport { isSignal, isComputed } from '@tachui/core/reactive'\n\n// Comprehensive CSS-compatible padding values including modern CSS units\nexport type PaddingValue =\n | number\n | string\n | `${number}px`\n | `${number}rem`\n | `${number}em`\n | `${number}%`\n | `${number}vw`\n | `${number}vh`\n | `${number}vmin`\n | `${number}vmax`\n | 'auto'\n\n// Advanced type-safe options with comprehensive conflict prevention and SwiftUI compatibility\nexport type PaddingOptions =\n | {\n all: PaddingValue\n vertical?: never\n horizontal?: never\n top?: never\n right?: never\n bottom?: never\n left?: never\n leading?: never\n trailing?: never\n }\n | {\n all?: never\n vertical: PaddingValue\n horizontal: PaddingValue\n top?: never\n right?: never\n bottom?: never\n left?: never\n leading?: never\n trailing?: never\n }\n | {\n all?: never\n vertical?: PaddingValue\n horizontal?: PaddingValue\n top?: PaddingValue\n right?: PaddingValue\n bottom?: PaddingValue\n left?: PaddingValue\n leading?: never\n trailing?: never\n }\n | {\n all?: never\n vertical?: PaddingValue\n horizontal?: PaddingValue\n top?: PaddingValue\n leading?: PaddingValue\n trailing?: PaddingValue\n bottom?: PaddingValue\n right?: never\n left?: never\n }\n\nexport type ReactivePaddingOptions = ReactiveModifierProps<PaddingOptions>\n\nexport class PaddingModifier extends BaseModifier<PaddingOptions> {\n readonly type = 'padding'\n readonly priority = 45 // Optimized priority for internal spacing (before margin at 50)\n\n constructor(options: ReactivePaddingOptions) {\n // Enhanced reactive value handling\n super(options as unknown as PaddingOptions)\n }\n\n apply(_node: DOMNode, context: ModifierContext): DOMNode | undefined {\n if (!context.element) return\n\n const styles = this.computePaddingStyles(this.properties)\n this.applyStyles(context.element, styles)\n\n return undefined\n }\n\n private computePaddingStyles(props: PaddingOptions) {\n const styles: Record<string, any> = {}\n\n // Enhanced value formatter with comprehensive CSS unit support\n // Now handles reactive signals properly by passing them through unchanged\n const formatValue = (value: PaddingValue): any => {\n // Pass reactive signals through directly to applyStyles\n if (isSignal(value) || isComputed(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return `${value}px`\n }\n if (value === 'auto') return value\n if (typeof value === 'string') {\n // Validate and normalize CSS values\n const cssValueRegex = /^-?\\d*\\.?\\d+(px|rem|em|%|vw|vh|vmin|vmax)$/\n return cssValueRegex.test(value) ? value : `${value}px`\n }\n return String(value)\n }\n\n // Priority-based application with enhanced logic\n if ('all' in props && props.all !== undefined) {\n // All sides - highest priority, most efficient CSS\n styles.padding = formatValue(props.all)\n } else {\n // Handle shorthand properties with optimal CSS generation\n if ('vertical' in props && props.vertical !== undefined) {\n const value = formatValue(props.vertical)\n styles.paddingTop = value\n styles.paddingBottom = value\n }\n if ('horizontal' in props && props.horizontal !== undefined) {\n const value = formatValue(props.horizontal)\n styles.paddingLeft = value\n styles.paddingRight = value\n }\n\n // Individual sides override shorthand (maintain specificity)\n if ('top' in props && props.top !== undefined) {\n styles.paddingTop = formatValue(props.top)\n }\n if ('right' in props && props.right !== undefined) {\n styles.paddingRight = formatValue(props.right)\n }\n if ('bottom' in props && props.bottom !== undefined) {\n styles.paddingBottom = formatValue(props.bottom)\n }\n if ('left' in props && props.left !== undefined) {\n styles.paddingLeft = formatValue(props.left)\n }\n\n // SwiftUI-style leading/trailing with RTL awareness\n // TODO: Add RTL detection for proper leading/trailing mapping\n if ('leading' in props && props.leading !== undefined) {\n styles.paddingLeft = formatValue(props.leading) // LTR assumption\n }\n if ('trailing' in props && props.trailing !== undefined) {\n styles.paddingRight = formatValue(props.trailing) // LTR assumption\n }\n }\n\n return styles\n }\n}\n\n/**\n * Create a padding modifier with comprehensive flexibility\n *\n * Best-in-class implementation with full type safety, SwiftUI compatibility,\n * and modern CSS unit support.\n *\n * @example\n * ```typescript\n * // All sides equal\n * .padding({ all: 16 })\n * .padding(16) // Shorthand\n *\n * // Symmetric spacing\n * .padding({ vertical: 12, horizontal: 8 })\n *\n * // Individual sides with modern CSS units\n * .padding({ top: '1rem', bottom: 16, left: '2vw', right: 12 })\n *\n * // SwiftUI-style leading/trailing\n * .padding({ leading: 16, trailing: 8, vertical: 12 })\n *\n * // Mixed approach with overrides\n * .padding({ horizontal: 16, top: 8, bottom: 24 })\n *\n * // Modern CSS units\n * .padding({ all: '1rem' })\n * .padding({ vertical: '2vh', horizontal: '10vw' })\n * ```\n */\nexport function padding(options: ReactivePaddingOptions): PaddingModifier\nexport function padding(all: PaddingValue): PaddingModifier\nexport function padding(\n optionsOrAll: ReactivePaddingOptions | PaddingValue\n): PaddingModifier {\n if (typeof optionsOrAll === 'number' || typeof optionsOrAll === 'string') {\n return new PaddingModifier({ all: optionsOrAll })\n }\n return new PaddingModifier(optionsOrAll)\n}\n\n/**\n * Convenience function for top padding only\n *\n * @example\n * ```typescript\n * .paddingTop(16)\n * .paddingTop('1rem')\n * .paddingTop('2vh')\n * ```\n */\nexport function paddingTop(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ top: value })\n}\n\n/**\n * Convenience function for bottom padding only\n *\n * @example\n * ```typescript\n * .paddingBottom(24)\n * .paddingBottom('2rem')\n * ```\n */\nexport function paddingBottom(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ bottom: value })\n}\n\n/**\n * Convenience function for left padding only\n *\n * @example\n * ```typescript\n * .paddingLeft(12)\n * .paddingLeft('1rem')\n * ```\n */\nexport function paddingLeft(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ left: value })\n}\n\n/**\n * Convenience function for right padding only\n *\n * @example\n * ```typescript\n * .paddingRight(12)\n * .paddingRight('1rem')\n * ```\n */\nexport function paddingRight(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ right: value })\n}\n\n/**\n * SwiftUI-style leading padding (left in LTR, right in RTL)\n *\n * @example\n * ```typescript\n * .paddingLeading(16)\n * .paddingLeading('1rem')\n * ```\n */\nexport function paddingLeading(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ leading: value })\n}\n\n/**\n * SwiftUI-style trailing padding (right in LTR, left in RTL)\n *\n * @example\n * ```typescript\n * .paddingTrailing(8)\n * .paddingTrailing('0.5rem')\n * ```\n */\nexport function paddingTrailing(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ trailing: value })\n}\n\n/**\n * Convenience function for left and right padding\n *\n * @example\n * ```typescript\n * .paddingHorizontal(20)\n * .paddingHorizontal('2rem')\n * .paddingHorizontal('5vw')\n * ```\n */\nexport function paddingHorizontal(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ horizontal: value })\n}\n\n/**\n * Convenience function for top and bottom padding\n *\n * @example\n * ```typescript\n * .paddingVertical(16)\n * .paddingVertical('1rem')\n * .paddingVertical('3vh')\n * ```\n */\nexport function paddingVertical(value: PaddingValue): PaddingModifier {\n return new PaddingModifier({ vertical: value })\n}\n\n/**\n * Design system padding presets for consistent spacing\n *\n * Based on modern design system principles with t-shirt sizing\n * and semantic naming for common UI patterns.\n */\nexport const paddingPresets = {\n /**\n * Extra small padding (4px) - For tight spacing\n */\n xs: () => padding(4),\n\n /**\n * Small padding (8px) - For compact components\n */\n sm: () => padding(8),\n\n /**\n * Medium padding (12px) - Default comfortable spacing\n */\n md: () => padding(12),\n\n /**\n * Large padding (16px) - For prominent components\n */\n lg: () => padding(16),\n\n /**\n * Extra large padding (24px) - For emphasis\n */\n xl: () => padding(24),\n\n /**\n * Extra extra large padding (32px) - For major sections\n */\n xxl: () => padding(32),\n\n /**\n * Huge padding (48px) - For hero sections\n */\n xxxl: () => padding(48),\n\n // Semantic presets for common UI patterns\n\n /**\n * Button padding preset (horizontal: 16, vertical: 8)\n * Optimized for interactive elements\n */\n button: () => padding({ horizontal: 16, vertical: 8 }),\n\n /**\n * Small button padding (horizontal: 12, vertical: 6)\n */\n buttonSm: () => padding({ horizontal: 12, vertical: 6 }),\n\n /**\n * Large button padding (horizontal: 24, vertical: 12)\n */\n buttonLg: () => padding({ horizontal: 24, vertical: 12 }),\n\n /**\n * Card padding preset (all: 16)\n * Standard for card-like containers\n */\n card: () => padding(16),\n\n /**\n * Compact card padding (all: 12)\n */\n cardSm: () => padding(12),\n\n /**\n * Spacious card padding (all: 24)\n */\n cardLg: () => padding(24),\n\n /**\n * Section padding preset (horizontal: 20, vertical: 12)\n * For content sections and layout blocks\n */\n section: () => padding({ horizontal: 20, vertical: 12 }),\n\n /**\n * Page padding preset (horizontal: 24, vertical: 16)\n * For top-level page containers\n */\n page: () => padding({ horizontal: 24, vertical: 16 }),\n\n /**\n * Form field padding (horizontal: 12, vertical: 8)\n */\n field: () => padding({ horizontal: 12, vertical: 8 }),\n\n /**\n * Navigation item padding (horizontal: 16, vertical: 8)\n */\n nav: () => padding({ horizontal: 16, vertical: 8 }),\n\n /**\n * List item padding (horizontal: 16, vertical: 12)\n */\n listItem: () => padding({ horizontal: 16, vertical: 12 }),\n} as const\n\n// Types are exported above - avoiding duplicate exports\n"],"names":["PaddingModifier","BaseModifier","options","__publicField","_node","context","styles","props","formatValue","value","isSignal","isComputed","padding","optionsOrAll","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingLeading","paddingTrailing","paddingHorizontal","paddingVertical","paddingPresets"],"mappings":";;;;;AA8EO,MAAMA,UAAwBC,EAA6B;AAAA;AAAA,EAIhE,YAAYC,GAAiC;AAE3C,UAAMA,CAAoC;AALnC,IAAAC,EAAA,cAAO;AACP,IAAAA,EAAA,kBAAW;AAAA,EAKpB;AAAA,EAEA,MAAMC,GAAgBC,GAA+C;AACnE,QAAI,CAACA,EAAQ,QAAS;AAEtB,UAAMC,IAAS,KAAK,qBAAqB,KAAK,UAAU;AACxD,SAAK,YAAYD,EAAQ,SAASC,CAAM;AAAA,EAG1C;AAAA,EAEQ,qBAAqBC,GAAuB;AAClD,UAAMD,IAA8B,CAAA,GAI9BE,IAAc,CAACC,MAEfC,EAASD,CAAK,KAAKE,EAAWF,CAAK,IAC9BA,IAGL,OAAOA,KAAU,WACZ,GAAGA,CAAK,OAEbA,MAAU,SAAeA,IACzB,OAAOA,KAAU,WAEG,6CACD,KAAKA,CAAK,IAAIA,IAAQ,GAAGA,CAAK,OAE9C,OAAOA,CAAK;AAIrB,QAAI,SAASF,KAASA,EAAM,QAAQ;AAElC,MAAAD,EAAO,UAAUE,EAAYD,EAAM,GAAG;AAAA,SACjC;AAEL,UAAI,cAAcA,KAASA,EAAM,aAAa,QAAW;AACvD,cAAME,IAAQD,EAAYD,EAAM,QAAQ;AACxC,QAAAD,EAAO,aAAaG,GACpBH,EAAO,gBAAgBG;AAAA,MACzB;AACA,UAAI,gBAAgBF,KAASA,EAAM,eAAe,QAAW;AAC3D,cAAME,IAAQD,EAAYD,EAAM,UAAU;AAC1C,QAAAD,EAAO,cAAcG,GACrBH,EAAO,eAAeG;AAAA,MACxB;AAGA,MAAI,SAASF,KAASA,EAAM,QAAQ,WAClCD,EAAO,aAAaE,EAAYD,EAAM,GAAG,IAEvC,WAAWA,KAASA,EAAM,UAAU,WACtCD,EAAO,eAAeE,EAAYD,EAAM,KAAK,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, min/max dimensions
3
+ *
4
+ * Provides a unified interface for setting element dimensions
5
+ * with support for SwiftUI-style infinity constants.
6
+ */
7
+ import type { DOMNode } from '@tachui/core/runtime/types';
8
+ import type { Dimension } from '@tachui/core/constants/layout';
9
+ import { BaseModifier } from './base';
10
+ import type { ModifierContext, ReactiveModifierProps } from '@tachui/core/modifiers/types';
11
+ export interface SizeOptions {
12
+ width?: Dimension;
13
+ height?: Dimension;
14
+ minWidth?: Dimension;
15
+ maxWidth?: Dimension;
16
+ minHeight?: Dimension;
17
+ maxHeight?: Dimension;
18
+ }
19
+ export type ReactiveSizeOptions = ReactiveModifierProps<SizeOptions>;
20
+ export declare class SizeModifier extends BaseModifier<SizeOptions> {
21
+ readonly type = "size";
22
+ readonly priority = 80;
23
+ constructor(options: ReactiveSizeOptions);
24
+ apply(_node: DOMNode, context: ModifierContext): DOMNode | undefined;
25
+ private computeSizeStyles;
26
+ }
27
+ /**
28
+ * Create a size modifier with multiple dimension properties
29
+ * Now supports SwiftUI-style infinity for responsive layouts
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Set both width and height
34
+ * .size({ width: 200, height: 100 })
35
+ *
36
+ * // Set responsive width with constraints
37
+ * .size({ width: '100%', maxWidth: 800, minWidth: 320 })
38
+ *
39
+ * // SwiftUI-style infinity support
40
+ * .size({ width: infinity, height: 200 })
41
+ * .size({ maxWidth: infinity, maxHeight: infinity })
42
+ * ```
43
+ */
44
+ export declare function size(options: ReactiveSizeOptions): SizeModifier;
45
+ /**
46
+ * Convenience function for setting width only
47
+ * Supports infinity for fill-available behavior
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * .width('100%')
52
+ * .width(280)
53
+ * .width(infinity) // Fill available space
54
+ * ```
55
+ */
56
+ export declare function width(value: Dimension): SizeModifier;
57
+ /**
58
+ * Convenience function for setting height only
59
+ * Supports infinity for fill-available behavior
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * .height('100vh')
64
+ * .height(64)
65
+ * .height(infinity) // Fill available space
66
+ * ```
67
+ */
68
+ export declare function height(value: Dimension): SizeModifier;
69
+ /**
70
+ * Convenience function for setting max-width only
71
+ * Supports infinity to remove width constraints
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * .maxWidth(800)
76
+ * .maxWidth('100%')
77
+ * .maxWidth(infinity) // Remove width constraints
78
+ * ```
79
+ */
80
+ export declare function maxWidth(value: Dimension): SizeModifier;
81
+ /**
82
+ * Convenience function for setting min-width only
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * .minWidth(320)
87
+ * .minWidth('50%')
88
+ * ```
89
+ */
90
+ export declare function minWidth(value: Dimension): SizeModifier;
91
+ /**
92
+ * Convenience function for setting max-height only
93
+ * Supports infinity to remove height constraints
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * .maxHeight(600)
98
+ * .maxHeight('80vh')
99
+ * .maxHeight(infinity) // Remove height constraints
100
+ * ```
101
+ */
102
+ export declare function maxHeight(value: Dimension): SizeModifier;
103
+ /**
104
+ * Convenience function for setting min-height only
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * .minHeight(200)
109
+ * .minHeight('30vh')
110
+ * ```
111
+ */
112
+ export declare function minHeight(value: Dimension): SizeModifier;
113
+ //# sourceMappingURL=size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/basic/size.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAM9D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACtB,MAAM,8BAA8B,CAAA;AAErC,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAA;AAEpE,qBAAa,YAAa,SAAQ,YAAY,CAAC,WAAW,CAAC;IACzD,QAAQ,CAAC,IAAI,UAAS;IACtB,QAAQ,CAAC,QAAQ,MAAK;gBAEV,OAAO,EAAE,mBAAmB;IAKxC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,GAAG,SAAS;IASpE,OAAO,CAAC,iBAAiB;CA0D1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAE/D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAEpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAEvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAEvD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAExD;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAExD"}
@@ -0,0 +1,78 @@
1
+ var f = Object.defineProperty;
2
+ var u = (t, h, i) => h in t ? f(t, h, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[h] = i;
3
+ var a = (t, h, i) => u(t, typeof h != "symbol" ? h + "" : h, i);
4
+ import { shouldExpandForInfinity as c, dimensionToCSS as m, isInfinity as s } from "@tachui/core/constants/layout";
5
+ import { B as g } from "../base-CkGf4b9G.js";
6
+ class d extends g {
7
+ // Priority 80 for layout
8
+ constructor(i) {
9
+ super(i);
10
+ a(this, "type", "size");
11
+ a(this, "priority", 80);
12
+ }
13
+ apply(i, n) {
14
+ if (!n.element) return;
15
+ const o = this.computeSizeStyles(this.properties);
16
+ this.applyStyles(n.element, o);
17
+ }
18
+ computeSizeStyles(i) {
19
+ const n = {}, o = c(i);
20
+ if (Object.assign(n, o.cssProps), i.width !== void 0) {
21
+ const e = m(i.width);
22
+ e !== void 0 && !s(i.width) && (n.width = e);
23
+ }
24
+ if (i.height !== void 0) {
25
+ const e = m(i.height);
26
+ e !== void 0 && !s(i.height) && (n.height = e);
27
+ }
28
+ if (i.minWidth !== void 0) {
29
+ const e = m(i.minWidth);
30
+ e !== void 0 && (n.minWidth = e);
31
+ }
32
+ if (i.maxWidth !== void 0 && !s(i.maxWidth)) {
33
+ const e = m(i.maxWidth);
34
+ e !== void 0 && (n.maxWidth = e);
35
+ } else s(i.maxWidth) && (n.maxWidth = "none");
36
+ if (i.minHeight !== void 0) {
37
+ const e = m(i.minHeight);
38
+ e !== void 0 && (n.minHeight = e);
39
+ }
40
+ if (i.maxHeight !== void 0 && !s(i.maxHeight)) {
41
+ const e = m(i.maxHeight);
42
+ e !== void 0 && (n.maxHeight = e);
43
+ } else s(i.maxHeight) && (n.maxHeight = "none");
44
+ return n;
45
+ }
46
+ }
47
+ function v(t) {
48
+ return new d(t);
49
+ }
50
+ function w(t) {
51
+ return new d({ width: t });
52
+ }
53
+ function H(t) {
54
+ return new d({ height: t });
55
+ }
56
+ function W(t) {
57
+ return new d({ maxWidth: t });
58
+ }
59
+ function y(t) {
60
+ return new d({ minWidth: t });
61
+ }
62
+ function S(t) {
63
+ return new d({ maxHeight: t });
64
+ }
65
+ function V(t) {
66
+ return new d({ minHeight: t });
67
+ }
68
+ export {
69
+ d as SizeModifier,
70
+ H as height,
71
+ S as maxHeight,
72
+ W as maxWidth,
73
+ V as minHeight,
74
+ y as minWidth,
75
+ v as size,
76
+ w as width
77
+ };
78
+ //# sourceMappingURL=size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size.js","sources":["../../src/basic/size.ts"],"sourcesContent":["/**\n * Size Modifier - width, height, min/max dimensions\n *\n * Provides a unified interface for setting element dimensions\n * with support for SwiftUI-style infinity constants.\n */\n\nimport type { DOMNode } from '@tachui/core/runtime/types'\nimport type { Dimension } from '@tachui/core/constants/layout'\nimport {\n dimensionToCSS,\n isInfinity,\n shouldExpandForInfinity,\n} from '@tachui/core/constants/layout'\nimport { BaseModifier } from './base'\nimport type {\n ModifierContext,\n ReactiveModifierProps,\n} from '@tachui/core/modifiers/types'\n\nexport interface SizeOptions {\n width?: Dimension\n height?: Dimension\n minWidth?: Dimension\n maxWidth?: Dimension\n minHeight?: Dimension\n maxHeight?: Dimension\n}\n\nexport type ReactiveSizeOptions = ReactiveModifierProps<SizeOptions>\n\nexport class SizeModifier extends BaseModifier<SizeOptions> {\n readonly type = 'size'\n readonly priority = 80 // Priority 80 for layout\n\n constructor(options: ReactiveSizeOptions) {\n // Preserve reactive values; BaseModifier.applyStyles will create effects\n super(options as unknown as SizeOptions)\n }\n\n apply(_node: DOMNode, context: ModifierContext): DOMNode | undefined {\n if (!context.element) return\n\n const styles = this.computeSizeStyles(this.properties)\n this.applyStyles(context.element, styles)\n\n return undefined\n }\n\n private computeSizeStyles(props: SizeOptions) {\n const styles: Record<string, any> = {}\n\n // Check for infinity constraints and apply appropriate flex/size styles\n const infinityResult = shouldExpandForInfinity(props)\n Object.assign(styles, infinityResult.cssProps)\n\n // Convert dimensions to CSS, handling infinity appropriately\n if (props.width !== undefined) {\n const cssValue = dimensionToCSS(props.width)\n if (cssValue !== undefined && !isInfinity(props.width)) {\n styles.width = cssValue\n }\n }\n\n if (props.height !== undefined) {\n const cssValue = dimensionToCSS(props.height)\n if (cssValue !== undefined && !isInfinity(props.height)) {\n styles.height = cssValue\n }\n }\n\n if (props.minWidth !== undefined) {\n const cssValue = dimensionToCSS(props.minWidth)\n if (cssValue !== undefined) {\n styles.minWidth = cssValue\n }\n }\n\n if (props.maxWidth !== undefined && !isInfinity(props.maxWidth)) {\n const cssValue = dimensionToCSS(props.maxWidth)\n if (cssValue !== undefined) {\n styles.maxWidth = cssValue\n }\n } else if (isInfinity(props.maxWidth)) {\n // Remove maxWidth constraint for infinity\n styles.maxWidth = 'none'\n }\n\n if (props.minHeight !== undefined) {\n const cssValue = dimensionToCSS(props.minHeight)\n if (cssValue !== undefined) {\n styles.minHeight = cssValue\n }\n }\n\n if (props.maxHeight !== undefined && !isInfinity(props.maxHeight)) {\n const cssValue = dimensionToCSS(props.maxHeight)\n if (cssValue !== undefined) {\n styles.maxHeight = cssValue\n }\n } else if (isInfinity(props.maxHeight)) {\n // Remove maxHeight constraint for infinity\n styles.maxHeight = 'none'\n }\n\n return styles\n }\n}\n\n/**\n * Create a size modifier with multiple dimension properties\n * Now supports SwiftUI-style infinity for responsive layouts\n *\n * @example\n * ```typescript\n * // Set both width and height\n * .size({ width: 200, height: 100 })\n *\n * // Set responsive width with constraints\n * .size({ width: '100%', maxWidth: 800, minWidth: 320 })\n *\n * // SwiftUI-style infinity support\n * .size({ width: infinity, height: 200 })\n * .size({ maxWidth: infinity, maxHeight: infinity })\n * ```\n */\nexport function size(options: ReactiveSizeOptions): SizeModifier {\n return new SizeModifier(options)\n}\n\n/**\n * Convenience function for setting width only\n * Supports infinity for fill-available behavior\n *\n * @example\n * ```typescript\n * .width('100%')\n * .width(280)\n * .width(infinity) // Fill available space\n * ```\n */\nexport function width(value: Dimension): SizeModifier {\n return new SizeModifier({ width: value })\n}\n\n/**\n * Convenience function for setting height only\n * Supports infinity for fill-available behavior\n *\n * @example\n * ```typescript\n * .height('100vh')\n * .height(64)\n * .height(infinity) // Fill available space\n * ```\n */\nexport function height(value: Dimension): SizeModifier {\n return new SizeModifier({ height: value })\n}\n\n/**\n * Convenience function for setting max-width only\n * Supports infinity to remove width constraints\n *\n * @example\n * ```typescript\n * .maxWidth(800)\n * .maxWidth('100%')\n * .maxWidth(infinity) // Remove width constraints\n * ```\n */\nexport function maxWidth(value: Dimension): SizeModifier {\n return new SizeModifier({ maxWidth: value })\n}\n\n/**\n * Convenience function for setting min-width only\n *\n * @example\n * ```typescript\n * .minWidth(320)\n * .minWidth('50%')\n * ```\n */\nexport function minWidth(value: Dimension): SizeModifier {\n return new SizeModifier({ minWidth: value })\n}\n\n/**\n * Convenience function for setting max-height only\n * Supports infinity to remove height constraints\n *\n * @example\n * ```typescript\n * .maxHeight(600)\n * .maxHeight('80vh')\n * .maxHeight(infinity) // Remove height constraints\n * ```\n */\nexport function maxHeight(value: Dimension): SizeModifier {\n return new SizeModifier({ maxHeight: value })\n}\n\n/**\n * Convenience function for setting min-height only\n *\n * @example\n * ```typescript\n * .minHeight(200)\n * .minHeight('30vh')\n * ```\n */\nexport function minHeight(value: Dimension): SizeModifier {\n return new SizeModifier({ minHeight: value })\n}\n"],"names":["SizeModifier","BaseModifier","options","__publicField","_node","context","styles","props","infinityResult","shouldExpandForInfinity","cssValue","dimensionToCSS","isInfinity","size","width","value","height","maxWidth","minWidth","maxHeight","minHeight"],"mappings":";;;;;AA+BO,MAAMA,UAAqBC,EAA0B;AAAA;AAAA,EAI1D,YAAYC,GAA8B;AAExC,UAAMA,CAAiC;AALhC,IAAAC,EAAA,cAAO;AACP,IAAAA,EAAA,kBAAW;AAAA,EAKpB;AAAA,EAEA,MAAMC,GAAgBC,GAA+C;AACnE,QAAI,CAACA,EAAQ,QAAS;AAEtB,UAAMC,IAAS,KAAK,kBAAkB,KAAK,UAAU;AACrD,SAAK,YAAYD,EAAQ,SAASC,CAAM;AAAA,EAG1C;AAAA,EAEQ,kBAAkBC,GAAoB;AAC5C,UAAMD,IAA8B,CAAA,GAG9BE,IAAiBC,EAAwBF,CAAK;AAIpD,QAHA,OAAO,OAAOD,GA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