@dloizides/ui-forms 1.56.0 → 1.58.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 CHANGED
@@ -904,8 +904,12 @@ interface SelectControlProps {
904
904
  }
905
905
  declare function SelectControl(props: SelectControlProps): React.ReactElement;
906
906
 
907
- /** Select look: `default` = kit box (touch-target floor, 14 px text, glyph chevron); `field` = 38 px wide-screen box (44 px on a phone), 13 px text, drawn chevron, one-line ellipsis. */
908
- type SelectLook = 'default' | 'field';
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 an optional theme border colour for the box. */
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
- /** Select look: `default` = kit box (touch-target floor, 14 px text, glyph chevron); `field` = 38 px wide-screen box (44 px on a phone), 13 px text, drawn chevron, one-line ellipsis. */
908
- type SelectLook = 'default' | 'field';
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 an optional theme border colour for the box. */
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
@@ -2198,6 +2198,14 @@ var FormCheckbox = ({
2198
2198
  );
2199
2199
  };
2200
2200
 
2201
+ // src/SelectControl/controlBorder.ts
2202
+ var CONTROL_BORDER_SCALE = "controlBorder";
2203
+ var MAIN_STEP2 = "500";
2204
+ function controlBorderOf(theme) {
2205
+ const scale = theme.palette[CONTROL_BORDER_SCALE];
2206
+ return scale?.[MAIN_STEP2] ?? theme.colors.border;
2207
+ }
2208
+
2201
2209
  // src/SearchSelect/SelectSurface.ts
2202
2210
  var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
2203
2211
  SelectSurface2["Sheet"] = "sheet";
@@ -2223,26 +2231,34 @@ var FIELD_PAD_H = 10;
2223
2231
  var FIELD_FONT = 13;
2224
2232
  var FIELD_RADIUS = 8;
2225
2233
  var FIELD_CHEVRON_ROOM = 30;
2234
+ var CHIP_DESKTOP_HEIGHT = 30;
2235
+ var CHIP_GAP = 6;
2226
2236
  var CHEVRON_BOX = 16;
2227
2237
  var DEFAULT_CONFIG = { look: "default" };
2228
2238
  var SelectLookContext = React41.createContext(DEFAULT_CONFIG);
2229
- function SelectLookProvider({ look, borderColor, children }) {
2230
- const value = React41.useMemo(() => ({ look, borderColor }), [look, borderColor]);
2239
+ function SelectLookProvider({ look, borderColor, backgroundColor, textColor, children }) {
2240
+ const value = React41.useMemo(() => ({ look, borderColor, backgroundColor, textColor }), [look, borderColor, backgroundColor, textColor]);
2231
2241
  return /* @__PURE__ */ jsxRuntime.jsx(SelectLookContext.Provider, { value, children });
2232
2242
  }
2233
- function selectLookMetrics({ look, borderColor }, windowWidth) {
2243
+ function selectLookMetrics({ look, borderColor, backgroundColor, textColor }, windowWidth) {
2234
2244
  if (look === "default") {
2235
2245
  return void 0;
2236
2246
  }
2237
2247
  const isPhone = windowWidth < PHONE_MAX_WIDTH;
2248
+ const isChip = look === "chip";
2249
+ const desktopHeight = isChip ? CHIP_DESKTOP_HEIGHT : FIELD_DESKTOP_HEIGHT;
2238
2250
  return {
2239
- height: isPhone ? FIELD_PHONE_HEIGHT : FIELD_DESKTOP_HEIGHT,
2251
+ height: isPhone ? FIELD_PHONE_HEIGHT : desktopHeight,
2240
2252
  paddingHorizontal: FIELD_PAD_H,
2241
2253
  paddingVertical: 0,
2242
2254
  fontSize: FIELD_FONT,
2243
2255
  borderRadius: FIELD_RADIUS,
2244
2256
  chevronRoom: FIELD_CHEVRON_ROOM,
2245
- borderColor
2257
+ hug: isChip,
2258
+ gap: isChip ? CHIP_GAP : void 0,
2259
+ borderColor,
2260
+ backgroundColor,
2261
+ textColor
2246
2262
  };
2247
2263
  }
2248
2264
  function useSelectLookMetrics() {
@@ -2282,10 +2298,10 @@ function lookSelectStyle(fit, m, colors) {
2282
2298
  paddingInlineStart: m.paddingHorizontal,
2283
2299
  paddingInlineEnd: m.chevronRoom,
2284
2300
  borderColor: m.borderColor ?? colors.border,
2285
- backgroundColor: colors.background,
2286
- color: colors.text,
2301
+ backgroundColor: m.backgroundColor ?? colors.background,
2302
+ color: m.textColor ?? colors.text,
2287
2303
  appearance: "none",
2288
- backgroundImage: chevronDataUri(colors.chevron),
2304
+ backgroundImage: chevronDataUri(m.textColor ?? colors.chevron),
2289
2305
  backgroundRepeat: "no-repeat",
2290
2306
  backgroundPosition: `right ${String(CHEVRON_INSET)}px center`,
2291
2307
  backgroundSize: "16px 16px"
@@ -2325,7 +2341,7 @@ function NativeSelect({
2325
2341
  const textColor = hasMatch ? colors.text : colors.textSecondary;
2326
2342
  const fit = native === "fit";
2327
2343
  const metrics = useSelectLookMetrics();
2328
- const selectStyle = metrics === void 0 ? nativeSelectStyle(fit, colors.border, colors.surfaceElevated, textColor) : lookSelectStyle(fit, metrics, { border: colors.border, background: colors.surfaceElevated, text: textColor, chevron: colors.textSecondary });
2344
+ const selectStyle = metrics === void 0 ? nativeSelectStyle(fit, controlBorderOf(theme), colors.surfaceElevated, textColor) : lookSelectStyle(fit, metrics, { border: controlBorderOf(theme), background: colors.surfaceElevated, text: textColor, chevron: colors.textSecondary });
2329
2345
  const handleChange = (event) => onChange(event.target.value);
2330
2346
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, metrics === void 0 ? void 0 : fitStyles.oneLine, style], children: /* @__PURE__ */ jsxRuntime.jsxs(
2331
2347
  "select",
@@ -2383,7 +2399,18 @@ var IS_WEB7 = reactNative.Platform.OS === "web";
2383
2399
  var CHEVRON_DOWN = "\u25BE";
2384
2400
  var CHEVRON_UP = "\u25B4";
2385
2401
  function lookTriggerBox(m) {
2386
- return m === void 0 ? void 0 : { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius };
2402
+ if (m === void 0) return void 0;
2403
+ const hug = m.hug ? { justifyContent: "flex-start", alignSelf: "flex-start", gap: m.gap } : void 0;
2404
+ return { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius, ...hug };
2405
+ }
2406
+ function triggerInk(m, colors, isEmpty) {
2407
+ const themeText = isEmpty ? colors.textSecondary : colors.text;
2408
+ return {
2409
+ border: m?.borderColor ?? colors.controlBorder,
2410
+ background: m?.backgroundColor ?? colors.surfaceElevated,
2411
+ text: m?.textColor ?? themeText,
2412
+ chevron: m?.textColor ?? colors.textSecondary
2413
+ };
2387
2414
  }
2388
2415
  function listboxTriggerAria(testID, hasList, highlighted) {
2389
2416
  return {
@@ -2433,6 +2460,7 @@ function MenuSelectControl({
2433
2460
  [onChange]
2434
2461
  );
2435
2462
  const metrics = useSelectLookMetrics();
2463
+ const ink = triggerInk(metrics, { ...colors, controlBorder: controlBorderOf(theme) }, value === "");
2436
2464
  const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
2437
2465
  const isListbox = menuAnchor !== void 0;
2438
2466
  const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
@@ -2451,11 +2479,11 @@ function MenuSelectControl({
2451
2479
  "aria-labelledby": labelledById,
2452
2480
  onBlur: isListbox ? close : void 0,
2453
2481
  onPress: toggle2,
2454
- style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: metrics?.borderColor ?? colors.border, backgroundColor: colors.surfaceElevated }],
2482
+ style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: ink.border, backgroundColor: ink.background }],
2455
2483
  testID: `${testID}-trigger`,
2456
2484
  children: [
2457
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
2458
- metrics === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN }) : /* @__PURE__ */ jsxRuntime.jsx(SelectChevron, { color: colors.textSecondary, open: isOpen })
2485
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: ink.text }], children: selectedLabel }),
2486
+ 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
2487
  ]
2460
2488
  }
2461
2489
  ),
@@ -2501,7 +2529,7 @@ var SelectField = ({
2501
2529
  ) });
2502
2530
  };
2503
2531
  var REMOVE_GLYPH = "\xD7";
2504
- var CHIP_GAP = 4;
2532
+ var CHIP_GAP2 = 4;
2505
2533
  var CHIP_PAD_H = 8;
2506
2534
  var CHIP_PAD_V = 4;
2507
2535
  var CHIP_RADIUS = 999;
@@ -2510,7 +2538,7 @@ var styles18 = reactNative.StyleSheet.create({
2510
2538
  chip: {
2511
2539
  flexDirection: "row",
2512
2540
  alignItems: "center",
2513
- gap: CHIP_GAP,
2541
+ gap: CHIP_GAP2,
2514
2542
  paddingHorizontal: CHIP_PAD_H,
2515
2543
  paddingVertical: CHIP_PAD_V,
2516
2544
  borderWidth: 1,