@astryxdesign/core 0.2.0-canary.78221de → 0.2.0-canary.827f173
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.
- package/dist/Dialog/Dialog.d.ts +44 -5
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +57 -14
- package/dist/astryx.css +2 -0
- package/dist/astryx.umd.js +28 -28
- package/dist/astryx.umd.js.map +3 -3
- package/package.json +1 -1
- package/src/Dialog/Dialog.doc.mjs +5 -1
- package/src/Dialog/Dialog.test.tsx +84 -1
- package/src/Dialog/Dialog.tsx +85 -32
package/dist/Dialog/Dialog.d.ts
CHANGED
|
@@ -46,15 +46,53 @@ export type DialogVariant = keyof DialogVariantMap;
|
|
|
46
46
|
* - info: Informational flows - allows all exit methods
|
|
47
47
|
*/
|
|
48
48
|
export type DialogPurpose = 'required' | 'form' | 'info';
|
|
49
|
+
/** Block-axis offsets — always allowed, independent of inline direction. */
|
|
50
|
+
interface DialogBlockPosition {
|
|
51
|
+
top?: number | string;
|
|
52
|
+
bottom?: number | string;
|
|
53
|
+
}
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
55
|
+
* Static position for a dialog. The inline axis is logical XOR physical — the
|
|
56
|
+
* type forbids mixing the two, so a single dialog can't be positioned both ways:
|
|
57
|
+
* - Logical `start`/`end` map to `inset-inline-*` and mirror under RTL (preferred).
|
|
58
|
+
* - Physical `left`/`right` are deprecated, do not mirror, and are removed in a
|
|
59
|
+
* future major.
|
|
60
|
+
* Block-axis `top`/`bottom` may be combined with either.
|
|
51
61
|
*/
|
|
52
|
-
export
|
|
53
|
-
|
|
62
|
+
export type DialogPosition = (DialogBlockPosition & {
|
|
63
|
+
/** Logical inline-start offset (`inset-inline-start`); mirrors under RTL. */
|
|
64
|
+
start?: number | string;
|
|
65
|
+
/** Logical inline-end offset (`inset-inline-end`); mirrors under RTL. */
|
|
66
|
+
end?: number | string;
|
|
67
|
+
left?: never;
|
|
68
|
+
right?: never;
|
|
69
|
+
}) | (DialogBlockPosition & {
|
|
70
|
+
/** @deprecated Use `start`. Physical (never mirrors); removed in a future major. */
|
|
54
71
|
left?: number | string;
|
|
72
|
+
/** @deprecated Use `end`. Physical (never mirrors); removed in a future major. */
|
|
55
73
|
right?: number | string;
|
|
56
|
-
|
|
57
|
-
|
|
74
|
+
start?: never;
|
|
75
|
+
end?: never;
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Map a {@link DialogPosition} to resolved CSS offsets. Logical `start`/`end`
|
|
79
|
+
* become `inset-inline-*` (mirror under RTL); physical `left`/`right` stay
|
|
80
|
+
* physical. The union type guarantees at most one inline pair is set, so no
|
|
81
|
+
* precedence is needed — each unset offset falls back to `auto`.
|
|
82
|
+
*
|
|
83
|
+
* Not re-exported from the package; internal to Dialog. Directly unit-tested
|
|
84
|
+
* so the mapping is verified without StyleX class compilation.
|
|
85
|
+
*
|
|
86
|
+
* @see DialogPosition
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveDialogPositionOffsets(position: DialogPosition): {
|
|
89
|
+
top: string;
|
|
90
|
+
bottom: string;
|
|
91
|
+
insetInlineStart: string;
|
|
92
|
+
insetInlineEnd: string;
|
|
93
|
+
left: string;
|
|
94
|
+
right: string;
|
|
95
|
+
};
|
|
58
96
|
export interface DialogProps extends BaseProps<HTMLDialogElement> {
|
|
59
97
|
/** Ref forwarded to the root element */
|
|
60
98
|
ref?: React.Ref<HTMLDialogElement>;
|
|
@@ -152,4 +190,5 @@ export declare function Dialog({ isOpen, isInline, onOpenChange, width, maxHeigh
|
|
|
152
190
|
export declare namespace Dialog {
|
|
153
191
|
var displayName: string;
|
|
154
192
|
}
|
|
193
|
+
export {};
|
|
155
194
|
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/Dialog/Dialog.tsx"],"names":[],"mappings":"AAIA;;;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;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,QAAgB,EAChB,YAAY,EACZ,KAAW,EACX,SAAkB,EAClB,QAAQ,EACR,OAAoB,EACpB,OAAgB,EAChB,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,WAAW,sCA6Sb;yBA7Te,MAAM"}
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -74,8 +74,15 @@ function getDialogDirection(triggerEl, distance = 16) {
|
|
|
74
74
|
* - info: Informational flows - allows all exit methods
|
|
75
75
|
*/
|
|
76
76
|
|
|
77
|
+
/** Block-axis offsets — always allowed, independent of inline direction. */
|
|
78
|
+
|
|
77
79
|
/**
|
|
78
|
-
*
|
|
80
|
+
* Static position for a dialog. The inline axis is logical XOR physical — the
|
|
81
|
+
* type forbids mixing the two, so a single dialog can't be positioned both ways:
|
|
82
|
+
* - Logical `start`/`end` map to `inset-inline-*` and mirror under RTL (preferred).
|
|
83
|
+
* - Physical `left`/`right` are deprecated, do not mirror, and are removed in a
|
|
84
|
+
* future major.
|
|
85
|
+
* Block-axis `top`/`bottom` may be combined with either.
|
|
79
86
|
*/
|
|
80
87
|
|
|
81
88
|
const enterDirectional = "x11lauxq-B";
|
|
@@ -167,17 +174,21 @@ const dynamicStyles = {
|
|
|
167
174
|
"--x-width": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(typeof width === 'number' ? `${width}px` : width),
|
|
168
175
|
"--x-maxHeight": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight)
|
|
169
176
|
}],
|
|
170
|
-
position: (top, right, bottom, left) => [_temp2, {
|
|
171
|
-
k87sOh:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
position: (top, insetInlineStart, insetInlineEnd, right, bottom, left) => [_temp2, {
|
|
178
|
+
k87sOh: top != null ? "xjbys53" : top,
|
|
179
|
+
kLqNvP: insetInlineStart != null ? "x1lxsm33" : insetInlineStart,
|
|
180
|
+
kt4wiu: insetInlineEnd != null ? "xqxgn94" : insetInlineEnd,
|
|
181
|
+
kCIrl2: right != null ? "x7ok3n0" : right,
|
|
182
|
+
krVfgx: bottom != null ? "x1nqzi6q" : bottom,
|
|
183
|
+
kbCHJM: left != null ? "xgq9j65" : left,
|
|
175
184
|
$$css: true
|
|
176
185
|
}, {
|
|
177
|
-
"--x-top": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(top
|
|
178
|
-
"--x-
|
|
179
|
-
"--x-
|
|
180
|
-
"--x-
|
|
186
|
+
"--x-top": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(top),
|
|
187
|
+
"--x-insetInlineStart": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(insetInlineStart),
|
|
188
|
+
"--x-insetInlineEnd": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(insetInlineEnd),
|
|
189
|
+
"--x-right": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(right),
|
|
190
|
+
"--x-bottom": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(bottom),
|
|
191
|
+
"--x-left": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(left)
|
|
181
192
|
}]
|
|
182
193
|
};
|
|
183
194
|
|
|
@@ -185,11 +196,40 @@ const dynamicStyles = {
|
|
|
185
196
|
* Format position value - numbers become pixels, strings pass through, undefined becomes null
|
|
186
197
|
*/
|
|
187
198
|
function formatPosition(value) {
|
|
188
|
-
if (value === undefined) {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
199
|
return typeof value === 'number' ? `${value}px` : value;
|
|
192
200
|
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Map a {@link DialogPosition} to resolved CSS offsets. Logical `start`/`end`
|
|
204
|
+
* become `inset-inline-*` (mirror under RTL); physical `left`/`right` stay
|
|
205
|
+
* physical. The union type guarantees at most one inline pair is set, so no
|
|
206
|
+
* precedence is needed — each unset offset falls back to `auto`.
|
|
207
|
+
*
|
|
208
|
+
* Not re-exported from the package; internal to Dialog. Directly unit-tested
|
|
209
|
+
* so the mapping is verified without StyleX class compilation.
|
|
210
|
+
*
|
|
211
|
+
* @see DialogPosition
|
|
212
|
+
*/
|
|
213
|
+
export function resolveDialogPositionOffsets(position) {
|
|
214
|
+
const {
|
|
215
|
+
top,
|
|
216
|
+
bottom,
|
|
217
|
+
start,
|
|
218
|
+
end,
|
|
219
|
+
left,
|
|
220
|
+
right
|
|
221
|
+
} = position;
|
|
222
|
+
return {
|
|
223
|
+
top: top !== undefined ? formatPosition(top) : 'auto',
|
|
224
|
+
bottom: bottom !== undefined ? formatPosition(bottom) : 'auto',
|
|
225
|
+
// Logical offsets mirror under RTL (preferred replacements).
|
|
226
|
+
insetInlineStart: start !== undefined ? formatPosition(start) : 'auto',
|
|
227
|
+
insetInlineEnd: end !== undefined ? formatPosition(end) : 'auto',
|
|
228
|
+
// Deprecated physical offsets never mirror.
|
|
229
|
+
left: left !== undefined ? formatPosition(left) : 'auto',
|
|
230
|
+
right: right !== undefined ? formatPosition(right) : 'auto'
|
|
231
|
+
};
|
|
232
|
+
}
|
|
193
233
|
/**
|
|
194
234
|
* A dialog component using the native <dialog> element.
|
|
195
235
|
*
|
|
@@ -434,7 +474,10 @@ export function Dialog({
|
|
|
434
474
|
...safeProps,
|
|
435
475
|
...mergeProps(themeProps('dialog', {
|
|
436
476
|
variant
|
|
437
|
-
}), stylex.props(styles.dialog, isOpen && styles.open, styles.backdrop, !isFullscreen && dynamicStyles.sizing(width, maxHeight), hasPosition &&
|
|
477
|
+
}), stylex.props(styles.dialog, isOpen && styles.open, styles.backdrop, !isFullscreen && dynamicStyles.sizing(width, maxHeight), hasPosition && (() => {
|
|
478
|
+
const o = resolveDialogPositionOffsets(position);
|
|
479
|
+
return dynamicStyles.position(o.top, o.insetInlineStart, o.insetInlineEnd, o.right, o.bottom, o.left);
|
|
480
|
+
})(), isFullscreen && styles.fullscreen, xstyle), className, style),
|
|
438
481
|
onClick: handleClick,
|
|
439
482
|
onCancel: handleCancel,
|
|
440
483
|
"aria-modal": "true"
|
package/dist/astryx.css
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
@property --x-gridTemplateColumns { syntax: "*"; inherits: false;}
|
|
21
21
|
@property --x-height { syntax: "*"; inherits: false;}
|
|
22
22
|
@property --x-insetInlineEnd { syntax: "*"; inherits: false;}
|
|
23
|
+
@property --x-insetInlineStart { syntax: "*"; inherits: false;}
|
|
23
24
|
@property --x-left { syntax: "*"; inherits: false;}
|
|
24
25
|
@property --x-marginInline { syntax: "*"; inherits: false;}
|
|
25
26
|
@property --x-maxHeight { syntax: "*"; inherits: false;}
|
|
@@ -846,6 +847,7 @@
|
|
|
846
847
|
.xbudbmw:not(#\#):not(#\#):not(#\#){inset-inline-start:50%}
|
|
847
848
|
.x1kiyvbf:not(#\#):not(#\#):not(#\#){inset-inline-start:var(--_textarea-inline-padding)}
|
|
848
849
|
.x1ybfrjj:not(#\#):not(#\#):not(#\#){inset-inline-start:var(--spacing-3)}
|
|
850
|
+
.x1lxsm33:not(#\#):not(#\#):not(#\#){inset-inline-start:var(--x-insetInlineStart)}
|
|
849
851
|
.xc8icb0:not(#\#):not(#\#):not(#\#){isolation:isolate}
|
|
850
852
|
.xl56j7k:not(#\#):not(#\#):not(#\#){justify-content:center}
|
|
851
853
|
.x13a6bvl:not(#\#):not(#\#):not(#\#){justify-content:flex-end}
|