@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.mjs CHANGED
@@ -2191,6 +2191,14 @@ var FormCheckbox = ({
2191
2191
  );
2192
2192
  };
2193
2193
 
2194
+ // src/SelectControl/controlBorder.ts
2195
+ var CONTROL_BORDER_SCALE = "controlBorder";
2196
+ var MAIN_STEP2 = "500";
2197
+ function controlBorderOf(theme) {
2198
+ const scale = theme.palette[CONTROL_BORDER_SCALE];
2199
+ return scale?.[MAIN_STEP2] ?? theme.colors.border;
2200
+ }
2201
+
2194
2202
  // src/SearchSelect/SelectSurface.ts
2195
2203
  var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
2196
2204
  SelectSurface2["Sheet"] = "sheet";
@@ -2216,26 +2224,34 @@ var FIELD_PAD_H = 10;
2216
2224
  var FIELD_FONT = 13;
2217
2225
  var FIELD_RADIUS = 8;
2218
2226
  var FIELD_CHEVRON_ROOM = 30;
2227
+ var CHIP_DESKTOP_HEIGHT = 30;
2228
+ var CHIP_GAP = 6;
2219
2229
  var CHEVRON_BOX = 16;
2220
2230
  var DEFAULT_CONFIG = { look: "default" };
2221
2231
  var SelectLookContext = createContext(DEFAULT_CONFIG);
2222
- function SelectLookProvider({ look, borderColor, children }) {
2223
- const value = useMemo(() => ({ look, borderColor }), [look, borderColor]);
2232
+ function SelectLookProvider({ look, borderColor, backgroundColor, textColor, children }) {
2233
+ const value = useMemo(() => ({ look, borderColor, backgroundColor, textColor }), [look, borderColor, backgroundColor, textColor]);
2224
2234
  return /* @__PURE__ */ jsx(SelectLookContext.Provider, { value, children });
2225
2235
  }
2226
- function selectLookMetrics({ look, borderColor }, windowWidth) {
2236
+ function selectLookMetrics({ look, borderColor, backgroundColor, textColor }, windowWidth) {
2227
2237
  if (look === "default") {
2228
2238
  return void 0;
2229
2239
  }
2230
2240
  const isPhone = windowWidth < PHONE_MAX_WIDTH;
2241
+ const isChip = look === "chip";
2242
+ const desktopHeight = isChip ? CHIP_DESKTOP_HEIGHT : FIELD_DESKTOP_HEIGHT;
2231
2243
  return {
2232
- height: isPhone ? FIELD_PHONE_HEIGHT : FIELD_DESKTOP_HEIGHT,
2244
+ height: isPhone ? FIELD_PHONE_HEIGHT : desktopHeight,
2233
2245
  paddingHorizontal: FIELD_PAD_H,
2234
2246
  paddingVertical: 0,
2235
2247
  fontSize: FIELD_FONT,
2236
2248
  borderRadius: FIELD_RADIUS,
2237
2249
  chevronRoom: FIELD_CHEVRON_ROOM,
2238
- borderColor
2250
+ hug: isChip,
2251
+ gap: isChip ? CHIP_GAP : void 0,
2252
+ borderColor,
2253
+ backgroundColor,
2254
+ textColor
2239
2255
  };
2240
2256
  }
2241
2257
  function useSelectLookMetrics() {
@@ -2275,10 +2291,10 @@ function lookSelectStyle(fit, m, colors) {
2275
2291
  paddingInlineStart: m.paddingHorizontal,
2276
2292
  paddingInlineEnd: m.chevronRoom,
2277
2293
  borderColor: m.borderColor ?? colors.border,
2278
- backgroundColor: colors.background,
2279
- color: colors.text,
2294
+ backgroundColor: m.backgroundColor ?? colors.background,
2295
+ color: m.textColor ?? colors.text,
2280
2296
  appearance: "none",
2281
- backgroundImage: chevronDataUri(colors.chevron),
2297
+ backgroundImage: chevronDataUri(m.textColor ?? colors.chevron),
2282
2298
  backgroundRepeat: "no-repeat",
2283
2299
  backgroundPosition: `right ${String(CHEVRON_INSET)}px center`,
2284
2300
  backgroundSize: "16px 16px"
@@ -2318,7 +2334,7 @@ function NativeSelect({
2318
2334
  const textColor = hasMatch ? colors.text : colors.textSecondary;
2319
2335
  const fit = native === "fit";
2320
2336
  const metrics = useSelectLookMetrics();
2321
- 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 });
2337
+ 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 });
2322
2338
  const handleChange = (event) => onChange(event.target.value);
2323
2339
  return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, metrics === void 0 ? void 0 : fitStyles.oneLine, style], children: /* @__PURE__ */ jsxs(
2324
2340
  "select",
@@ -2376,7 +2392,18 @@ var IS_WEB7 = Platform.OS === "web";
2376
2392
  var CHEVRON_DOWN = "\u25BE";
2377
2393
  var CHEVRON_UP = "\u25B4";
2378
2394
  function lookTriggerBox(m) {
2379
- return m === void 0 ? void 0 : { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius };
2395
+ if (m === void 0) return void 0;
2396
+ const hug = m.hug ? { justifyContent: "flex-start", alignSelf: "flex-start", gap: m.gap } : void 0;
2397
+ return { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius, ...hug };
2398
+ }
2399
+ function triggerInk(m, colors, isEmpty) {
2400
+ const themeText = isEmpty ? colors.textSecondary : colors.text;
2401
+ return {
2402
+ border: m?.borderColor ?? colors.controlBorder,
2403
+ background: m?.backgroundColor ?? colors.surfaceElevated,
2404
+ text: m?.textColor ?? themeText,
2405
+ chevron: m?.textColor ?? colors.textSecondary
2406
+ };
2380
2407
  }
2381
2408
  function listboxTriggerAria(testID, hasList, highlighted) {
2382
2409
  return {
@@ -2426,6 +2453,7 @@ function MenuSelectControl({
2426
2453
  [onChange]
2427
2454
  );
2428
2455
  const metrics = useSelectLookMetrics();
2456
+ const ink = triggerInk(metrics, { ...colors, controlBorder: controlBorderOf(theme) }, value === "");
2429
2457
  const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
2430
2458
  const isListbox = menuAnchor !== void 0;
2431
2459
  const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
@@ -2444,11 +2472,11 @@ function MenuSelectControl({
2444
2472
  "aria-labelledby": labelledById,
2445
2473
  onBlur: isListbox ? close : void 0,
2446
2474
  onPress: toggle2,
2447
- style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: metrics?.borderColor ?? colors.border, backgroundColor: colors.surfaceElevated }],
2475
+ style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: ink.border, backgroundColor: ink.background }],
2448
2476
  testID: `${testID}-trigger`,
2449
2477
  children: [
2450
- /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
2451
- metrics === void 0 ? /* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN }) : /* @__PURE__ */ jsx(SelectChevron, { color: colors.textSecondary, open: isOpen })
2478
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: ink.text }], children: selectedLabel }),
2479
+ metrics === void 0 ? /* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: ink.chevron }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN }) : /* @__PURE__ */ jsx(SelectChevron, { color: ink.chevron, open: isOpen })
2452
2480
  ]
2453
2481
  }
2454
2482
  ),
@@ -2494,7 +2522,7 @@ var SelectField = ({
2494
2522
  ) });
2495
2523
  };
2496
2524
  var REMOVE_GLYPH = "\xD7";
2497
- var CHIP_GAP = 4;
2525
+ var CHIP_GAP2 = 4;
2498
2526
  var CHIP_PAD_H = 8;
2499
2527
  var CHIP_PAD_V = 4;
2500
2528
  var CHIP_RADIUS = 999;
@@ -2503,7 +2531,7 @@ var styles18 = StyleSheet.create({
2503
2531
  chip: {
2504
2532
  flexDirection: "row",
2505
2533
  alignItems: "center",
2506
- gap: CHIP_GAP,
2534
+ gap: CHIP_GAP2,
2507
2535
  paddingHorizontal: CHIP_PAD_H,
2508
2536
  paddingVertical: CHIP_PAD_V,
2509
2537
  borderWidth: 1,