@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,266 @@
1
+ /**
2
+ * Margin Modifier - Best-in-class external spacing around elements
3
+ *
4
+ * Comprehensive interface for element margins with full SwiftUI compatibility,
5
+ * CSS-in-JS support, reactive values, design system presets, and RTL awareness.
6
+ */
7
+ export type MarginValue = number | string | `${number}px` | `${number}rem` | `${number}em` | `${number}%` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | 'auto';
8
+ export type MarginOptions = {
9
+ all: MarginValue;
10
+ vertical?: never;
11
+ horizontal?: never;
12
+ top?: never;
13
+ right?: never;
14
+ bottom?: never;
15
+ left?: never;
16
+ leading?: never;
17
+ trailing?: never;
18
+ } | {
19
+ all?: never;
20
+ vertical: MarginValue;
21
+ horizontal: MarginValue;
22
+ top?: never;
23
+ right?: never;
24
+ bottom?: never;
25
+ left?: never;
26
+ leading?: never;
27
+ trailing?: never;
28
+ } | {
29
+ all?: never;
30
+ vertical?: MarginValue;
31
+ horizontal?: MarginValue;
32
+ top?: MarginValue;
33
+ right?: MarginValue;
34
+ bottom?: MarginValue;
35
+ left?: MarginValue;
36
+ leading?: never;
37
+ trailing?: never;
38
+ } | {
39
+ all?: never;
40
+ vertical?: MarginValue;
41
+ horizontal?: MarginValue;
42
+ top?: MarginValue;
43
+ leading?: MarginValue;
44
+ trailing?: MarginValue;
45
+ bottom?: MarginValue;
46
+ right?: never;
47
+ left?: never;
48
+ };
49
+ import type { DOMNode } from '@tachui/core/runtime/types';
50
+ import { BaseModifier } from './base';
51
+ import type { ModifierContext, ReactiveModifierProps } from '@tachui/core/modifiers/types';
52
+ export type ReactiveMarginOptions = ReactiveModifierProps<MarginOptions>;
53
+ export declare class MarginModifier extends BaseModifier<MarginOptions> {
54
+ readonly type = "margin";
55
+ readonly priority = 50;
56
+ constructor(options: ReactiveMarginOptions);
57
+ apply(_node: DOMNode, context: ModifierContext): DOMNode | undefined;
58
+ private computeMarginStyles;
59
+ }
60
+ /**
61
+ * Create a margin 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
+ * .margin({ all: 16 })
70
+ * .margin(16) // Shorthand
71
+ * .margin('auto') // Center horizontally
72
+ *
73
+ * // Symmetric spacing
74
+ * .margin({ vertical: 12, horizontal: 8 })
75
+ * .margin({ vertical: 30, horizontal: 'auto' })
76
+ *
77
+ * // Individual sides with modern CSS units
78
+ * .margin({ top: '1rem', bottom: 16, left: '2vw', right: 12 })
79
+ *
80
+ * // SwiftUI-style leading/trailing
81
+ * .margin({ leading: 16, trailing: 8, vertical: 12 })
82
+ *
83
+ * // Mixed approach with overrides
84
+ * .margin({ horizontal: 16, top: 8, bottom: 24 })
85
+ *
86
+ * // Modern CSS units
87
+ * .margin({ all: '1rem' })
88
+ * .margin({ vertical: '2vh', horizontal: 'auto' })
89
+ * ```
90
+ */
91
+ export declare function margin(options: ReactiveMarginOptions): MarginModifier;
92
+ export declare function margin(all: MarginValue): MarginModifier;
93
+ /**
94
+ * Convenience function for top margin only
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * .marginTop(16)
99
+ * .marginTop('1rem')
100
+ * .marginTop('2vh')
101
+ * ```
102
+ */
103
+ export declare function marginTop(value: MarginValue): MarginModifier;
104
+ /**
105
+ * Convenience function for bottom margin only
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * .marginBottom(24)
110
+ * .marginBottom('2rem')
111
+ * ```
112
+ */
113
+ export declare function marginBottom(value: MarginValue): MarginModifier;
114
+ /**
115
+ * Convenience function for left margin only
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * .marginLeft(12)
120
+ * .marginLeft('1rem')
121
+ * ```
122
+ */
123
+ export declare function marginLeft(value: MarginValue): MarginModifier;
124
+ /**
125
+ * Convenience function for right margin only
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * .marginRight(12)
130
+ * .marginRight('1rem')
131
+ * ```
132
+ */
133
+ export declare function marginRight(value: MarginValue): MarginModifier;
134
+ /**
135
+ * SwiftUI-style leading margin (left in LTR, right in RTL)
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * .marginLeading(16)
140
+ * .marginLeading('1rem')
141
+ * ```
142
+ */
143
+ export declare function marginLeading(value: MarginValue): MarginModifier;
144
+ /**
145
+ * SwiftUI-style trailing margin (right in LTR, left in RTL)
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * .marginTrailing(8)
150
+ * .marginTrailing('0.5rem')
151
+ * ```
152
+ */
153
+ export declare function marginTrailing(value: MarginValue): MarginModifier;
154
+ /**
155
+ * Convenience function for left and right margin
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * .marginHorizontal(20)
160
+ * .marginHorizontal('2rem')
161
+ * .marginHorizontal('auto') // Center horizontally
162
+ * .marginHorizontal('5vw')
163
+ * ```
164
+ */
165
+ export declare function marginHorizontal(value: MarginValue): MarginModifier;
166
+ /**
167
+ * Convenience function for top and bottom margin
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * .marginVertical(16)
172
+ * .marginVertical('1rem')
173
+ * .marginVertical('3vh')
174
+ * ```
175
+ */
176
+ export declare function marginVertical(value: MarginValue): MarginModifier;
177
+ /**
178
+ * Design system margin presets for consistent spacing
179
+ *
180
+ * Based on modern design system principles with t-shirt sizing
181
+ * and semantic naming for common UI patterns.
182
+ */
183
+ export declare const marginPresets: {
184
+ /**
185
+ * Extra small margin (4px) - For tight spacing
186
+ */
187
+ readonly xs: () => MarginModifier;
188
+ /**
189
+ * Small margin (8px) - For compact components
190
+ */
191
+ readonly sm: () => MarginModifier;
192
+ /**
193
+ * Medium margin (12px) - Default comfortable spacing
194
+ */
195
+ readonly md: () => MarginModifier;
196
+ /**
197
+ * Large margin (16px) - For prominent separation
198
+ */
199
+ readonly lg: () => MarginModifier;
200
+ /**
201
+ * Extra large margin (24px) - For emphasis
202
+ */
203
+ readonly xl: () => MarginModifier;
204
+ /**
205
+ * Extra extra large margin (32px) - For major sections
206
+ */
207
+ readonly xxl: () => MarginModifier;
208
+ /**
209
+ * Huge margin (48px) - For hero sections
210
+ */
211
+ readonly xxxl: () => MarginModifier;
212
+ /**
213
+ * Component separation (vertical: 16, horizontal: 0)
214
+ * For spacing between stacked components
215
+ */
216
+ readonly component: () => MarginModifier;
217
+ /**
218
+ * Section separation (vertical: 24, horizontal: 0)
219
+ * For major content sections
220
+ */
221
+ readonly section: () => MarginModifier;
222
+ /**
223
+ * Page margin (horizontal: auto)
224
+ * For centering page content
225
+ */
226
+ readonly page: () => MarginModifier;
227
+ /**
228
+ * Card margin (all: 16)
229
+ * Standard margin around card components
230
+ */
231
+ readonly card: () => MarginModifier;
232
+ /**
233
+ * Compact card margin (all: 8)
234
+ */
235
+ readonly cardSm: () => MarginModifier;
236
+ /**
237
+ * Spacious card margin (all: 24)
238
+ */
239
+ readonly cardLg: () => MarginModifier;
240
+ /**
241
+ * Button margin (horizontal: 8, vertical: 4)
242
+ * For spacing between inline buttons
243
+ */
244
+ readonly button: () => MarginModifier;
245
+ /**
246
+ * List item margin (vertical: 8, horizontal: 0)
247
+ * For spacing between list items
248
+ */
249
+ readonly listItem: () => MarginModifier;
250
+ /**
251
+ * Form field margin (vertical: 12, horizontal: 0)
252
+ * For spacing between form fields
253
+ */
254
+ readonly field: () => MarginModifier;
255
+ /**
256
+ * Zero margin utility
257
+ * For removing default margins
258
+ */
259
+ readonly none: () => MarginModifier;
260
+ /**
261
+ * Auto margin utility
262
+ * For centering elements
263
+ */
264
+ readonly auto: () => MarginModifier;
265
+ };
266
+ //# sourceMappingURL=margin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"margin.d.ts","sourceRoot":"","sources":["../../src/basic/margin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,WAAW,GACnB,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,aAAa,GACrB;IACE,GAAG,EAAE,WAAW,CAAA;IAChB,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,WAAW,CAAA;IACrB,UAAU,EAAE,WAAW,CAAA;IACvB,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,CAAC,EAAE,WAAW,CAAA;IACtB,UAAU,CAAC,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,WAAW,GAAG,cAAc,CAAA;AAUxD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAE5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAE7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAE9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAEhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAEjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAEnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAEjE;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAKH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;CAEK,CAAA"}
@@ -0,0 +1,160 @@
1
+ var l = Object.defineProperty;
2
+ var f = (t, g, i) => g in t ? l(t, g, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[g] = i;
3
+ var m = (t, g, i) => f(t, typeof g != "symbol" ? g + "" : g, i);
4
+ import { B as c } from "../base-CkGf4b9G.js";
5
+ import { isSignal as u, isComputed as d } from "@tachui/core/reactive";
6
+ class o extends c {
7
+ // Optimized priority for external spacing (after padding at 45)
8
+ constructor(i) {
9
+ super(i);
10
+ m(this, "type", "margin");
11
+ m(this, "priority", 50);
12
+ }
13
+ apply(i, r) {
14
+ if (!r.element) return;
15
+ const a = this.computeMarginStyles(this.properties);
16
+ this.applyStyles(r.element, a);
17
+ }
18
+ computeMarginStyles(i) {
19
+ const r = {}, a = (n) => u(n) || d(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
+ r.margin = a(i.all);
22
+ else {
23
+ if ("vertical" in i && i.vertical !== void 0) {
24
+ const n = a(i.vertical);
25
+ r.marginTop = n, r.marginBottom = n;
26
+ }
27
+ if ("horizontal" in i && i.horizontal !== void 0) {
28
+ const n = a(i.horizontal);
29
+ r.marginLeft = n, r.marginRight = n;
30
+ }
31
+ "top" in i && i.top !== void 0 && (r.marginTop = a(i.top)), "right" in i && i.right !== void 0 && (r.marginRight = a(i.right)), "bottom" in i && i.bottom !== void 0 && (r.marginBottom = a(i.bottom)), "left" in i && i.left !== void 0 && (r.marginLeft = a(i.left)), "leading" in i && i.leading !== void 0 && (r.marginLeft = a(i.leading)), "trailing" in i && i.trailing !== void 0 && (r.marginRight = a(i.trailing));
32
+ }
33
+ return r;
34
+ }
35
+ }
36
+ function e(t) {
37
+ return typeof t == "number" || typeof t == "string" ? new o({ all: t }) : new o(t);
38
+ }
39
+ function s(t) {
40
+ return new o({ top: t });
41
+ }
42
+ function w(t) {
43
+ return new o({ bottom: t });
44
+ }
45
+ function z(t) {
46
+ return new o({ left: t });
47
+ }
48
+ function b(t) {
49
+ return new o({ right: t });
50
+ }
51
+ function L(t) {
52
+ return new o({ leading: t });
53
+ }
54
+ function R(t) {
55
+ return new o({ trailing: t });
56
+ }
57
+ function S(t) {
58
+ return new o({ horizontal: t });
59
+ }
60
+ function B(t) {
61
+ return new o({ vertical: t });
62
+ }
63
+ const M = {
64
+ /**
65
+ * Extra small margin (4px) - For tight spacing
66
+ */
67
+ xs: () => e(4),
68
+ /**
69
+ * Small margin (8px) - For compact components
70
+ */
71
+ sm: () => e(8),
72
+ /**
73
+ * Medium margin (12px) - Default comfortable spacing
74
+ */
75
+ md: () => e(12),
76
+ /**
77
+ * Large margin (16px) - For prominent separation
78
+ */
79
+ lg: () => e(16),
80
+ /**
81
+ * Extra large margin (24px) - For emphasis
82
+ */
83
+ xl: () => e(24),
84
+ /**
85
+ * Extra extra large margin (32px) - For major sections
86
+ */
87
+ xxl: () => e(32),
88
+ /**
89
+ * Huge margin (48px) - For hero sections
90
+ */
91
+ xxxl: () => e(48),
92
+ // Semantic presets for common UI patterns
93
+ /**
94
+ * Component separation (vertical: 16, horizontal: 0)
95
+ * For spacing between stacked components
96
+ */
97
+ component: () => e({ vertical: 16, horizontal: 0 }),
98
+ /**
99
+ * Section separation (vertical: 24, horizontal: 0)
100
+ * For major content sections
101
+ */
102
+ section: () => e({ vertical: 24, horizontal: 0 }),
103
+ /**
104
+ * Page margin (horizontal: auto)
105
+ * For centering page content
106
+ */
107
+ page: () => e({ horizontal: "auto" }),
108
+ /**
109
+ * Card margin (all: 16)
110
+ * Standard margin around card components
111
+ */
112
+ card: () => e(16),
113
+ /**
114
+ * Compact card margin (all: 8)
115
+ */
116
+ cardSm: () => e(8),
117
+ /**
118
+ * Spacious card margin (all: 24)
119
+ */
120
+ cardLg: () => e(24),
121
+ /**
122
+ * Button margin (horizontal: 8, vertical: 4)
123
+ * For spacing between inline buttons
124
+ */
125
+ button: () => e({ horizontal: 8, vertical: 4 }),
126
+ /**
127
+ * List item margin (vertical: 8, horizontal: 0)
128
+ * For spacing between list items
129
+ */
130
+ listItem: () => e({ vertical: 8, horizontal: 0 }),
131
+ /**
132
+ * Form field margin (vertical: 12, horizontal: 0)
133
+ * For spacing between form fields
134
+ */
135
+ field: () => e({ vertical: 12, horizontal: 0 }),
136
+ /**
137
+ * Zero margin utility
138
+ * For removing default margins
139
+ */
140
+ none: () => e(0),
141
+ /**
142
+ * Auto margin utility
143
+ * For centering elements
144
+ */
145
+ auto: () => e("auto")
146
+ };
147
+ export {
148
+ o as MarginModifier,
149
+ e as margin,
150
+ w as marginBottom,
151
+ S as marginHorizontal,
152
+ L as marginLeading,
153
+ z as marginLeft,
154
+ M as marginPresets,
155
+ b as marginRight,
156
+ s as marginTop,
157
+ R as marginTrailing,
158
+ B as marginVertical
159
+ };
160
+ //# sourceMappingURL=margin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"margin.js","sources":["../../src/basic/margin.ts"],"sourcesContent":["/**\n * Margin Modifier - Best-in-class external spacing around elements\n *\n * Comprehensive interface for element margins with full SwiftUI compatibility,\n * CSS-in-JS support, reactive values, design system presets, and RTL awareness.\n */\n\n// Comprehensive CSS-compatible margin values including modern CSS units\nexport type MarginValue =\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 MarginOptions =\n | {\n all: MarginValue\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: MarginValue\n horizontal: MarginValue\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?: MarginValue\n horizontal?: MarginValue\n top?: MarginValue\n right?: MarginValue\n bottom?: MarginValue\n left?: MarginValue\n leading?: never\n trailing?: never\n }\n | {\n all?: never\n vertical?: MarginValue\n horizontal?: MarginValue\n top?: MarginValue\n leading?: MarginValue\n trailing?: MarginValue\n bottom?: MarginValue\n right?: never\n left?: never\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\nexport type ReactiveMarginOptions = ReactiveModifierProps<MarginOptions>\n\nexport class MarginModifier extends BaseModifier<MarginOptions> {\n readonly type = 'margin'\n readonly priority = 50 // Optimized priority for external spacing (after padding at 45)\n\n constructor(options: ReactiveMarginOptions) {\n // Enhanced reactive value handling\n super(options as unknown as MarginOptions)\n }\n\n apply(_node: DOMNode, context: ModifierContext): DOMNode | undefined {\n if (!context.element) return\n\n const styles = this.computeMarginStyles(this.properties)\n this.applyStyles(context.element, styles)\n\n return undefined\n }\n\n private computeMarginStyles(props: MarginOptions) {\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: MarginValue): 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.margin = 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.marginTop = value\n styles.marginBottom = value\n }\n if ('horizontal' in props && props.horizontal !== undefined) {\n const value = formatValue(props.horizontal)\n styles.marginLeft = value\n styles.marginRight = value\n }\n\n // Individual sides override shorthand (maintain specificity)\n if ('top' in props && props.top !== undefined) {\n styles.marginTop = formatValue(props.top)\n }\n if ('right' in props && props.right !== undefined) {\n styles.marginRight = formatValue(props.right)\n }\n if ('bottom' in props && props.bottom !== undefined) {\n styles.marginBottom = formatValue(props.bottom)\n }\n if ('left' in props && props.left !== undefined) {\n styles.marginLeft = 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.marginLeft = formatValue(props.leading) // LTR assumption\n }\n if ('trailing' in props && props.trailing !== undefined) {\n styles.marginRight = formatValue(props.trailing) // LTR assumption\n }\n }\n\n return styles\n }\n}\n\n/**\n * Create a margin 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 * .margin({ all: 16 })\n * .margin(16) // Shorthand\n * .margin('auto') // Center horizontally\n *\n * // Symmetric spacing\n * .margin({ vertical: 12, horizontal: 8 })\n * .margin({ vertical: 30, horizontal: 'auto' })\n *\n * // Individual sides with modern CSS units\n * .margin({ top: '1rem', bottom: 16, left: '2vw', right: 12 })\n *\n * // SwiftUI-style leading/trailing\n * .margin({ leading: 16, trailing: 8, vertical: 12 })\n *\n * // Mixed approach with overrides\n * .margin({ horizontal: 16, top: 8, bottom: 24 })\n *\n * // Modern CSS units\n * .margin({ all: '1rem' })\n * .margin({ vertical: '2vh', horizontal: 'auto' })\n * ```\n */\nexport function margin(options: ReactiveMarginOptions): MarginModifier\nexport function margin(all: MarginValue): MarginModifier\nexport function margin(\n optionsOrAll: ReactiveMarginOptions | MarginValue\n): MarginModifier {\n if (typeof optionsOrAll === 'number' || typeof optionsOrAll === 'string') {\n return new MarginModifier({ all: optionsOrAll })\n }\n return new MarginModifier(optionsOrAll)\n}\n\n/**\n * Convenience function for top margin only\n *\n * @example\n * ```typescript\n * .marginTop(16)\n * .marginTop('1rem')\n * .marginTop('2vh')\n * ```\n */\nexport function marginTop(value: MarginValue): MarginModifier {\n return new MarginModifier({ top: value })\n}\n\n/**\n * Convenience function for bottom margin only\n *\n * @example\n * ```typescript\n * .marginBottom(24)\n * .marginBottom('2rem')\n * ```\n */\nexport function marginBottom(value: MarginValue): MarginModifier {\n return new MarginModifier({ bottom: value })\n}\n\n/**\n * Convenience function for left margin only\n *\n * @example\n * ```typescript\n * .marginLeft(12)\n * .marginLeft('1rem')\n * ```\n */\nexport function marginLeft(value: MarginValue): MarginModifier {\n return new MarginModifier({ left: value })\n}\n\n/**\n * Convenience function for right margin only\n *\n * @example\n * ```typescript\n * .marginRight(12)\n * .marginRight('1rem')\n * ```\n */\nexport function marginRight(value: MarginValue): MarginModifier {\n return new MarginModifier({ right: value })\n}\n\n/**\n * SwiftUI-style leading margin (left in LTR, right in RTL)\n *\n * @example\n * ```typescript\n * .marginLeading(16)\n * .marginLeading('1rem')\n * ```\n */\nexport function marginLeading(value: MarginValue): MarginModifier {\n return new MarginModifier({ leading: value })\n}\n\n/**\n * SwiftUI-style trailing margin (right in LTR, left in RTL)\n *\n * @example\n * ```typescript\n * .marginTrailing(8)\n * .marginTrailing('0.5rem')\n * ```\n */\nexport function marginTrailing(value: MarginValue): MarginModifier {\n return new MarginModifier({ trailing: value })\n}\n\n/**\n * Convenience function for left and right margin\n *\n * @example\n * ```typescript\n * .marginHorizontal(20)\n * .marginHorizontal('2rem')\n * .marginHorizontal('auto') // Center horizontally\n * .marginHorizontal('5vw')\n * ```\n */\nexport function marginHorizontal(value: MarginValue): MarginModifier {\n return new MarginModifier({ horizontal: value })\n}\n\n/**\n * Convenience function for top and bottom margin\n *\n * @example\n * ```typescript\n * .marginVertical(16)\n * .marginVertical('1rem')\n * .marginVertical('3vh')\n * ```\n */\nexport function marginVertical(value: MarginValue): MarginModifier {\n return new MarginModifier({ vertical: value })\n}\n\n/**\n * Design system margin 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 marginPresets = {\n /**\n * Extra small margin (4px) - For tight spacing\n */\n xs: () => margin(4),\n\n /**\n * Small margin (8px) - For compact components\n */\n sm: () => margin(8),\n\n /**\n * Medium margin (12px) - Default comfortable spacing\n */\n md: () => margin(12),\n\n /**\n * Large margin (16px) - For prominent separation\n */\n lg: () => margin(16),\n\n /**\n * Extra large margin (24px) - For emphasis\n */\n xl: () => margin(24),\n\n /**\n * Extra extra large margin (32px) - For major sections\n */\n xxl: () => margin(32),\n\n /**\n * Huge margin (48px) - For hero sections\n */\n xxxl: () => margin(48),\n\n // Semantic presets for common UI patterns\n\n /**\n * Component separation (vertical: 16, horizontal: 0)\n * For spacing between stacked components\n */\n component: () => margin({ vertical: 16, horizontal: 0 }),\n\n /**\n * Section separation (vertical: 24, horizontal: 0)\n * For major content sections\n */\n section: () => margin({ vertical: 24, horizontal: 0 }),\n\n /**\n * Page margin (horizontal: auto)\n * For centering page content\n */\n page: () => margin({ horizontal: 'auto' }),\n\n /**\n * Card margin (all: 16)\n * Standard margin around card components\n */\n card: () => margin(16),\n\n /**\n * Compact card margin (all: 8)\n */\n cardSm: () => margin(8),\n\n /**\n * Spacious card margin (all: 24)\n */\n cardLg: () => margin(24),\n\n /**\n * Button margin (horizontal: 8, vertical: 4)\n * For spacing between inline buttons\n */\n button: () => margin({ horizontal: 8, vertical: 4 }),\n\n /**\n * List item margin (vertical: 8, horizontal: 0)\n * For spacing between list items\n */\n listItem: () => margin({ vertical: 8, horizontal: 0 }),\n\n /**\n * Form field margin (vertical: 12, horizontal: 0)\n * For spacing between form fields\n */\n field: () => margin({ vertical: 12, horizontal: 0 }),\n\n /**\n * Zero margin utility\n * For removing default margins\n */\n none: () => margin(0),\n\n /**\n * Auto margin utility\n * For centering elements\n */\n auto: () => margin('auto'),\n} as const\n\n// Types are exported above - avoiding duplicate exports\n"],"names":["MarginModifier","BaseModifier","options","__publicField","_node","context","styles","props","formatValue","value","isSignal","isComputed","margin","optionsOrAll","marginTop","marginBottom","marginLeft","marginRight","marginLeading","marginTrailing","marginHorizontal","marginVertical","marginPresets"],"mappings":";;;;;AA8EO,MAAMA,UAAuBC,EAA4B;AAAA;AAAA,EAI9D,YAAYC,GA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