@butternutbox/pawprint-native 0.24.3 → 0.25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butternutbox/pawprint-native",
3
- "version": "0.24.3",
3
+ "version": "0.25.0",
4
4
  "type": "module",
5
5
  "description": "ButternutBox Pawprint Design System - React Native Components",
6
6
  "main": "./dist/index.cjs",
@@ -287,6 +287,45 @@ export const AllDateStates = {
287
287
  )
288
288
  }
289
289
 
290
+ export const CustomMonthLabels = {
291
+ render: () => {
292
+ const { year, month, selectedDate, setSelectedDate, prevMonth, nextMonth } =
293
+ useCalendarState()
294
+
295
+ const CUSTOM_MONTH_NAMES = [
296
+ "January",
297
+ "February",
298
+ "March",
299
+ "April",
300
+ "May",
301
+ "June",
302
+ "July",
303
+ "August",
304
+ "September",
305
+ "October",
306
+ "November",
307
+ "December"
308
+ ]
309
+
310
+ const customMonthLabel = (y: number, m: number): string =>
311
+ `${CUSTOM_MONTH_NAMES[m]} ${y}`
312
+
313
+ return (
314
+ <View style={styles.container}>
315
+ <DatePicker
316
+ year={year}
317
+ month={month}
318
+ selectedDate={selectedDate}
319
+ onDateSelect={setSelectedDate}
320
+ onPrevMonth={prevMonth}
321
+ onNextMonth={nextMonth}
322
+ getMonthLabel={customMonthLabel}
323
+ />
324
+ </View>
325
+ )
326
+ }
327
+ }
328
+
290
329
  const styles = StyleSheet.create({
291
330
  container: {
292
331
  padding: 16
@@ -118,6 +118,7 @@ type DatePickerOwnProps = {
118
118
  showNextControl?: boolean
119
119
  locale?: Locale
120
120
  monthLabel?: string
121
+ getMonthLabel?: (year: number, month: number, locale?: Locale) => string
121
122
  weekDayLabels?: [string, string, string, string, string, string, string]
122
123
  getDateState?: (date: Date) => DateItemState
123
124
  isDateDisabled?: (date: Date) => boolean
@@ -266,6 +267,7 @@ export const DatePicker = React.forwardRef<View, DatePickerProps>(
266
267
  showNextControl = true,
267
268
  locale,
268
269
  monthLabel,
270
+ getMonthLabel,
269
271
  weekDayLabels = DEFAULT_WEEK_LABELS,
270
272
  getDateState,
271
273
  isDateDisabled,
@@ -341,7 +343,9 @@ export const DatePicker = React.forwardRef<View, DatePickerProps>(
341
343
  )
342
344
 
343
345
  const resolvedMonthLabel =
344
- monthLabel ?? getDefaultMonthLabel(year, month, locale)
346
+ monthLabel ??
347
+ getMonthLabel?.(year, month, locale) ??
348
+ getDefaultMonthLabel(year, month, locale)
345
349
 
346
350
  const calendarRows = useMemo(
347
351
  () => buildCalendarGrid(year, month),
@@ -453,7 +453,10 @@ const SelectFieldRoot = React.forwardRef<View, SelectFieldProps>(
453
453
  accessibilityLabel="Search options"
454
454
  />
455
455
  ) : (
456
- <SelectFieldValue placeholder={placeholder} />
456
+ <SelectFieldValue
457
+ placeholder={placeholder}
458
+ hasValue={Boolean(currentValue)}
459
+ />
457
460
  )}
458
461
  </SelectFieldTrigger>
459
462
  {description && (
@@ -6,10 +6,11 @@ import { Typography } from "../../atoms/Typography"
6
6
 
7
7
  type SelectFieldValueProps = {
8
8
  placeholder?: string
9
+ hasValue?: boolean
9
10
  } & Omit<ViewProps, "children">
10
11
 
11
12
  export const SelectFieldValue = React.forwardRef<View, SelectFieldValueProps>(
12
- ({ placeholder, ...rest }, ref) => {
13
+ ({ placeholder, hasValue = true, ...rest }, ref) => {
13
14
  const theme = useTheme()
14
15
  const { colour, field } = theme.tokens.components.inputs
15
16
 
@@ -17,7 +18,9 @@ export const SelectFieldValue = React.forwardRef<View, SelectFieldValueProps>(
17
18
  <View ref={ref} style={{ flex: 1, minWidth: 0 }} {...rest}>
18
19
  <Typography
19
20
  token={field.placeholder.default}
20
- color={colour.field.text.default}
21
+ color={
22
+ hasValue ? colour.field.text.default : colour.field.text.placeholder
23
+ }
21
24
  align="left"
22
25
  >
23
26
  <SelectPrimitive.Value placeholder={placeholder ?? ""} />