@smartsoft001/claude-plugins 2.194.0 → 2.196.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/.claude-plugin/marketplace.json +14 -3
- package/README.md +19 -4
- package/package.json +3 -3
- package/plugins/smart-angular/.claude-plugin/plugin.json +6 -0
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-claude-config.md +13 -9
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/patch-delta.md +1 -1
- package/plugins/{smart → smart-core}/.claude-plugin/README.md +31 -16
- package/plugins/{smart → smart-core}/.claude-plugin/merge-permissions.js +7 -6
- package/plugins/smart-core/.claude-plugin/plugin.json +5 -0
- package/plugins/{smart → smart-core}/.claude-plugin/settings.template.json +2 -2
- package/plugins/{smart → smart-core}/hooks/README.md +1 -1
- package/plugins/{smart → smart-core}/skills/audit-log/SKILL.md +2 -2
- package/plugins/{smart → smart-core}/skills/format-code/SKILL.md +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +6 -0
- package/plugins/smart-react/agents/react-components.md +260 -0
- package/plugins/smart-react/skills/react-components-accordion/SKILL.md +204 -0
- package/plugins/smart-react/skills/react-components-action-panel/SKILL.md +191 -0
- package/plugins/smart-react/skills/react-components-alert/SKILL.md +244 -0
- package/plugins/smart-react/skills/react-components-app/SKILL.md +236 -0
- package/plugins/smart-react/skills/react-components-avatar/SKILL.md +176 -0
- package/plugins/smart-react/skills/react-components-badge/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-breadcrumbs/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-button/SKILL.md +239 -0
- package/plugins/smart-react/skills/react-components-button-group/SKILL.md +187 -0
- package/plugins/smart-react/skills/react-components-calendar/SKILL.md +270 -0
- package/plugins/smart-react/skills/react-components-card/SKILL.md +201 -0
- package/plugins/smart-react/skills/react-components-card-heading/SKILL.md +133 -0
- package/plugins/smart-react/skills/react-components-command-palette/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-container/SKILL.md +134 -0
- package/plugins/smart-react/skills/react-components-date-edit/SKILL.md +186 -0
- package/plugins/smart-react/skills/react-components-date-range/SKILL.md +259 -0
- package/plugins/smart-react/skills/react-components-description-list/SKILL.md +144 -0
- package/plugins/smart-react/skills/react-components-detail/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-components-details/SKILL.md +250 -0
- package/plugins/smart-react/skills/react-components-divider/SKILL.md +128 -0
- package/plugins/smart-react/skills/react-components-drawer/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-dropdown/SKILL.md +194 -0
- package/plugins/smart-react/skills/react-components-empty-state/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-export/SKILL.md +120 -0
- package/plugins/smart-react/skills/react-components-feed/SKILL.md +171 -0
- package/plugins/smart-react/skills/react-components-form/SKILL.md +319 -0
- package/plugins/smart-react/skills/react-components-grid-list/SKILL.md +172 -0
- package/plugins/smart-react/skills/react-components-icon/SKILL.md +117 -0
- package/plugins/smart-react/skills/react-components-import/SKILL.md +113 -0
- package/plugins/smart-react/skills/react-components-info/SKILL.md +147 -0
- package/plugins/smart-react/skills/react-components-input/SKILL.md +406 -0
- package/plugins/smart-react/skills/react-components-list/SKILL.md +384 -0
- package/plugins/smart-react/skills/react-components-list-container/SKILL.md +105 -0
- package/plugins/smart-react/skills/react-components-loader/SKILL.md +126 -0
- package/plugins/smart-react/skills/react-components-media-object/SKILL.md +130 -0
- package/plugins/smart-react/skills/react-components-modal/SKILL.md +266 -0
- package/plugins/smart-react/skills/react-components-multi-column-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-navbar/SKILL.md +211 -0
- package/plugins/smart-react/skills/react-components-notification/SKILL.md +223 -0
- package/plugins/smart-react/skills/react-components-overlays/SKILL.md +182 -0
- package/plugins/smart-react/skills/react-components-page/SKILL.md +224 -0
- package/plugins/smart-react/skills/react-components-page-heading/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-paging/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-password-strength/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-progress-bars/SKILL.md +195 -0
- package/plugins/smart-react/skills/react-components-searchbar/SKILL.md +150 -0
- package/plugins/smart-react/skills/react-components-section-heading/SKILL.md +138 -0
- package/plugins/smart-react/skills/react-components-select-menu/SKILL.md +168 -0
- package/plugins/smart-react/skills/react-components-sidebar-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-sidebar-navigation/SKILL.md +277 -0
- package/plugins/smart-react/skills/react-components-sign-in-form/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-stacked-layout/SKILL.md +146 -0
- package/plugins/smart-react/skills/react-components-stacked-list/SKILL.md +156 -0
- package/plugins/smart-react/skills/react-components-stats/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-table/SKILL.md +222 -0
- package/plugins/smart-react/skills/react-components-tabs/SKILL.md +189 -0
- package/plugins/smart-react/skills/react-components-textarea/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-toggle/SKILL.md +157 -0
- package/plugins/smart-react/skills/react-components-vertical-navigation/SKILL.md +212 -0
- package/plugins/smart-react/skills/react-forms/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-provider/SKILL.md +368 -0
- package/plugins/smart-react/skills/smart-crud-react/SKILL.md +410 -0
- package/plugins/smart/.claude-plugin/plugin.json +0 -5
- /package/plugins/{smart/agents/angular-components/AGENT.md → smart-angular/agents/angular-components.md} +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-accordion/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-action-panel/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-alert/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-avatar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-badge/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-breadcrumbs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button-group/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-calendar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-command-palette/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-container/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-edit/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-range/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-description-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-detail/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-details/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-divider/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-drawer/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-dropdown/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-empty-state/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-feed/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-grid-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-icon/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-info/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-input/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list-container/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-media-object/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-modal/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-multi-column-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-navbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-notification/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-paging/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-password-strength/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-progress-bars/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-searchbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-section-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-select-menu/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sign-in-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stats/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-table/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-tabs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-textarea/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-toggle/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-vertical-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-app.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-shared-lib.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/version-resolution.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/derive-prefix.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/smart-crud/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/CONFIG.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/audit_logger.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/auto_format.sh +0 -0
- /package/plugins/{smart → smart-core}/hooks/hooks.json +0 -0
- /package/plugins/{smart → smart-core}/hooks/safety_validator.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/sensitive_file_blocker.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/skill_validator.py +0 -0
- /package/plugins/{smart → smart-core}/skills/project-conventions/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/skills/safety-check/SKILL.md +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-date-range
|
|
3
|
+
description: SmartDateRange React component API (@smartsoft001/react) — date-range picker for IDateRange ({ start, end } as YYYY-MM-DD) with a scrollable calendar modal (standard) or a popover calendar (variant="preset"), value/onValueChange or a form control, quick-pick buttons, and the useDateRange / useDateRangeModal hooks.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Date Range (`SmartDateRange`)
|
|
8
|
+
|
|
9
|
+
`SmartDateRange` picks a date range, an `IDateRange` from `@smartsoft001/domain-core` (`{ start, end }`, both `YYYY-MM-DD`). Its `variant` picks the rendering: `standard` (default) is a trigger with a clear button that opens `SmartDateRangeModalStandard`, a scrollable calendar of the months around today; `preset` is a trigger opening a popover calendar where the user picks a start and an end day and applies. Bind it with `value` + `onValueChange` (or `defaultValue`), or pass a form `control`. Clearing emits `undefined`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Filtering by a period (from / to) or entering a stay, a contract term, a report range
|
|
14
|
+
- Binding a range to a `SmartFormControl`
|
|
15
|
+
- Using the modal's quick picks (today, last 7 days, this month...) or restricting the range length
|
|
16
|
+
- Building a range picker of your own on `useDateRange` / `useDateRangeModal`
|
|
17
|
+
|
|
18
|
+
## Exports
|
|
19
|
+
|
|
20
|
+
All from `@smartsoft001/react`.
|
|
21
|
+
|
|
22
|
+
| Export | Kind | What it is |
|
|
23
|
+
| ----------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| `SmartDateRange` | component | The date-range picker in the `variant` rendering (`standard`, a trigger opening a scrollable calendar modal, by default; or `preset`, a calendar popover). |
|
|
25
|
+
| `SmartDateRangePreset` | component | Styled date-range variation (preset) based on the Preline "single calendar range" datepicker. |
|
|
26
|
+
| `SmartDateRangeModalStandard` | component | The date-range picker modal: a scrollable calendar of the months around today. |
|
|
27
|
+
| `SmartDateRangeStandard` | component | The default date-range rendering: a trigger showing the range and a clear button; the trigger opens `<SmartDateRangeModalStandard>`, rendered inline. |
|
|
28
|
+
| `useDateRangeModal` | hook | The behaviour of the date-range modal: the scrollable calendar of the `CalendarService`, the picked range and the quick-pick buttons. |
|
|
29
|
+
| `useDateRange` | hook | The behaviour every date-range variant shares: the range value, the open state of the picker and the calendar state the picker is reopened with. |
|
|
30
|
+
|
|
31
|
+
The preset's class helpers (`DATE_RANGE_PRESET_TRIGGER`, `DATE_RANGE_PRESET_CLEAR`, `DATE_RANGE_PRESET_POPOVER`, `DATE_RANGE_PRESET_NAV_BUTTON`, `DATE_RANGE_PRESET_SELECT`, `DATE_RANGE_PRESET_WEEKDAY`, `DATE_RANGE_PRESET_DAY_DEFAULT`, `DATE_RANGE_PRESET_DAY_MUTED`, `DATE_RANGE_PRESET_DAY_SELECTED`, `DATE_RANGE_PRESET_RANGE_BG`, `DATE_RANGE_PRESET_FOOTER`, `DATE_RANGE_PRESET_CANCEL_BUTTON`, `DATE_RANGE_PRESET_APPLY_BUTTON`) are exported too, for a custom implementation that wants the preset look.
|
|
32
|
+
|
|
33
|
+
## Props and Types
|
|
34
|
+
|
|
35
|
+
### `SmartDateRangeProps`
|
|
36
|
+
|
|
37
|
+
Props of `<SmartDateRange>`. Extends `SmartDateRangeVariantProps`.
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Default | Description |
|
|
40
|
+
| ---------- | ---------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `variant?` | `DateRangeVariantName` | `'standard'` | `standard` (trigger + modal) or `preset` (popover calendar). |
|
|
42
|
+
| `control?` | `SmartAbstractControl` | — | Binds the range to a form control: the control's value is shown, a change sets it and marks the control dirty and touched. |
|
|
43
|
+
|
|
44
|
+
### `SmartDateRangeVariantProps`
|
|
45
|
+
|
|
46
|
+
Props of the date-range variants: the range as a controlled `value` + `onValueChange` pair, or kept internally from `defaultValue`.
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
| ---------------- | ------------------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `value?` | `IDateRange \| null` | — | The range. `undefined` leaves the component uncontrolled, starting from `defaultValue`; `null` is an empty controlled value. |
|
|
51
|
+
| `defaultValue?` | `IDateRange \| null` | — | The initial range when uncontrolled. |
|
|
52
|
+
| `onValueChange?` | `(value: IDateRange \| undefined) => void` | — | Emits the applied range, or `undefined` once cleared. |
|
|
53
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
54
|
+
|
|
55
|
+
### `SmartDateRangeModalProps`
|
|
56
|
+
|
|
57
|
+
Props of the date-range modal (`SmartDateRangeModalStandard`).
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Default | Description |
|
|
60
|
+
| ---------------------- | -------------------------------- | ------- | ---------------------------------------------------------------------------- |
|
|
61
|
+
| `showFilterBtns?` | `boolean` | `false` | Shows the quick-pick buttons (today, last 7 days, ...). |
|
|
62
|
+
| `restrictSelectionTo?` | `number` | `0` | When set, only a range of exactly this many days can be applied. |
|
|
63
|
+
| `previousState?` | `CalendarState` | — | The state the modal opens with; without `dateFrom` it selects today. |
|
|
64
|
+
| `onApply?` | `(state: CalendarState) => void` | — | Called with the picked state when the user applies. |
|
|
65
|
+
| `onDismiss?` | `() => void` | — | Called when the modal is closed without applying (backdrop or close button). |
|
|
66
|
+
|
|
67
|
+
### `CalendarState`
|
|
68
|
+
|
|
69
|
+
What the date-range modal applies, and is reopened with.
|
|
70
|
+
|
|
71
|
+
| Field | Type | Default | Description |
|
|
72
|
+
| -------------------- | ----------------------- | -------- | --------------------------------------------------------------- |
|
|
73
|
+
| `dateFrom` | `moment.Moment \| null` | required | Start of the picked range. |
|
|
74
|
+
| `dateTo` | `moment.Moment \| null` | required | End of the picked range. |
|
|
75
|
+
| `scrollPosition` | `number` | required | Scroll position of the modal's calendar, restored on reopening. |
|
|
76
|
+
| `selectedButtonName` | `FilterBtnConstants` | required | The quick-pick button that produced the range. |
|
|
77
|
+
|
|
78
|
+
### `DateRangeModalForm`
|
|
79
|
+
|
|
80
|
+
The modal's form: the shown dates and the picked days.
|
|
81
|
+
|
|
82
|
+
| Field | Type | Default | Description |
|
|
83
|
+
| -------------- | ----------------------- | -------- | --------------------- |
|
|
84
|
+
| `dateFrom` | `string \| null` | required | The shown start date. |
|
|
85
|
+
| `dateTo` | `string \| null` | required | The shown end date. |
|
|
86
|
+
| `startDateRef` | `moment.Moment \| null` | required | The picked start day. |
|
|
87
|
+
| `endDateRef` | `moment.Moment \| null` | required | The picked end day. |
|
|
88
|
+
|
|
89
|
+
### Related types
|
|
90
|
+
|
|
91
|
+
- `DateRangeVariantName`: `'standard' \| 'preset'` — The renderings `SmartDateRange` can pick.
|
|
92
|
+
- `FilterBtnConstants` (enum): `empthyString = '', today = 'Today', yesterday = 'Yesterday', lastSevenDays = 'LastSevenDays', lastThirtyDays = 'LastThirtyDays', thisMonth = 'ThisMonth', lastMonth = 'LastMonth'` — The quick-pick buttons of the modal (the `empthyString` member is spelled that way in the code).
|
|
93
|
+
|
|
94
|
+
`SmartAbstractControl` is described in the `react-forms` and `react-provider` skills.
|
|
95
|
+
|
|
96
|
+
## Binding
|
|
97
|
+
|
|
98
|
+
- **Controlled**: `value` (`IDateRange`, `null` for empty) and `onValueChange(range | undefined)`.
|
|
99
|
+
- **Uncontrolled**: leave `value` undefined; the picker starts from `defaultValue`.
|
|
100
|
+
- **Form control**: `control={someControl}` shows the control's value; a change sets it, marks the control dirty and touched, and still calls `onValueChange`.
|
|
101
|
+
|
|
102
|
+
## Usage
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { useState } from 'react';
|
|
106
|
+
|
|
107
|
+
import { IDateRange } from '@smartsoft001/domain-core';
|
|
108
|
+
import { SmartDateRange, SmartFormControl } from '@smartsoft001/react';
|
|
109
|
+
|
|
110
|
+
const period = new SmartFormControl<IDateRange | null>(null);
|
|
111
|
+
|
|
112
|
+
export function ReportPeriod() {
|
|
113
|
+
const [range, setRange] = useState<IDateRange | null>({
|
|
114
|
+
start: '2026-10-01',
|
|
115
|
+
end: '2026-10-31',
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
{/* Trigger + scrollable calendar modal, controlled. */}
|
|
121
|
+
<SmartDateRange
|
|
122
|
+
value={range}
|
|
123
|
+
onValueChange={(next) => setRange(next ?? null)}
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
{/* Popover calendar. */}
|
|
127
|
+
<SmartDateRange
|
|
128
|
+
variant="preset"
|
|
129
|
+
value={range}
|
|
130
|
+
onValueChange={(next) => setRange(next ?? null)}
|
|
131
|
+
/>
|
|
132
|
+
|
|
133
|
+
{/* Bound to a form control. */}
|
|
134
|
+
<SmartDateRange control={period} />
|
|
135
|
+
</>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Replacing the Implementation
|
|
141
|
+
|
|
142
|
+
`SmartDateRange` has no `SmartProvider` registry key: the `variant` prop picks `SmartDateRangeStandard` or `SmartDateRangePreset`, and both can be rendered directly with `SmartDateRangeVariantProps`. A form's `dateRange` fields render it through the input field components (see `react-components-input`). For another look, write a component on `useDateRange` (and `useDateRangeModal` for the modal's calendar) and render it in place of `SmartDateRange`.
|
|
143
|
+
|
|
144
|
+
### Hooks
|
|
145
|
+
|
|
146
|
+
#### `useDateRangeModal`
|
|
147
|
+
|
|
148
|
+
The behaviour of the date-range modal: the scrollable calendar of the `CalendarService`, the picked range and the quick-pick buttons.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
function useDateRangeModal({
|
|
152
|
+
restrictSelectionTo = 0,
|
|
153
|
+
previousState = EMPTY_STATE,
|
|
154
|
+
onApply,
|
|
155
|
+
onDismiss,
|
|
156
|
+
}: SmartDateRangeModalProps);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
| Returns | Type | Description |
|
|
160
|
+
| ------------------------------ | ----------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
161
|
+
| `elementRef` | `RefObject<HTMLDivElement \| null>` | Attach to the scrollable calendar element. |
|
|
162
|
+
| `calendar` | `month[]` | The months of the `CalendarService` shown in the modal. |
|
|
163
|
+
| `dateForm` | `DateRangeModalForm` | The shown dates and the picked days. |
|
|
164
|
+
| `selectedButtonName` | `FilterBtnConstants` | The active quick pick. |
|
|
165
|
+
| `onDayClick` | `(date: moment.Moment \| null) => void` | Picks a start, then an end day. |
|
|
166
|
+
| `isInRange` | `(day: moment.Moment \| null) => boolean` | Whether a day lies inside the picked range. |
|
|
167
|
+
| `isSelectionStart` | `(day: moment.Moment \| null) => boolean` | Whether a day is the range start. |
|
|
168
|
+
| `isSelectionEnd` | `(day: moment.Moment \| null) => boolean` | Whether a day is the range end. |
|
|
169
|
+
| `isStartAndEndDateSame` | `() => boolean` | Whether start and end are the same day. |
|
|
170
|
+
| `isSelectionInRestrictedRange` | `() => boolean` | Whether the range has exactly `restrictSelectionTo` days (always true without a restriction). |
|
|
171
|
+
| `selectToday` | `() => void` | Quick pick: today. |
|
|
172
|
+
| `selectYesterday` | `() => void` | Quick pick: yesterday. |
|
|
173
|
+
| `selectLastSevenDays` | `() => void` | Quick pick: the last 7 days. |
|
|
174
|
+
| `selectLastThirtyDays` | `() => void` | Quick pick: the last 30 days. |
|
|
175
|
+
| `selectThisMonth` | `() => void` | Quick pick: this month. |
|
|
176
|
+
| `selectLastMonth` | `() => void` | Quick pick: last month. |
|
|
177
|
+
| `dismissPage` | `() => void \| undefined` | Calls `onDismiss`. |
|
|
178
|
+
| `applyDates` | `() => void` | Calls `onApply` with the picked state. |
|
|
179
|
+
|
|
180
|
+
#### `useDateRange`
|
|
181
|
+
|
|
182
|
+
The behaviour every date-range variant shares: the range value, the open state of the picker and the calendar state the picker is reopened with.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
function useDateRange({
|
|
186
|
+
value,
|
|
187
|
+
defaultValue,
|
|
188
|
+
onValueChange,
|
|
189
|
+
}: SmartDateRangeVariantProps);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
| Returns | Type | Description |
|
|
193
|
+
| ---------------- | ------------------------------- | ----------------------------------------------------------------------------------- |
|
|
194
|
+
| `value` | `IDateRange \| undefined` | The current range (controlled or internal), `undefined` when empty. |
|
|
195
|
+
| `isOpen` | `boolean` | Whether the picker is open. |
|
|
196
|
+
| `calendarData` | `CalendarState` | The `CalendarState` the picker reopens with. |
|
|
197
|
+
| `onClick` | `() => void` | Opens the picker. |
|
|
198
|
+
| `onModalApply` | `(data: CalendarState) => void` | Applies a picked `CalendarState`: sets the range, calls `onValueChange` and closes. |
|
|
199
|
+
| `onModalDismiss` | `() => void` | Closes the picker without changing the range. |
|
|
200
|
+
| `onClear` | `() => void` | Clears the range and calls `onValueChange(undefined)`. |
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import {
|
|
204
|
+
SmartDateRangeModalStandard,
|
|
205
|
+
SmartDateRangeVariantProps,
|
|
206
|
+
useDateRange,
|
|
207
|
+
} from '@smartsoft001/react';
|
|
208
|
+
|
|
209
|
+
export function LinkDateRange(props: SmartDateRangeVariantProps) {
|
|
210
|
+
const {
|
|
211
|
+
value,
|
|
212
|
+
isOpen,
|
|
213
|
+
calendarData,
|
|
214
|
+
onClick,
|
|
215
|
+
onModalApply,
|
|
216
|
+
onModalDismiss,
|
|
217
|
+
onClear,
|
|
218
|
+
} = useDateRange(props);
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<span className={props.className}>
|
|
222
|
+
<button type="button" onClick={onClick}>
|
|
223
|
+
{value ? `${value.start} – ${value.end}` : 'Pick dates'}
|
|
224
|
+
</button>
|
|
225
|
+
{value && (
|
|
226
|
+
<button type="button" onClick={onClear}>
|
|
227
|
+
Clear
|
|
228
|
+
</button>
|
|
229
|
+
)}
|
|
230
|
+
{isOpen && (
|
|
231
|
+
<SmartDateRangeModalStandard
|
|
232
|
+
showFilterBtns
|
|
233
|
+
previousState={calendarData}
|
|
234
|
+
onApply={onModalApply}
|
|
235
|
+
onDismiss={onModalDismiss}
|
|
236
|
+
/>
|
|
237
|
+
)}
|
|
238
|
+
</span>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Styling
|
|
244
|
+
|
|
245
|
+
- `SmartDateRangeModalStandard` is `fixed` positioned and rendered inline by the standard trigger; a backdrop click or its close button dismisses it.
|
|
246
|
+
- Both variants carry `smart:dark:` variants; `className` is appended to the root element.
|
|
247
|
+
|
|
248
|
+
## File Locations
|
|
249
|
+
|
|
250
|
+
Source: `packages/shared/react/src/lib/components/date-range/` in the smartsoft001 repository.
|
|
251
|
+
|
|
252
|
+
- `date-range.tsx`: `SmartDateRange`
|
|
253
|
+
- `date-range.types.ts`: `DateRangeVariantName`, `FilterBtnConstants`, `CalendarState`, `SmartDateRangeVariantProps`, `SmartDateRangeProps`, `SmartDateRangeModalProps`
|
|
254
|
+
- `preset/date-range-preset.tsx`: `SmartDateRangePreset`
|
|
255
|
+
- `standard/date-range-modal-standard.tsx`: `SmartDateRangeModalStandard`
|
|
256
|
+
- `standard/date-range-standard.tsx`: `SmartDateRangeStandard`
|
|
257
|
+
- `use-date-range-modal.ts`: `useDateRangeModal`, `DateRangeModalForm`
|
|
258
|
+
- `use-date-range.ts`: `useDateRange`
|
|
259
|
+
- `date-range.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-description-list
|
|
3
|
+
description: SmartDescriptionList React component API (@smartsoft001/react) — label/value rows (dl) with a title, description, per-row value and action slots, attachments and footer slots, the 'description-list' registry key and SmartDescriptionListPreset.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Description List (`SmartDescriptionList`)
|
|
8
|
+
|
|
9
|
+
`SmartDescriptionList` renders a list of label / value pairs (a `<dl>`), with an optional title and description above it and attachments and footer slots below it. A row's `valueTpl` node wins over its `value` text, and `actionTpl` adds an action (e.g. an "Update" link) next to the value. `SmartDescriptionListStandard` is unstyled; `SmartDescriptionListPreset` renders the header, a divided list and the extra sections styled.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Showing the fields of a record read-only (profile, order, applicant) from data you already have
|
|
14
|
+
- Rows with custom value content or an action per row
|
|
15
|
+
- Restyling every description list (the `description-list` registry key)
|
|
16
|
+
|
|
17
|
+
For the fields of a model described with `@Field` decorators, use `SmartDetails` (`react-components-details`) instead: it builds the rows from the metadata.
|
|
18
|
+
|
|
19
|
+
## Exports
|
|
20
|
+
|
|
21
|
+
All from `@smartsoft001/react`.
|
|
22
|
+
|
|
23
|
+
| Export | Kind | What it is |
|
|
24
|
+
| ------------------------------ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `SmartDescriptionList` | component | Renders the implementation registered as `components['description-list']` on `SmartProvider`, `SmartDescriptionListStandard` by default. |
|
|
26
|
+
| `SmartDescriptionListPreset` | component | Preset-styled description list. |
|
|
27
|
+
| `SmartDescriptionListStandard` | component | The default description list rendering: an unstyled title, description, a `<dl>` of label/value items (`valueTpl` wins over `value`, `actionTpl` follows the value) and the attachments and footer slots. |
|
|
28
|
+
|
|
29
|
+
The preset's class helpers (`getDescriptionListListClasses`, `DESCRIPTION_LIST_TITLE_CLASSES`, `DESCRIPTION_LIST_DESCRIPTION_CLASSES`, `DESCRIPTION_LIST_LIST_CLASSES`, `DESCRIPTION_LIST_ROW_CLASSES`, `DESCRIPTION_LIST_TERM_CLASSES`, `DESCRIPTION_LIST_VALUE_CLASSES`, `DESCRIPTION_LIST_ACTION_CLASSES`, `DESCRIPTION_LIST_ATTACHMENTS_CLASSES`, `DESCRIPTION_LIST_FOOTER_CLASSES`) are exported too, for a custom implementation that wants the preset look.
|
|
30
|
+
|
|
31
|
+
## Props and Types
|
|
32
|
+
|
|
33
|
+
### `SmartDescriptionListProps`
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
| ------------ | ------------------------- | ------- | ---------------------------------------------------------- |
|
|
37
|
+
| `options?` | `IDescriptionListOptions` | — | Header, rows and extra sections. |
|
|
38
|
+
| `className?` | `string` | — | Classes on the root element (on the `<dl>` in the preset). |
|
|
39
|
+
|
|
40
|
+
### `IDescriptionListOptions`
|
|
41
|
+
|
|
42
|
+
| Field | Type | Default | Description |
|
|
43
|
+
| ----------------- | ------------------------ | ------- | -------------------------------------------- |
|
|
44
|
+
| `title?` | `string` | — | Heading above the list. |
|
|
45
|
+
| `description?` | `string` | — | Text under the heading. |
|
|
46
|
+
| `items?` | `IDescriptionListItem[]` | `[]` | The rows. |
|
|
47
|
+
| `attachmentsTpl?` | `ReactNode` | — | A section after the rows (e.g. a file list). |
|
|
48
|
+
| `footerTpl?` | `ReactNode` | — | A section at the end. |
|
|
49
|
+
|
|
50
|
+
### `IDescriptionListItem`
|
|
51
|
+
|
|
52
|
+
| Field | Type | Default | Description |
|
|
53
|
+
| ------------ | ----------- | -------- | --------------------------------------- |
|
|
54
|
+
| `label` | `string` | required | The term. |
|
|
55
|
+
| `value?` | `string` | — | The value as text. |
|
|
56
|
+
| `valueTpl?` | `ReactNode` | — | The value as a node; wins over `value`. |
|
|
57
|
+
| `actionTpl?` | `ReactNode` | — | An action next to the value. |
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { SmartDescriptionList } from '@smartsoft001/react';
|
|
63
|
+
|
|
64
|
+
export function ApplicantInfo({ onEditEmail }: { onEditEmail: () => void }) {
|
|
65
|
+
return (
|
|
66
|
+
<SmartDescriptionList
|
|
67
|
+
options={{
|
|
68
|
+
title: 'Applicant information',
|
|
69
|
+
description: 'Personal details and application.',
|
|
70
|
+
items: [
|
|
71
|
+
{ label: 'Full name', value: 'Margot Foster' },
|
|
72
|
+
{
|
|
73
|
+
label: 'Email address',
|
|
74
|
+
value: 'margotfoster@example.com',
|
|
75
|
+
actionTpl: (
|
|
76
|
+
<button type="button" onClick={onEditEmail}>
|
|
77
|
+
Update
|
|
78
|
+
</button>
|
|
79
|
+
),
|
|
80
|
+
},
|
|
81
|
+
{ label: 'Salary expectation', valueTpl: <strong>$120,000</strong> },
|
|
82
|
+
],
|
|
83
|
+
footerTpl: <small>Last updated yesterday</small>,
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Replacing the Implementation
|
|
91
|
+
|
|
92
|
+
`SmartDescriptionList` renders the component registered under the `'description-list'` key of `SmartProvider`'s `components`, and `SmartDescriptionListStandard` when nothing is registered there. Every `SmartDescriptionList` below the provider then renders the registered component, which receives the same props.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import type { ReactNode } from 'react';
|
|
96
|
+
|
|
97
|
+
import { SmartProvider, SmartDescriptionListPreset } from '@smartsoft001/react';
|
|
98
|
+
|
|
99
|
+
// A module constant: a new object on every render would change the context.
|
|
100
|
+
const components = { 'description-list': SmartDescriptionListPreset };
|
|
101
|
+
|
|
102
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
103
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`SmartDescriptionListPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartDescriptionList`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { SmartDescriptionListProps } from '@smartsoft001/react';
|
|
111
|
+
|
|
112
|
+
export function InlineDescriptionList({
|
|
113
|
+
options,
|
|
114
|
+
className,
|
|
115
|
+
}: SmartDescriptionListProps) {
|
|
116
|
+
return (
|
|
117
|
+
<dl className={className}>
|
|
118
|
+
{(options?.items ?? []).map((item) => (
|
|
119
|
+
<div key={item.label}>
|
|
120
|
+
<dt>{item.label}</dt>
|
|
121
|
+
<dd>
|
|
122
|
+
{item.valueTpl ?? item.value} {item.actionTpl}
|
|
123
|
+
</dd>
|
|
124
|
+
</div>
|
|
125
|
+
))}
|
|
126
|
+
</dl>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Styling
|
|
132
|
+
|
|
133
|
+
- `SmartDescriptionListPreset` has no wrapper element: header, `<dl>`, attachments and footer render side by side, and `className` lands on the `<dl>`. It carries `smart:dark:` variants.
|
|
134
|
+
- `SmartDescriptionListStandard` is unstyled markup.
|
|
135
|
+
|
|
136
|
+
## File Locations
|
|
137
|
+
|
|
138
|
+
Source: `packages/shared/react/src/lib/components/description-list/` in the smartsoft001 repository.
|
|
139
|
+
|
|
140
|
+
- `description-list.tsx`: `SmartDescriptionList`
|
|
141
|
+
- `description-list.types.ts`: `SmartDescriptionListProps`
|
|
142
|
+
- `preset/description-list-preset.tsx`: `SmartDescriptionListPreset`
|
|
143
|
+
- `standard/description-list-standard.tsx`: `SmartDescriptionListStandard`
|
|
144
|
+
- `description-list.stories.tsx`: Storybook stories
|