@dloizides/ui-forms 1.56.0 → 1.57.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 +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -904,8 +904,12 @@ interface SelectControlProps {
|
|
|
904
904
|
}
|
|
905
905
|
declare function SelectControl(props: SelectControlProps): React.ReactElement;
|
|
906
906
|
|
|
907
|
-
/**
|
|
908
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Select look: `default` = kit box (touch-target floor, 14 px text, glyph chevron); `field` = 38 px wide-screen box
|
|
909
|
+
* (44 px on a phone), 13 px text, drawn chevron, one-line ellipsis; `chip` = 30 px content-width toolbar chip
|
|
910
|
+
* (44 px on a phone), 13 px text, label and chevron side by side, for a picker sitting in a header or toolbar band.
|
|
911
|
+
*/
|
|
912
|
+
type SelectLook = 'default' | 'field' | 'chip';
|
|
909
913
|
/** The box metrics a select look draws with. */
|
|
910
914
|
interface SelectLookMetrics {
|
|
911
915
|
height: number;
|
|
@@ -914,15 +918,22 @@ interface SelectLookMetrics {
|
|
|
914
918
|
fontSize: number;
|
|
915
919
|
borderRadius: number;
|
|
916
920
|
chevronRoom: number;
|
|
921
|
+
/** `true` when the trigger hugs its label (chevron beside it) instead of filling the row. */
|
|
922
|
+
hug: boolean;
|
|
923
|
+
gap?: number;
|
|
917
924
|
borderColor?: string;
|
|
925
|
+
backgroundColor?: string;
|
|
926
|
+
textColor?: string;
|
|
918
927
|
}
|
|
919
|
-
/** A select look plus
|
|
928
|
+
/** A select look plus optional theme colours for the box border, fill and ink (text and chevron). */
|
|
920
929
|
interface SelectLookConfig {
|
|
921
930
|
look: SelectLook;
|
|
922
931
|
borderColor?: string;
|
|
932
|
+
backgroundColor?: string;
|
|
933
|
+
textColor?: string;
|
|
923
934
|
}
|
|
924
935
|
/** Sets the look of every `SelectControl` and `SelectField` below it; outside one, selects keep the `default` look. */
|
|
925
|
-
declare function SelectLookProvider({ look, borderColor, children }: SelectLookConfig & {
|
|
936
|
+
declare function SelectLookProvider({ look, borderColor, backgroundColor, textColor, children }: SelectLookConfig & {
|
|
926
937
|
children: React.ReactNode;
|
|
927
938
|
}): React.ReactElement;
|
|
928
939
|
/**
|
|
@@ -930,7 +941,7 @@ declare function SelectLookProvider({ look, borderColor, children }: SelectLookC
|
|
|
930
941
|
* @param config the look and its optional border colour
|
|
931
942
|
* @param windowWidth the current window width in px
|
|
932
943
|
*/
|
|
933
|
-
declare function selectLookMetrics({ look, borderColor }: SelectLookConfig, windowWidth: number): SelectLookMetrics | undefined;
|
|
944
|
+
declare function selectLookMetrics({ look, borderColor, backgroundColor, textColor }: SelectLookConfig, windowWidth: number): SelectLookMetrics | undefined;
|
|
934
945
|
|
|
935
946
|
/** The row index an arrow key moves to: wraps at both ends, -1 when there are no rows. */
|
|
936
947
|
declare function nextHighlight(current: number, count: number, delta: number): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -904,8 +904,12 @@ interface SelectControlProps {
|
|
|
904
904
|
}
|
|
905
905
|
declare function SelectControl(props: SelectControlProps): React.ReactElement;
|
|
906
906
|
|
|
907
|
-
/**
|
|
908
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Select look: `default` = kit box (touch-target floor, 14 px text, glyph chevron); `field` = 38 px wide-screen box
|
|
909
|
+
* (44 px on a phone), 13 px text, drawn chevron, one-line ellipsis; `chip` = 30 px content-width toolbar chip
|
|
910
|
+
* (44 px on a phone), 13 px text, label and chevron side by side, for a picker sitting in a header or toolbar band.
|
|
911
|
+
*/
|
|
912
|
+
type SelectLook = 'default' | 'field' | 'chip';
|
|
909
913
|
/** The box metrics a select look draws with. */
|
|
910
914
|
interface SelectLookMetrics {
|
|
911
915
|
height: number;
|
|
@@ -914,15 +918,22 @@ interface SelectLookMetrics {
|
|
|
914
918
|
fontSize: number;
|
|
915
919
|
borderRadius: number;
|
|
916
920
|
chevronRoom: number;
|
|
921
|
+
/** `true` when the trigger hugs its label (chevron beside it) instead of filling the row. */
|
|
922
|
+
hug: boolean;
|
|
923
|
+
gap?: number;
|
|
917
924
|
borderColor?: string;
|
|
925
|
+
backgroundColor?: string;
|
|
926
|
+
textColor?: string;
|
|
918
927
|
}
|
|
919
|
-
/** A select look plus
|
|
928
|
+
/** A select look plus optional theme colours for the box border, fill and ink (text and chevron). */
|
|
920
929
|
interface SelectLookConfig {
|
|
921
930
|
look: SelectLook;
|
|
922
931
|
borderColor?: string;
|
|
932
|
+
backgroundColor?: string;
|
|
933
|
+
textColor?: string;
|
|
923
934
|
}
|
|
924
935
|
/** Sets the look of every `SelectControl` and `SelectField` below it; outside one, selects keep the `default` look. */
|
|
925
|
-
declare function SelectLookProvider({ look, borderColor, children }: SelectLookConfig & {
|
|
936
|
+
declare function SelectLookProvider({ look, borderColor, backgroundColor, textColor, children }: SelectLookConfig & {
|
|
926
937
|
children: React.ReactNode;
|
|
927
938
|
}): React.ReactElement;
|
|
928
939
|
/**
|
|
@@ -930,7 +941,7 @@ declare function SelectLookProvider({ look, borderColor, children }: SelectLookC
|
|
|
930
941
|
* @param config the look and its optional border colour
|
|
931
942
|
* @param windowWidth the current window width in px
|
|
932
943
|
*/
|
|
933
|
-
declare function selectLookMetrics({ look, borderColor }: SelectLookConfig, windowWidth: number): SelectLookMetrics | undefined;
|
|
944
|
+
declare function selectLookMetrics({ look, borderColor, backgroundColor, textColor }: SelectLookConfig, windowWidth: number): SelectLookMetrics | undefined;
|
|
934
945
|
|
|
935
946
|
/** The row index an arrow key moves to: wraps at both ends, -1 when there are no rows. */
|
|
936
947
|
declare function nextHighlight(current: number, count: number, delta: number): number;
|
package/dist/index.js
CHANGED
|
@@ -2223,26 +2223,34 @@ var FIELD_PAD_H = 10;
|
|
|
2223
2223
|
var FIELD_FONT = 13;
|
|
2224
2224
|
var FIELD_RADIUS = 8;
|
|
2225
2225
|
var FIELD_CHEVRON_ROOM = 30;
|
|
2226
|
+
var CHIP_DESKTOP_HEIGHT = 30;
|
|
2227
|
+
var CHIP_GAP = 6;
|
|
2226
2228
|
var CHEVRON_BOX = 16;
|
|
2227
2229
|
var DEFAULT_CONFIG = { look: "default" };
|
|
2228
2230
|
var SelectLookContext = React41.createContext(DEFAULT_CONFIG);
|
|
2229
|
-
function SelectLookProvider({ look, borderColor, children }) {
|
|
2230
|
-
const value = React41.useMemo(() => ({ look, borderColor }), [look, borderColor]);
|
|
2231
|
+
function SelectLookProvider({ look, borderColor, backgroundColor, textColor, children }) {
|
|
2232
|
+
const value = React41.useMemo(() => ({ look, borderColor, backgroundColor, textColor }), [look, borderColor, backgroundColor, textColor]);
|
|
2231
2233
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectLookContext.Provider, { value, children });
|
|
2232
2234
|
}
|
|
2233
|
-
function selectLookMetrics({ look, borderColor }, windowWidth) {
|
|
2235
|
+
function selectLookMetrics({ look, borderColor, backgroundColor, textColor }, windowWidth) {
|
|
2234
2236
|
if (look === "default") {
|
|
2235
2237
|
return void 0;
|
|
2236
2238
|
}
|
|
2237
2239
|
const isPhone = windowWidth < PHONE_MAX_WIDTH;
|
|
2240
|
+
const isChip = look === "chip";
|
|
2241
|
+
const desktopHeight = isChip ? CHIP_DESKTOP_HEIGHT : FIELD_DESKTOP_HEIGHT;
|
|
2238
2242
|
return {
|
|
2239
|
-
height: isPhone ? FIELD_PHONE_HEIGHT :
|
|
2243
|
+
height: isPhone ? FIELD_PHONE_HEIGHT : desktopHeight,
|
|
2240
2244
|
paddingHorizontal: FIELD_PAD_H,
|
|
2241
2245
|
paddingVertical: 0,
|
|
2242
2246
|
fontSize: FIELD_FONT,
|
|
2243
2247
|
borderRadius: FIELD_RADIUS,
|
|
2244
2248
|
chevronRoom: FIELD_CHEVRON_ROOM,
|
|
2245
|
-
|
|
2249
|
+
hug: isChip,
|
|
2250
|
+
gap: isChip ? CHIP_GAP : void 0,
|
|
2251
|
+
borderColor,
|
|
2252
|
+
backgroundColor,
|
|
2253
|
+
textColor
|
|
2246
2254
|
};
|
|
2247
2255
|
}
|
|
2248
2256
|
function useSelectLookMetrics() {
|
|
@@ -2282,10 +2290,10 @@ function lookSelectStyle(fit, m, colors) {
|
|
|
2282
2290
|
paddingInlineStart: m.paddingHorizontal,
|
|
2283
2291
|
paddingInlineEnd: m.chevronRoom,
|
|
2284
2292
|
borderColor: m.borderColor ?? colors.border,
|
|
2285
|
-
backgroundColor: colors.background,
|
|
2286
|
-
color: colors.text,
|
|
2293
|
+
backgroundColor: m.backgroundColor ?? colors.background,
|
|
2294
|
+
color: m.textColor ?? colors.text,
|
|
2287
2295
|
appearance: "none",
|
|
2288
|
-
backgroundImage: chevronDataUri(colors.chevron),
|
|
2296
|
+
backgroundImage: chevronDataUri(m.textColor ?? colors.chevron),
|
|
2289
2297
|
backgroundRepeat: "no-repeat",
|
|
2290
2298
|
backgroundPosition: `right ${String(CHEVRON_INSET)}px center`,
|
|
2291
2299
|
backgroundSize: "16px 16px"
|
|
@@ -2383,7 +2391,18 @@ var IS_WEB7 = reactNative.Platform.OS === "web";
|
|
|
2383
2391
|
var CHEVRON_DOWN = "\u25BE";
|
|
2384
2392
|
var CHEVRON_UP = "\u25B4";
|
|
2385
2393
|
function lookTriggerBox(m) {
|
|
2386
|
-
|
|
2394
|
+
if (m === void 0) return void 0;
|
|
2395
|
+
const hug = m.hug ? { justifyContent: "flex-start", alignSelf: "flex-start", gap: m.gap } : void 0;
|
|
2396
|
+
return { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius, ...hug };
|
|
2397
|
+
}
|
|
2398
|
+
function triggerInk(m, colors, isEmpty) {
|
|
2399
|
+
const themeText = isEmpty ? colors.textSecondary : colors.text;
|
|
2400
|
+
return {
|
|
2401
|
+
border: m?.borderColor ?? colors.border,
|
|
2402
|
+
background: m?.backgroundColor ?? colors.surfaceElevated,
|
|
2403
|
+
text: m?.textColor ?? themeText,
|
|
2404
|
+
chevron: m?.textColor ?? colors.textSecondary
|
|
2405
|
+
};
|
|
2387
2406
|
}
|
|
2388
2407
|
function listboxTriggerAria(testID, hasList, highlighted) {
|
|
2389
2408
|
return {
|
|
@@ -2433,6 +2452,7 @@ function MenuSelectControl({
|
|
|
2433
2452
|
[onChange]
|
|
2434
2453
|
);
|
|
2435
2454
|
const metrics = useSelectLookMetrics();
|
|
2455
|
+
const ink = triggerInk(metrics, colors, value === "");
|
|
2436
2456
|
const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
|
|
2437
2457
|
const isListbox = menuAnchor !== void 0;
|
|
2438
2458
|
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
@@ -2451,11 +2471,11 @@ function MenuSelectControl({
|
|
|
2451
2471
|
"aria-labelledby": labelledById,
|
|
2452
2472
|
onBlur: isListbox ? close : void 0,
|
|
2453
2473
|
onPress: toggle2,
|
|
2454
|
-
style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor:
|
|
2474
|
+
style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: ink.border, backgroundColor: ink.background }],
|
|
2455
2475
|
testID: `${testID}-trigger`,
|
|
2456
2476
|
children: [
|
|
2457
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color:
|
|
2458
|
-
metrics === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color:
|
|
2477
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: ink.text }], children: selectedLabel }),
|
|
2478
|
+
metrics === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: ink.chevron }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN }) : /* @__PURE__ */ jsxRuntime.jsx(SelectChevron, { color: ink.chevron, open: isOpen })
|
|
2459
2479
|
]
|
|
2460
2480
|
}
|
|
2461
2481
|
),
|
|
@@ -2501,7 +2521,7 @@ var SelectField = ({
|
|
|
2501
2521
|
) });
|
|
2502
2522
|
};
|
|
2503
2523
|
var REMOVE_GLYPH = "\xD7";
|
|
2504
|
-
var
|
|
2524
|
+
var CHIP_GAP2 = 4;
|
|
2505
2525
|
var CHIP_PAD_H = 8;
|
|
2506
2526
|
var CHIP_PAD_V = 4;
|
|
2507
2527
|
var CHIP_RADIUS = 999;
|
|
@@ -2510,7 +2530,7 @@ var styles18 = reactNative.StyleSheet.create({
|
|
|
2510
2530
|
chip: {
|
|
2511
2531
|
flexDirection: "row",
|
|
2512
2532
|
alignItems: "center",
|
|
2513
|
-
gap:
|
|
2533
|
+
gap: CHIP_GAP2,
|
|
2514
2534
|
paddingHorizontal: CHIP_PAD_H,
|
|
2515
2535
|
paddingVertical: CHIP_PAD_V,
|
|
2516
2536
|
borderWidth: 1,
|