@synerise/ds-completed-within 1.2.30 → 1.3.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,16 @@
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
+ # [1.3.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@1.2.31...@synerise/ds-completed-within@1.3.0) (2026-07-24)
7
+
8
+ ### Features
9
+
10
+ - **completed-within:** forward readOnly to the period select ([499dc74](https://github.com/Synerise/synerise-design/commit/499dc74e21afebfb50bc904c262a3230bedbd9b8))
11
+
12
+ ## [1.2.31](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@1.2.30...@synerise/ds-completed-within@1.2.31) (2026-07-23)
13
+
14
+ **Note:** Version bump only for package @synerise/ds-completed-within
15
+
6
16
  ## [1.2.30](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@1.2.29...@synerise/ds-completed-within@1.2.30) (2026-07-16)
7
17
 
8
18
  **Note:** Version bump only for package @synerise/ds-completed-within
package/CLAUDE.md ADDED
@@ -0,0 +1,99 @@
1
+ # CompletedWithin (`@synerise/ds-completed-within`)
2
+
3
+ > A trigger button + dropdown picker that lets the user select a numeric value and a time period (e.g. "Completed within 3 days").
4
+
5
+ ## Package structure
6
+
7
+ ```
8
+ src/
9
+ CompletedWithin.tsx — main component, state management + dropdown orchestration
10
+ CompletedWithin.types.ts — all prop interfaces and shared types
11
+ CompleteWithin.styles.ts — styled-components (note: intentional typo in filename)
12
+ index.ts — public exports
13
+ Settings/
14
+ Settings.tsx — dropdown content: InputNumber + Select for value/period
15
+ Settings.types.ts — SettingsProps (internal use only)
16
+ Settings.styles.ts — styled wrapper for the dropdown panel
17
+ ```
18
+
19
+ ## Public exports
20
+
21
+ ### `CompletedWithin` (default export)
22
+
23
+ No `forwardRef`.
24
+
25
+ | Prop | Type | Default | Description |
26
+ |------|------|---------|-------------|
27
+ | `value` | `PeriodValue` | — | **Required.** Controlled value `{ period, value }`. |
28
+ | `onSetValue` | `(value: PeriodValue) => void` | — | **Required.** Called when dropdown closes with a valid value set. |
29
+ | `text` | `Partial<CompletedWithinTexts>` | see defaults below | Override any label. Merged with react-intl defaults. |
30
+ | `maxValue` | `number` | `undefined` | Upper bound for the numeric input. Value is clamped on dropdown close. |
31
+ | `periods` | `CustomPeriod[]` | Built-in 6 periods | Replaces the default period list entirely when provided. |
32
+ | `placeholder` | `string` | `undefined` | Label shown on the trigger button when no value is set. |
33
+ | `tooltip` | `string` | `undefined` | Tooltip shown on hover over the trigger button. |
34
+ | `readOnly` | `boolean` | `undefined` | Hides the dropdown and clear button; renders trigger only. |
35
+
36
+ ### `PeriodValue` (type)
37
+
38
+ ```ts
39
+ { period: Period; value?: number }
40
+ ```
41
+
42
+ ### `Period` (type)
43
+
44
+ `'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS' | 'MONTHS' | 'YEARS' | string | undefined`
45
+ (uses `LiteralStringUnion` — accepts those literals with IDE autocomplete, but allows any string for custom periods)
46
+
47
+ ### `CustomPeriod` (type)
48
+
49
+ ```ts
50
+ { value: Period; label: ReactNode }
51
+ ```
52
+
53
+ ### `CompletedWithinTexts` (type)
54
+
55
+ | Key | Type | Default |
56
+ |-----|------|---------|
57
+ | `header` | `ReactNode` | `'Completed within'` |
58
+ | `completedLabel` | `ReactNode` | `'Completed within'` |
59
+ | `clear` | `ReactNode` | `'Clear'` |
60
+ | `periodPlaceholder` | `ReactNode` | `'Interval'` |
61
+
62
+ ### `CompletedWithinProps` (type)
63
+
64
+ Re-exported props interface.
65
+
66
+ ## Usage patterns
67
+
68
+ ```tsx
69
+ import CompletedWithin from '@synerise/ds-completed-within';
70
+ import type { PeriodValue } from '@synerise/ds-completed-within';
71
+
72
+ const [value, setValue] = useState<PeriodValue>({ period: undefined, value: undefined });
73
+
74
+ <CompletedWithin
75
+ value={value}
76
+ onSetValue={setValue}
77
+ placeholder="Completed within"
78
+ maxValue={365}
79
+ />
80
+ ```
81
+
82
+ ## Implementation notes
83
+
84
+ - **`onSetValue` fires on dropdown close**, not on each keystroke. The component buffers changes in internal state (`innerValue`, `innerPeriod`) and only calls `onSetValue` when the Dropdown `onOpenChange` fires with `visible: false` AND both `innerValue` and `innerPeriod` are set.
85
+ - **`maxValue` clamping** — if `innerValue > maxValue` when the dropdown closes, `maxValue` is used instead. This happens silently with no validation UI.
86
+ - **Clear button** — only shown when `value.value !== undefined && value.value > 0` AND `readOnly` is false. Calls `onSetValue({ value: undefined, period: undefined })`.
87
+ - **Trigger mode** — renders as `'icon-label'` (clock icon + text) when a value is set or `placeholder` is provided, otherwise `'single-icon'` (clock only).
88
+ - **Default periods** are translated via react-intl using `DS.COMPLETED-WITHIN.{PERIOD}` message IDs. Custom `periods` prop bypasses i18n entirely.
89
+ - **`IntlProvider` required** — uses `useIntl()` directly. Wrap the app in `IntlProvider` or all text will fall back to English defaults.
90
+ - **Filename typo**: styles file is `CompleteWithin.styles.ts` (missing "d"), not `CompletedWithin.styles.ts`.
91
+ - **`DEFAULT_PERIODS`** is exported from `CompletedWithin.tsx` (not re-exported from `index.ts`) — not part of the public API.
92
+
93
+ ## Key dependencies
94
+
95
+ - `@synerise/ds-dropdown` — wraps the Settings panel
96
+ - `@synerise/ds-tooltip` — trigger button hover tooltip (hidden while dropdown is open)
97
+ - `@synerise/ds-input-number` — numeric value input in Settings
98
+ - `@synerise/ds-select` — period selection in Settings
99
+ - `react-intl` — i18n for default labels
@@ -14,21 +14,11 @@ const Settings = ({
14
14
  }) => {
15
15
  return /* @__PURE__ */ jsx(Settings$1, { "data-testid": "completed-within-dropdown", children: /* @__PURE__ */ jsxs(InputGroup, { size: "default", label: text.header, resetMargin: true, compact: true, children: [
16
16
  /* @__PURE__ */ jsx(InputNumber, { size: "small", raw: true, readOnly, value: value.value, onChange: onValueChange, min: 0, max: maxValue ?? Number.MAX_SAFE_INTEGER }),
17
- /* @__PURE__ */ jsx(
18
- Select,
19
- {
20
- size: "default",
21
- value: value.period,
22
- placeholder: text.periodPlaceholder,
23
- onChange: (option) => {
24
- onPeriodChange(option);
25
- },
26
- dropdownStyle: {
27
- minWidth: "150px"
28
- },
29
- children: periods.map((period) => /* @__PURE__ */ jsx(Select.Option, { value: period.value, children: period.label }, period.value))
30
- }
31
- )
17
+ /* @__PURE__ */ jsx(Select, { readOnly, size: "default", value: value.period, placeholder: text.periodPlaceholder, onChange: (option) => {
18
+ onPeriodChange(option);
19
+ }, dropdownStyle: {
20
+ minWidth: "150px"
21
+ }, children: periods.map((period) => /* @__PURE__ */ jsx(Select.Option, { value: period.value, children: period.label }, period.value)) })
32
22
  ] }) });
33
23
  };
34
24
  export {
@@ -3,7 +3,7 @@ import { InputGroupWrapper } from "@synerise/ds-input/dist/InputGroup.styles";
3
3
  const Settings = /* @__PURE__ */ styled.div.withConfig({
4
4
  displayName: "Settingsstyles__Settings",
5
5
  componentId: "sc-11xtzjt-0"
6
- })(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:20px;background-color:", ";max-width:238px;.ant-select-selection-item,.ant-select-selection-placeholder{font-weight:500;}", "{width:100%;}"], (props) => props.theme.palette.white, InputGroupWrapper);
6
+ })(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:20px;background-color:", ";max-width:238px;.ds-select-selection-item,.ds-select-selection-placeholder{font-weight:500;}", "{width:100%;}"], (props) => props.theme.palette.white, InputGroupWrapper);
7
7
  export {
8
8
  Settings
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-completed-within",
3
- "version": "1.2.30",
3
+ "version": "1.3.0",
4
4
  "description": "CompletedWithin UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -17,6 +17,7 @@
17
17
  "files": [
18
18
  "/dist",
19
19
  "CHANGELOG.md",
20
+ "CLAUDE.md",
20
21
  "README.md",
21
22
  "package.json",
22
23
  "LICENSE.md"
@@ -41,14 +42,14 @@
41
42
  ],
42
43
  "types": "dist/index.d.ts",
43
44
  "dependencies": {
44
- "@synerise/ds-button": "^1.5.34",
45
- "@synerise/ds-dropdown": "^1.3.19",
46
- "@synerise/ds-icon": "^1.18.4",
47
- "@synerise/ds-input": "^1.7.12",
48
- "@synerise/ds-input-number": "^1.2.49",
49
- "@synerise/ds-select": "^1.3.33",
50
- "@synerise/ds-tooltip": "^1.5.3",
51
- "@synerise/ds-utils": "^1.10.1"
45
+ "@synerise/ds-button": "^1.5.35",
46
+ "@synerise/ds-dropdown": "^1.3.21",
47
+ "@synerise/ds-icon": "^1.18.5",
48
+ "@synerise/ds-input": "^1.7.14",
49
+ "@synerise/ds-input-number": "^1.2.51",
50
+ "@synerise/ds-select": "^1.4.0",
51
+ "@synerise/ds-tooltip": "^1.5.4",
52
+ "@synerise/ds-utils": "^1.10.2"
52
53
  },
53
54
  "devDependencies": {
54
55
  "vitest": "4"
@@ -60,5 +61,5 @@
60
61
  "react-intl": ">=3.12.0 <= 6.8",
61
62
  "styled-components": "^5.3.3"
62
63
  },
63
- "gitHead": "a81ab6519d49a3dea9c0cfebcdc9104cbb4f4226"
64
+ "gitHead": "018414e0d7ffd102a07f8aa35fa2e2d3d4ed19e2"
64
65
  }