@synerise/ds-subtle-form 2.0.4 → 2.1.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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.1.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-subtle-form@2.0.4...@synerise/ds-subtle-form@2.1.0) (2026-09-10)
7
+
8
+ ### Features
9
+
10
+ - **global:** move the pickers to date-fns 4 ([f878075](https://github.com/Synerise/synerise-design/commit/f878075940c2cd0d2d8a4a5603eb18d01f837640))
11
+
6
12
  ## [2.0.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-subtle-form@2.0.3...@synerise/ds-subtle-form@2.0.4) (2026-09-08)
7
13
 
8
14
  **Note:** Version bump only for package @synerise/ds-subtle-form
package/CLAUDE.md CHANGED
@@ -21,7 +21,7 @@ src/
21
21
  DatePicker/DatePicker.tsx — date picker with formatted value display and mask placeholder
22
22
  DatePicker/DatePicker.types.ts — SubtleDatePickerProps
23
23
  DatePicker/DatePicker.styles.ts — SelectContainer, MaskedDatePlaceholder
24
- DatePicker/utils.ts — getFormattingString, replaceLettersWithUnderscore
24
+ DatePicker/utils.ts — replaceLettersWithUnderscore (builds the input mask from a formatted sample)
25
25
  Field/Field.tsx — generic field: renders activeElement() / inactiveElement(); uses useOnClickOutside
26
26
  __specs__/
27
27
  TextArea.spec.tsx — Vitest tests (TextArea only)
@@ -104,7 +104,7 @@ Extends `SubtleFieldProps` + `@synerise/ds-date-picker` props. Additional:
104
104
  | `value` | `Date` | Selected date |
105
105
  | `onApply` | `(date: Date) => void` | Called when date is confirmed; also deactivates the field |
106
106
  | `onClear` | `() => void` | Called on clear; also deactivates |
107
- | `format` | `string` | Date format string (default: `'dd-MM-yyyy'`, or `'dd-MM-yyyy, HH:mm'` when `showTime`) |
107
+ | `valueFormatOptions` | `DateToFormatOptions` | Display options, passed through to `ds-date-picker`. The inactive view formats with the same options as the picker's own input, so both read identically. (The old `format` token prop is removed — it disagreed with the picker for every locale.) |
108
108
  | `placeholder` | `string` | Shown when no value |
109
109
  | `activeProp` | `boolean` | External control of active state |
110
110
 
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { SubtleDatePickerProps } from './DatePicker.types';
3
3
  declare const SubtleDatePicker: {
4
- ({ value, suffix, suffixTooltip, format: dateFormat, label, children, labelTooltip, placeholder, onApply, onClear, errorText, error, activeProp, onDropdownVisibleChange, disabled, ...rest }: SubtleDatePickerProps): React.JSX.Element;
4
+ ({ value, suffix, suffixTooltip, label, children, labelTooltip, placeholder, onApply, onClear, errorText, error, activeProp, onDropdownVisibleChange, disabled, ...rest }: SubtleDatePickerProps): React.JSX.Element;
5
5
  displayName: string;
6
6
  };
7
7
  export default SubtleDatePicker;
@@ -1,17 +1,16 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState, useRef, useMemo, useCallback, useEffect } from "react";
3
- import { useTheme } from "@synerise/ds-core";
4
- import { datePickerFormat, DatePicker } from "@synerise/ds-date-picker";
3
+ import { useTheme, useDataFormat, getDefaultDataTimeOptions } from "@synerise/ds-core";
4
+ import { DatePicker } from "@synerise/ds-date-picker";
5
5
  import Icon, { CalendarM } from "@synerise/ds-icon";
6
6
  import Tooltip from "@synerise/ds-tooltip";
7
7
  import { Subtle, SubtleFormField, Inactive, MainContent, Suffix } from "../../SubtleForm.styles.js";
8
8
  import { SelectContainer, MaskedDatePlaceholder } from "./DatePicker.styles.js";
9
- import { getFormattingString, replaceLettersWithUnderscore } from "./utils.js";
9
+ import { replaceLettersWithUnderscore } from "./utils.js";
10
10
  const SubtleDatePicker = ({
11
11
  value,
12
12
  suffix = true,
13
13
  suffixTooltip,
14
- format: dateFormat,
15
14
  label,
16
15
  children,
17
16
  labelTooltip,
@@ -29,20 +28,23 @@ const SubtleDatePicker = ({
29
28
  const [blurred, setBlurred] = useState(false);
30
29
  const containerRef = useRef(null);
31
30
  const theme = useTheme();
31
+ const {
32
+ formatValue
33
+ } = useDataFormat();
32
34
  const hasError = error || !!errorText;
33
35
  const {
34
- showTime
36
+ showTime,
37
+ valueFormatOptions
35
38
  } = rest;
36
- const dateFormattingString = useMemo(() => getFormattingString(dateFormat, showTime), [dateFormat, showTime]);
37
- const formatValue = useCallback((val) => {
38
- if (!val) {
39
- return "";
40
- }
41
- return datePickerFormat(val, dateFormattingString);
42
- }, [dateFormattingString]);
39
+ const displayOptions = useMemo(() => ({
40
+ ...getDefaultDataTimeOptions(showTime),
41
+ ...valueFormatOptions
42
+ }), [showTime, valueFormatOptions]);
43
+ const formatDisplayValue = useCallback((val) => val ? formatValue(val, displayOptions) : "", [formatValue, displayOptions]);
43
44
  const getDisplayText = useCallback(() => {
44
- return value && !!String(value).trim() ? formatValue(value) : placeholder;
45
- }, [value, placeholder, formatValue]);
45
+ return value && !!String(value).trim() ? formatDisplayValue(value) : placeholder;
46
+ }, [value, placeholder, formatDisplayValue]);
47
+ const maskSample = useMemo(() => formatDisplayValue(new Date(2026, 10, 22, 22, 22)), [formatDisplayValue]);
46
48
  useEffect(() => {
47
49
  if (error) {
48
50
  setActive(false);
@@ -63,14 +65,14 @@ const SubtleDatePicker = ({
63
65
  }, onClear: !disabled ? () => {
64
66
  handleDeactivate();
65
67
  onClear && onClear();
66
- } : void 0, error, errorText, autoFocus: !hasError, format: dateFormat, onDropdownVisibleChange: (visible) => {
68
+ } : void 0, error, errorText, autoFocus: !hasError, onDropdownVisibleChange: (visible) => {
67
69
  setActive(visible);
68
70
  setBlurred(!visible);
69
71
  onDropdownVisibleChange && onDropdownVisibleChange(visible);
70
72
  } }) : /* @__PURE__ */ jsxs(Inactive, { $disabled: disabled, onClick: !disabled ? handleActivate : void 0, $blurred: blurred, $mask: !value, children: [
71
73
  /* @__PURE__ */ jsxs(MainContent, { hasMargin: true, children: [
72
74
  getDisplayText(),
73
- !disabled && /* @__PURE__ */ jsx(MaskedDatePlaceholder, { children: replaceLettersWithUnderscore(dateFormattingString) })
75
+ !disabled && /* @__PURE__ */ jsx(MaskedDatePlaceholder, { children: replaceLettersWithUnderscore(maskSample) })
74
76
  ] }),
75
77
  !active && suffix && /* @__PURE__ */ jsx(Suffix, { select: true, children: /* @__PURE__ */ jsx(Tooltip, { title: suffixTooltip, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CalendarM, {}), color: theme.palette["grey-600"] }) }) })
76
78
  ] }) }) }) });
@@ -5,5 +5,4 @@ export type SubtleDatePickerProps = {
5
5
  activeProp?: boolean;
6
6
  placeholder?: string;
7
7
  children?: ReactNode;
8
- format?: string;
9
8
  } & SubtleFieldProps & DsDatePickerProps;
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Turns a formatted date into a placeholder of the same shape: `08-09-2026` becomes
3
+ * `_ _ - _ _ - _ _ _ _`. Digits are replaced as well as letters, because the sample is a real
4
+ * formatted value rather than a token pattern.
5
+ */
1
6
  export declare const replaceLettersWithUnderscore: (input: string) => string;
2
- export declare const getFormattingString: (formatProp: string | undefined, showTime: boolean | undefined) => string;
@@ -1,13 +1,6 @@
1
1
  const replaceLettersWithUnderscore = (input) => {
2
- return input.replace(/[a-zA-Z]/g, "_ ");
3
- };
4
- const getFormattingString = (formatProp, showTime) => {
5
- if (!formatProp) {
6
- return showTime ? "dd-MM-yyyy, HH:mm" : "dd-MM-yyyy";
7
- }
8
- return formatProp;
2
+ return input.replace(/[a-zA-Z0-9]/g, "_ ");
9
3
  };
10
4
  export {
11
- getFormattingString,
12
5
  replaceLettersWithUnderscore
13
6
  };
@@ -9,7 +9,7 @@ declare const SubtleForm: {
9
9
  displayName: string;
10
10
  };
11
11
  DatePicker: {
12
- ({ value, suffix, suffixTooltip, format: dateFormat, label, children, labelTooltip, placeholder, onApply, onClear, errorText, error, activeProp, onDropdownVisibleChange, disabled, ...rest }: import('./Elements/DatePicker/DatePicker.types').SubtleDatePickerProps): import("react").JSX.Element;
12
+ ({ value, suffix, suffixTooltip, label, children, labelTooltip, placeholder, onApply, onClear, errorText, error, activeProp, onDropdownVisibleChange, disabled, ...rest }: import('./Elements/DatePicker/DatePicker.types').SubtleDatePickerProps): import("react").JSX.Element;
13
13
  displayName: string;
14
14
  };
15
15
  Field: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-subtle-form",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "SubtleForm UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -42,7 +42,7 @@
42
42
  ],
43
43
  "types": "dist/index.d.ts",
44
44
  "dependencies": {
45
- "@synerise/ds-date-picker": "^2.0.3",
45
+ "@synerise/ds-date-picker": "^2.1.0",
46
46
  "@synerise/ds-form-field": "^2.0.2",
47
47
  "@synerise/ds-icon": "^2.1.0",
48
48
  "@synerise/ds-input": "^2.0.3",
@@ -57,5 +57,5 @@
57
57
  "styled-components": "^5.3.3",
58
58
  "vitest": "4"
59
59
  },
60
- "gitHead": "e0dced8fd3a1194eff2fafc1b7e385b29238af88"
60
+ "gitHead": "a49acd96b6f71f5617548ae5ce6126cb9b0985dc"
61
61
  }