@dloizides/ui-layout 1.41.0 → 1.42.0
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/index.d.mts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +114 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -103,10 +103,13 @@ var LAYOUT_TEST_IDS = {
|
|
|
103
103
|
bottomSheet: "bottom-sheet",
|
|
104
104
|
/** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
|
|
105
105
|
confirmDialog: "confirm-dialog",
|
|
106
|
+
/** Default base testID for `FormDialog`: `form-dialog`, `form-save`, `form-cancel`. */
|
|
107
|
+
formDialog: "form",
|
|
106
108
|
accordion: "accordion",
|
|
107
109
|
/** Default testID for the `BuildInfoFooter` caption (`v<version>`). */
|
|
108
110
|
buildInfoFooter: "build-info-footer"
|
|
109
111
|
};
|
|
112
|
+
var MODAL_FOOTER_STACK_BELOW = 400;
|
|
110
113
|
var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
111
114
|
var LAYOUT_I18N = {
|
|
112
115
|
/** Placeholder shown by `ModalDropdown` when no option matches the current value. */
|
|
@@ -176,6 +179,9 @@ var WEB_PLATFORM = "web";
|
|
|
176
179
|
function isWideWebViewport(width, platformOS, breakpoint = LAYOUT_COLLAPSE_BREAKPOINT) {
|
|
177
180
|
return platformOS === WEB_PLATFORM && width >= breakpoint;
|
|
178
181
|
}
|
|
182
|
+
function isModalFooterStacked(width) {
|
|
183
|
+
return width < MODAL_FOOTER_STACK_BELOW;
|
|
184
|
+
}
|
|
179
185
|
|
|
180
186
|
// src/hooks/useIsWideViewport.ts
|
|
181
187
|
function useIsWideViewport(breakpoint = LAYOUT_COLLAPSE_BREAKPOINT) {
|
|
@@ -479,6 +485,7 @@ var DIALOG_RADIUS = 12;
|
|
|
479
485
|
var DIALOG_PADDING = 16;
|
|
480
486
|
var HEADER_GAP = 12;
|
|
481
487
|
var FOOTER_MARGIN = 16;
|
|
488
|
+
var FOOTER_GAP = 12;
|
|
482
489
|
var HEADER_MARGIN = 12;
|
|
483
490
|
var DIALOG_MAX_HEIGHT = "90%";
|
|
484
491
|
var PANEL_ENTER_SCALE = 0.96;
|
|
@@ -510,8 +517,27 @@ var styles6 = StyleSheet.create({
|
|
|
510
517
|
},
|
|
511
518
|
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
512
519
|
titleWrap: { flex: 1 },
|
|
513
|
-
|
|
520
|
+
footerRow: {
|
|
521
|
+
marginTop: FOOTER_MARGIN,
|
|
522
|
+
flexDirection: "row",
|
|
523
|
+
flexWrap: "wrap",
|
|
524
|
+
justifyContent: "flex-end",
|
|
525
|
+
alignItems: "center",
|
|
526
|
+
columnGap: FOOTER_GAP,
|
|
527
|
+
rowGap: FOOTER_GAP
|
|
528
|
+
},
|
|
529
|
+
footerStack: {
|
|
530
|
+
marginTop: FOOTER_MARGIN,
|
|
531
|
+
flexDirection: "column-reverse",
|
|
532
|
+
alignItems: "stretch",
|
|
533
|
+
rowGap: FOOTER_GAP
|
|
534
|
+
}
|
|
514
535
|
});
|
|
536
|
+
var ModalFooter = ({ children, testID }) => {
|
|
537
|
+
const { width } = useWindowDimensions();
|
|
538
|
+
const style = isModalFooterStacked(width) ? styles6.footerStack : styles6.footerRow;
|
|
539
|
+
return /* @__PURE__ */ jsx(View, { style, testID, children });
|
|
540
|
+
};
|
|
515
541
|
var Modal = ({
|
|
516
542
|
visible,
|
|
517
543
|
onClose,
|
|
@@ -588,7 +614,7 @@ var Modal = ({
|
|
|
588
614
|
) : null
|
|
589
615
|
] }) : null,
|
|
590
616
|
/* @__PURE__ */ jsx(ScrollView, { children }),
|
|
591
|
-
footer !== void 0 ? /* @__PURE__ */ jsx(
|
|
617
|
+
footer !== void 0 ? /* @__PURE__ */ jsx(ModalFooter, { testID: `${testID}-footer`, children: footer }) : null
|
|
592
618
|
]
|
|
593
619
|
}
|
|
594
620
|
)
|
|
@@ -2020,10 +2046,8 @@ var BottomSheet = ({
|
|
|
2020
2046
|
};
|
|
2021
2047
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
2022
2048
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
2023
|
-
var BUTTON_GAP = 12;
|
|
2024
2049
|
var styles18 = StyleSheet.create({
|
|
2025
|
-
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT }
|
|
2026
|
-
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
2050
|
+
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT }
|
|
2027
2051
|
});
|
|
2028
2052
|
var ConfirmDialog = ({
|
|
2029
2053
|
visible,
|
|
@@ -2040,7 +2064,7 @@ var ConfirmDialog = ({
|
|
|
2040
2064
|
const { theme, t } = useUi();
|
|
2041
2065
|
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
2042
2066
|
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
2043
|
-
const footer = /* @__PURE__ */ jsxs(
|
|
2067
|
+
const footer = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2044
2068
|
/* @__PURE__ */ jsx(
|
|
2045
2069
|
Button,
|
|
2046
2070
|
{
|
|
@@ -2080,6 +2104,87 @@ var ConfirmDialog = ({
|
|
|
2080
2104
|
}
|
|
2081
2105
|
);
|
|
2082
2106
|
};
|
|
2107
|
+
var FIELD_SELECTOR = "input:not([disabled]), textarea:not([disabled]), select:not([disabled])";
|
|
2108
|
+
var FORM_STYLE = { display: "contents" };
|
|
2109
|
+
var WebFormBody = ({ children, visible, onSubmit }) => {
|
|
2110
|
+
const formRef = useRef(null);
|
|
2111
|
+
useEffect(() => {
|
|
2112
|
+
if (Platform.OS !== "web" || !visible) return;
|
|
2113
|
+
formRef.current?.querySelector(FIELD_SELECTOR)?.focus();
|
|
2114
|
+
}, [visible]);
|
|
2115
|
+
const handleSubmit = useCallback(
|
|
2116
|
+
(event) => {
|
|
2117
|
+
event.preventDefault();
|
|
2118
|
+
onSubmit();
|
|
2119
|
+
},
|
|
2120
|
+
[onSubmit]
|
|
2121
|
+
);
|
|
2122
|
+
if (Platform.OS !== "web") return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2123
|
+
return React14.createElement(
|
|
2124
|
+
"form",
|
|
2125
|
+
{ ref: formRef, noValidate: true, style: FORM_STYLE, onSubmit: handleSubmit },
|
|
2126
|
+
children,
|
|
2127
|
+
React14.createElement("button", { type: "submit", hidden: true, tabIndex: -1, "aria-hidden": true })
|
|
2128
|
+
);
|
|
2129
|
+
};
|
|
2130
|
+
var FormDialogActions = (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2131
|
+
/* @__PURE__ */ jsx(
|
|
2132
|
+
Button,
|
|
2133
|
+
{
|
|
2134
|
+
accessibilityHint: props.cancelHint,
|
|
2135
|
+
accessibilityLabel: props.cancelLabel,
|
|
2136
|
+
disabled: props.loading,
|
|
2137
|
+
label: props.cancelLabel,
|
|
2138
|
+
testID: `${props.testID}-cancel`,
|
|
2139
|
+
variant: "secondary",
|
|
2140
|
+
onPress: props.onCancel
|
|
2141
|
+
}
|
|
2142
|
+
),
|
|
2143
|
+
/* @__PURE__ */ jsx(
|
|
2144
|
+
Button,
|
|
2145
|
+
{
|
|
2146
|
+
accessibilityHint: props.submitHint,
|
|
2147
|
+
accessibilityLabel: props.submitLabel,
|
|
2148
|
+
label: props.submitLabel,
|
|
2149
|
+
loading: props.loading,
|
|
2150
|
+
testID: `${props.testID}-save`,
|
|
2151
|
+
variant: "primary",
|
|
2152
|
+
onPress: props.onSubmit
|
|
2153
|
+
}
|
|
2154
|
+
)
|
|
2155
|
+
] });
|
|
2156
|
+
var FormDialog = ({
|
|
2157
|
+
visible,
|
|
2158
|
+
title,
|
|
2159
|
+
children,
|
|
2160
|
+
submitLabel,
|
|
2161
|
+
submitHint,
|
|
2162
|
+
cancelLabel,
|
|
2163
|
+
loading = false,
|
|
2164
|
+
onSubmit,
|
|
2165
|
+
onCancel,
|
|
2166
|
+
size = "md",
|
|
2167
|
+
testID = LAYOUT_TEST_IDS.formDialog
|
|
2168
|
+
}) => {
|
|
2169
|
+
const { t } = useUi();
|
|
2170
|
+
const submit = useCallback(() => {
|
|
2171
|
+
if (!loading) onSubmit();
|
|
2172
|
+
}, [loading, onSubmit]);
|
|
2173
|
+
const footer = /* @__PURE__ */ jsx(
|
|
2174
|
+
FormDialogActions,
|
|
2175
|
+
{
|
|
2176
|
+
cancelHint: t(LAYOUT_I18N.cancelHint),
|
|
2177
|
+
cancelLabel: cancelLabel ?? t(LAYOUT_I18N.cancel),
|
|
2178
|
+
loading,
|
|
2179
|
+
submitHint,
|
|
2180
|
+
submitLabel,
|
|
2181
|
+
testID,
|
|
2182
|
+
onCancel,
|
|
2183
|
+
onSubmit: submit
|
|
2184
|
+
}
|
|
2185
|
+
);
|
|
2186
|
+
return /* @__PURE__ */ jsx(Modal, { footer, size, testID: `${testID}-dialog`, title, visible, onClose: onCancel, children: /* @__PURE__ */ jsx(WebFormBody, { visible, onSubmit: submit, children }) });
|
|
2187
|
+
};
|
|
2083
2188
|
var AccordionContext = createContext(null);
|
|
2084
2189
|
function useAccordionContext() {
|
|
2085
2190
|
const value = useContext(AccordionContext);
|
|
@@ -2948,6 +3053,6 @@ var ListRow = ({
|
|
|
2948
3053
|
] });
|
|
2949
3054
|
};
|
|
2950
3055
|
|
|
2951
|
-
export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BottomSheet, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, HEADER_STACK_BREAKPOINT, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, Modal, ModalDropdown, ModalShell, PageFrame, RowSelectedStyle, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, SideSheet, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
|
|
3056
|
+
export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BottomSheet, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, FormDialog, HEADER_STACK_BREAKPOINT, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, ModalShell, PageFrame, RowSelectedStyle, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, SideSheet, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
|
|
2952
3057
|
//# sourceMappingURL=index.mjs.map
|
|
2953
3058
|
//# sourceMappingURL=index.mjs.map
|