@tastic/profile 0.16.0 → 0.16.1

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
@@ -30,6 +30,7 @@ interface OptionPickerOption<T extends string> {
30
30
  value: T;
31
31
  label: string;
32
32
  icon?: string;
33
+ color?: string;
33
34
  }
34
35
  declare function getOptionPickerContentSize(optionCount: number, colorSection?: Pick<ProfilePickerColorSection, 'swatches' | 'caption'>): ProfilePickerContentSize;
35
36
  interface OptionPickerProps<T extends string> {
package/dist/index.d.ts CHANGED
@@ -30,6 +30,7 @@ interface OptionPickerOption<T extends string> {
30
30
  value: T;
31
31
  label: string;
32
32
  icon?: string;
33
+ color?: string;
33
34
  }
34
35
  declare function getOptionPickerContentSize(optionCount: number, colorSection?: Pick<ProfilePickerColorSection, 'swatches' | 'caption'>): ProfilePickerContentSize;
35
36
  interface OptionPickerProps<T extends string> {
package/dist/index.js CHANGED
@@ -210,10 +210,10 @@ function PickerMenu({ id, host, color, dark, label, chip, colorSection, homeColo
210
210
  ) })
211
211
  ] });
212
212
  }
213
- function IconRow({ icon, label, selected, color, fg, disabled = false, onPress }) {
213
+ function IconRow({ icon, iconColor, label, selected, color, fg, disabled = false, onPress }) {
214
214
  const textColor = selected ? (0, import_auto_paper2.getContrastColor)(color) : fg;
215
215
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_feedback_press.TouchableRipple, { disabled, onPress, style: [pickerMenuStyles.row, selected && { backgroundColor: color }], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native3.View, { style: [pickerMenuStyles.rowInner, disabled && pickerMenuStyles.rowDisabled], children: [
216
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native3.View, { style: styles3.iconSlot, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper2.Icon, { source: icon, size: 13, color: textColor }) }),
216
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native3.View, { style: styles3.iconSlot, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper2.Icon, { source: icon, size: 13, color: selected ? textColor : iconColor ?? textColor }) }),
217
217
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper2.Text, { style: [pickerMenuStyles.rowLabel, { color: textColor }], numberOfLines: 1, children: label })
218
218
  ] }) });
219
219
  }
@@ -431,7 +431,7 @@ function OptionPicker({ id, host, options, value, onChange, color, dark, icon, r
431
431
  onChange(option.value);
432
432
  host.close();
433
433
  };
434
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PickerMenu, { id, host, color, dark, label: selected?.label ?? "", chip: { icon }, colorSection, contentSize: getOptionPickerContentSize(options.length, colorSection), align, alignOverride, rotation, triggerStyle, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IconRow, { icon: option.icon ?? rowIcon, label: option.label, selected: option.value === value, color, fg, onPress: () => handleSelect(option) }, option.value)) });
434
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PickerMenu, { id, host, color, dark, label: selected?.label ?? "", chip: { icon }, colorSection, contentSize: getOptionPickerContentSize(options.length, colorSection), align, alignOverride, rotation, triggerStyle, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IconRow, { icon: option.icon ?? rowIcon, iconColor: option.color, label: option.label, selected: option.value === value, color, fg, onPress: () => handleSelect(option) }, option.value)) });
435
435
  }
436
436
 
437
437
  // src/ProfileChip.tsx
package/dist/index.mjs CHANGED
@@ -162,10 +162,10 @@ function PickerMenu({ id, host, color, dark, label, chip, colorSection, homeColo
162
162
  ) })
163
163
  ] });
164
164
  }
165
- function IconRow({ icon, label, selected, color, fg, disabled = false, onPress }) {
165
+ function IconRow({ icon, iconColor, label, selected, color, fg, disabled = false, onPress }) {
166
166
  const textColor = selected ? getContrastColor2(color) : fg;
167
167
  return /* @__PURE__ */ jsx4(TouchableRipple, { disabled, onPress, style: [pickerMenuStyles.row, selected && { backgroundColor: color }], children: /* @__PURE__ */ jsxs2(View3, { style: [pickerMenuStyles.rowInner, disabled && pickerMenuStyles.rowDisabled], children: [
168
- /* @__PURE__ */ jsx4(View3, { style: styles3.iconSlot, children: /* @__PURE__ */ jsx4(Icon2, { source: icon, size: 13, color: textColor }) }),
168
+ /* @__PURE__ */ jsx4(View3, { style: styles3.iconSlot, children: /* @__PURE__ */ jsx4(Icon2, { source: icon, size: 13, color: selected ? textColor : iconColor ?? textColor }) }),
169
169
  /* @__PURE__ */ jsx4(Text2, { style: [pickerMenuStyles.rowLabel, { color: textColor }], numberOfLines: 1, children: label })
170
170
  ] }) });
171
171
  }
@@ -383,7 +383,7 @@ function OptionPicker({ id, host, options, value, onChange, color, dark, icon, r
383
383
  onChange(option.value);
384
384
  host.close();
385
385
  };
386
- return /* @__PURE__ */ jsx5(PickerMenu, { id, host, color, dark, label: selected?.label ?? "", chip: { icon }, colorSection, contentSize: getOptionPickerContentSize(options.length, colorSection), align, alignOverride, rotation, triggerStyle, children: options.map((option) => /* @__PURE__ */ jsx5(IconRow, { icon: option.icon ?? rowIcon, label: option.label, selected: option.value === value, color, fg, onPress: () => handleSelect(option) }, option.value)) });
386
+ return /* @__PURE__ */ jsx5(PickerMenu, { id, host, color, dark, label: selected?.label ?? "", chip: { icon }, colorSection, contentSize: getOptionPickerContentSize(options.length, colorSection), align, alignOverride, rotation, triggerStyle, children: options.map((option) => /* @__PURE__ */ jsx5(IconRow, { icon: option.icon ?? rowIcon, iconColor: option.color, label: option.label, selected: option.value === value, color, fg, onPress: () => handleSelect(option) }, option.value)) });
387
387
  }
388
388
 
389
389
  // src/ProfileChip.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tastic/profile",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Player profile identity for local-multiplayer React Native games: a saved name/color/tag a player selects per seat, with a picker, an inline-editable roster screen, and a reusable identity badge, deliberately blind to any app-specific fields (control scheme, stats) an app layers on top",
5
5
  "keywords": [
6
6
  "react-native",
@@ -66,12 +66,12 @@
66
66
  "@infinitetoken/jest-config": "^0.5.2",
67
67
  "@infinitetoken/tsconfig": "^0.6.0",
68
68
  "@rific/auto-paper": "^0.13.3",
69
- "@rific/core": "^0.3.1",
69
+ "@rific/core": "^0.4.0",
70
70
  "@rific/feedback-press": "^0.13.0",
71
71
  "@rific/focus-chain": "^0.4.8",
72
- "@rific/toaster": "^0.8.2",
72
+ "@rific/toaster": "^0.8.3",
73
73
  "@tastic/core": "^0.14.0",
74
- "@tastic/hud": "^0.23.0",
74
+ "@tastic/hud": "^0.24.0",
75
75
  "@testing-library/dom": "^10.4.1",
76
76
  "@testing-library/react": "^16.3.2",
77
77
  "@types/jest": "^30.0.0",
@@ -7,6 +7,10 @@ export interface OptionPickerOption<T extends string> {
7
7
  value: T
8
8
  label: string
9
9
  icon?: string
10
+ // The option's own color (e.g. a difficulty's), for its row's icon while the row isn't the selected
11
+ // one; the selected row still fills with the picker's `color`, its icon contrasting as always.
12
+ // Without it the icon takes the row's text color.
13
+ color?: string
10
14
  }
11
15
 
12
16
  // The popover's content footprint: one row per option, plus (with a `colorSection`) the Color row,
@@ -57,7 +61,7 @@ export function OptionPicker<T extends string>({ id, host, options, value, onCha
57
61
  return (
58
62
  <PickerMenu id={id} host={host} color={color} dark={dark} label={selected?.label ?? ''} chip={{ icon }} colorSection={colorSection} contentSize={getOptionPickerContentSize(options.length, colorSection)} align={align} alignOverride={alignOverride} rotation={rotation} triggerStyle={triggerStyle}>
59
63
  {options.map((option) => (
60
- <IconRow key={option.value} icon={option.icon ?? rowIcon} label={option.label} selected={option.value === value} color={color} fg={fg} onPress={() => handleSelect(option)} />
64
+ <IconRow key={option.value} icon={option.icon ?? rowIcon} iconColor={option.color} label={option.label} selected={option.value === value} color={color} fg={fg} onPress={() => handleSelect(option)} />
61
65
  ))}
62
66
  </PickerMenu>
63
67
  )
@@ -231,6 +231,9 @@ export function PickerMenu({ id, host, color, dark, label, chip, colorSection, h
231
231
 
232
232
  interface IconRowProps {
233
233
  icon: string
234
+ // The icon's color while the row isn't selected (an OptionPicker option's own `color`). Defaults to
235
+ // `fg`, like the label.
236
+ iconColor?: string
234
237
  label: string
235
238
  // Fills the row with `color` (its icon and label then contrast against it).
236
239
  selected: boolean
@@ -244,7 +247,7 @@ interface IconRowProps {
244
247
  // A selected row's own background fills entirely with its identity color - matching how a selected
245
248
  // row reads elsewhere (see @tastic/hud's SectionedDropdown) rather than a checkmark bolted onto an
246
249
  // otherwise-plain row.
247
- export function IconRow({ icon, label, selected, color, fg, disabled = false, onPress }: IconRowProps) {
250
+ export function IconRow({ icon, iconColor, label, selected, color, fg, disabled = false, onPress }: IconRowProps) {
248
251
  const textColor = selected ? getContrastColor(color) : fg
249
252
  return (
250
253
  <TouchableRipple disabled={disabled} onPress={onPress} style={[pickerMenuStyles.row, selected && { backgroundColor: color }]}>
@@ -253,7 +256,7 @@ export function IconRow({ icon, label, selected, color, fg, disabled = false, on
253
256
  circle, but still the same fixed-size slot every row's icon/chip sits in (see ProfileChip's
254
257
  own doc), so this row's icon stays lined up with every other row regardless of selection. */}
255
258
  <View style={styles.iconSlot}>
256
- <Icon source={icon} size={13} color={textColor} />
259
+ <Icon source={icon} size={13} color={selected ? textColor : (iconColor ?? textColor)} />
257
260
  </View>
258
261
  <Text style={[pickerMenuStyles.rowLabel, { color: textColor }]} numberOfLines={1}>
259
262
  {label}