ui-soxo-bootstrap-core 2.4.25-dev.8 → 2.4.25-dev.9
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/core/lib/elements/basic/rangepicker/rangepicker.js +118 -29
- package/package.json +1 -1
- package/README.md +0 -260
|
@@ -1,46 +1,135 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file rangepicker.js
|
|
3
|
+
* @description A reusable, enhanced Ant Design RangePicker component.
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Manual selections require "Apply" button confirmation
|
|
7
|
+
* - Preset ranges apply immediately without confirmation
|
|
8
|
+
* - Optimized state management and event handling
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useCallback, useRef, useState } from 'react';
|
|
12
|
+
import { DatePicker, Space } from 'antd';
|
|
2
13
|
import moment from 'moment-timezone';
|
|
3
14
|
import PropTypes from 'prop-types';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import Button from '../button/button';
|
|
4
17
|
import './rangepicker.scss';
|
|
5
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Enhanced RangePicker with Apply/Cancel controls for manual selections.
|
|
21
|
+
* @param {object} props
|
|
22
|
+
* @param {moment.Moment[]} props.value - Current applied date range
|
|
23
|
+
* @param {function(moment.Moment[]): void} props.onChange - Callback when range is applied
|
|
24
|
+
* @param {string} [props.format='DD/MM/YYYY'] - Date display format
|
|
25
|
+
* @param {object} [props.ranges] - Preset date ranges
|
|
26
|
+
* @param {boolean} [props.allowClear=false] - Whether to show clear button
|
|
27
|
+
* @param {boolean} [props.inputReadOnly=true] - Whether input is read-only
|
|
28
|
+
*/
|
|
29
|
+
|
|
6
30
|
const { RangePicker } = DatePicker;
|
|
7
31
|
|
|
8
|
-
export default function RangePickerComponent({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
32
|
+
export default function RangePickerComponent({
|
|
33
|
+
value,
|
|
34
|
+
onChange,
|
|
35
|
+
format = 'DD/MM/YYYY',
|
|
36
|
+
ranges,
|
|
37
|
+
allowClear = false,
|
|
38
|
+
inputReadOnly = true,
|
|
39
|
+
...restProps
|
|
40
|
+
}) {
|
|
41
|
+
const { t } = useTranslation();
|
|
42
|
+
|
|
43
|
+
// Temporary range during selection (before Apply is clicked)
|
|
44
|
+
const [tempRange, setTempRange] = useState(null);
|
|
45
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
46
|
+
|
|
47
|
+
// Ref to track if a selection just happened, to prevent the picker from closing.
|
|
48
|
+
const selectionJustHappened = useRef(false);
|
|
12
49
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Handles any completed date selection (both manual and preset).
|
|
52
|
+
* It updates the temporary range and sets a flag to keep the picker open.
|
|
53
|
+
*/
|
|
54
|
+
const handleChange = useCallback((dates) => {
|
|
55
|
+
setTempRange(dates || []);
|
|
56
|
+
selectionJustHappened.current = true;
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Handles picker open/close events.
|
|
61
|
+
* Prevents closing after a selection, requiring user to click Apply/Cancel.
|
|
62
|
+
*/
|
|
63
|
+
const handleOpenChange = useCallback((open) => {
|
|
64
|
+
// If the picker is trying to close, check if it was due to a selection.
|
|
65
|
+
if (!open && selectionJustHappened.current) {
|
|
66
|
+
// It was a selection, so ignore the close request and reset the flag.
|
|
67
|
+
selectionJustHappened.current = false;
|
|
16
68
|
return;
|
|
17
69
|
}
|
|
18
70
|
|
|
19
|
-
//
|
|
20
|
-
|
|
71
|
+
// For all other cases (opening, or closing by clicking outside), proceed as normal.
|
|
72
|
+
if (open) {
|
|
73
|
+
// Reset temp range when opening for a fresh selection.
|
|
74
|
+
setTempRange(null);
|
|
75
|
+
}
|
|
76
|
+
setIsOpen(open);
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Applies the temporary range and closes picker
|
|
81
|
+
*/
|
|
82
|
+
const handleApply = useCallback(() => {
|
|
83
|
+
if (tempRange?.length === 2 && onChange) {
|
|
84
|
+
onChange(tempRange);
|
|
85
|
+
}
|
|
86
|
+
selectionJustHappened.current = false; // Clear the flag
|
|
87
|
+
setIsOpen(false);
|
|
88
|
+
}, [tempRange, onChange]);
|
|
21
89
|
|
|
22
|
-
|
|
23
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Cancels selection and closes picker
|
|
92
|
+
*/
|
|
93
|
+
const handleCancel = useCallback(() => {
|
|
94
|
+
selectionJustHappened.current = false; // Clear the flag
|
|
95
|
+
setTempRange(null);
|
|
96
|
+
setIsOpen(false);
|
|
97
|
+
}, []);
|
|
24
98
|
|
|
25
|
-
//
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
99
|
+
// Memoized preset ranges - use provided ranges or default set
|
|
100
|
+
const defaultRanges = useRef({
|
|
101
|
+
Today: [moment(), moment()],
|
|
102
|
+
Yesterday: [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')],
|
|
103
|
+
'This Week': [moment().startOf('week'), moment().endOf('week')],
|
|
104
|
+
'Last Week': [moment().subtract(1, 'week').startOf('week'), moment().subtract(1, 'week').endOf('week')],
|
|
105
|
+
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
106
|
+
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
|
|
107
|
+
}).current;
|
|
30
108
|
|
|
31
109
|
return (
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
110
|
+
<RangePicker
|
|
111
|
+
allowClear={allowClear}
|
|
112
|
+
inputReadOnly={inputReadOnly}
|
|
113
|
+
format={format}
|
|
114
|
+
value={tempRange || value}
|
|
115
|
+
open={isOpen}
|
|
116
|
+
onOpenChange={handleOpenChange}
|
|
117
|
+
onChange={handleChange}
|
|
118
|
+
ranges={ranges !== undefined ? ranges : defaultRanges}
|
|
119
|
+
{...restProps}
|
|
120
|
+
renderExtraFooter={() => (
|
|
121
|
+
<div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end', order: 1 }}>
|
|
122
|
+
<Space>
|
|
123
|
+
<Button size="small" onClick={handleCancel}>
|
|
124
|
+
{t('Cancel')}
|
|
125
|
+
</Button>
|
|
126
|
+
<Button type="primary" size="small" onClick={handleApply}>
|
|
127
|
+
{t('Apply')}
|
|
128
|
+
</Button>
|
|
129
|
+
</Space>
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
/>
|
|
44
133
|
);
|
|
45
134
|
}
|
|
46
135
|
|
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
# 📦 NPM Release Workflow — Task-Based Development → Develop → Master
|
|
2
|
-
|
|
3
|
-
This guide describes the complete workflow for publishing **task-based development builds** and **stable releases** using GitHub Actions, Git tags, and npm versioning.
|
|
4
|
-
|
|
5
|
-
Incorrect versioning or incorrect tags will break the publish pipeline — follow the process exactly.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# 📘 Table of Contents
|
|
10
|
-
- Overview
|
|
11
|
-
- Branch Strategy
|
|
12
|
-
- Task Branch Workflow
|
|
13
|
-
- Versioning Rules
|
|
14
|
-
- Development Release Workflow (`develop`)
|
|
15
|
-
- Promotion Workflow (Dev → Master)
|
|
16
|
-
- Publishing via GitHub Release UI
|
|
17
|
-
- How GitHub Action Detects Release Type
|
|
18
|
-
- Summary Table
|
|
19
|
-
- Common Mistakes & Fixes
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# 🧩 Overview
|
|
24
|
-
|
|
25
|
-
We maintain two release channels:
|
|
26
|
-
|
|
27
|
-
| Channel | Branch | Tag | Purpose |
|
|
28
|
-
|---------------------|----------|------------------|-----------------------|
|
|
29
|
-
| Stable (`latest`) | master | `vX.Y.Z` | Production release |
|
|
30
|
-
| Development (`dev`) | develop | `vX.Y.Z-dev.N` | QA/internal testing |
|
|
31
|
-
|
|
32
|
-
Releases are triggered using Git tags:
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
npm version
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
# 🌿 Branch Strategy
|
|
41
|
-
|
|
42
|
-
## `master`
|
|
43
|
-
- Production-ready code
|
|
44
|
-
- Publishes **stable** builds
|
|
45
|
-
- Versions never include a `dev` suffix
|
|
46
|
-
|
|
47
|
-
## `develop`
|
|
48
|
-
- Used for QA/internal testing
|
|
49
|
-
- Publishes **development** builds
|
|
50
|
-
- Versions always include `-dev.N`
|
|
51
|
-
|
|
52
|
-
## Task Branches
|
|
53
|
-
- Create from `master`
|
|
54
|
-
- Naming: `task/<JIRA-ID>-<description>`
|
|
55
|
-
- After completing work, merge into `develop`
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
# 🏗️ Task Branch Workflow
|
|
60
|
-
|
|
61
|
-
### 1. Create a task branch
|
|
62
|
-
```bash
|
|
63
|
-
git checkout master
|
|
64
|
-
git pull origin master
|
|
65
|
-
git checkout -b task/<JIRA-ID>-<description>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 2. Work on the task
|
|
69
|
-
```bash
|
|
70
|
-
git add .
|
|
71
|
-
git commit -m "TASK-123: Implement XYZ"
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### 3. Merge into develop
|
|
75
|
-
```bash
|
|
76
|
-
git checkout develop
|
|
77
|
-
git pull origin develop
|
|
78
|
-
git merge task/<JIRA-ID>-<description>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
# 🔧 Versioning Rules
|
|
84
|
-
|
|
85
|
-
## Development Versions
|
|
86
|
-
```
|
|
87
|
-
X.Y.Z-dev.N
|
|
88
|
-
```
|
|
89
|
-
Example:
|
|
90
|
-
```
|
|
91
|
-
2.4.30-dev.0
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Stable Versions
|
|
95
|
-
```
|
|
96
|
-
X.Y.Z
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Rules
|
|
100
|
-
- Each version must be unique
|
|
101
|
-
- Dev versions do **not** convert into stable versions
|
|
102
|
-
- Git tag must exactly match `package.json` version
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
# 🟦 Development Release Workflow (`develop`)
|
|
107
|
-
|
|
108
|
-
### 1. Switch to develop
|
|
109
|
-
```bash
|
|
110
|
-
git checkout develop
|
|
111
|
-
git pull origin develop
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 2. Create a new development version
|
|
115
|
-
```bash
|
|
116
|
-
npm version prerelease --preid=dev
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### 3. Push commit + tag
|
|
120
|
-
```bash
|
|
121
|
-
git push --follow-tags
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### 4. GitHub Action publishes dev build
|
|
125
|
-
```
|
|
126
|
-
npm publish --tag dev
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### 5. Install the dev build
|
|
130
|
-
```bash
|
|
131
|
-
npm install soxo-bootstrap-core@dev
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
# 🟩 Promotion Workflow (Dev → Master)
|
|
137
|
-
|
|
138
|
-
### 1. Switch to master
|
|
139
|
-
```bash
|
|
140
|
-
git checkout master
|
|
141
|
-
git pull origin master
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### 2. Merge develop into master
|
|
145
|
-
```bash
|
|
146
|
-
git merge develop
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### 3. Bump the stable version
|
|
150
|
-
```bash
|
|
151
|
-
npm version patch
|
|
152
|
-
# or
|
|
153
|
-
npm version minor
|
|
154
|
-
# or
|
|
155
|
-
npm version major
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### 4. Push with tags
|
|
159
|
-
```bash
|
|
160
|
-
git push --follow-tags
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### 5. GitHub Action publishes stable build
|
|
164
|
-
```
|
|
165
|
-
npm publish
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### 6. Install stable version
|
|
169
|
-
```bash
|
|
170
|
-
npm install soxo-bootstrap-core
|
|
171
|
-
# or
|
|
172
|
-
npm install soxo-bootstrap-core@<version>
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
# 🟧 Publishing via GitHub Release UI
|
|
178
|
-
|
|
179
|
-
### Important
|
|
180
|
-
**The tag must match the `package.json` version exactly**, including the `v` prefix.
|
|
181
|
-
|
|
182
|
-
Example:
|
|
183
|
-
```
|
|
184
|
-
package.json: "version": "2.4.31-dev.0"
|
|
185
|
-
GitHub Tag: v2.4.31-dev.0
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Steps
|
|
191
|
-
|
|
192
|
-
### 1. Ensure `develop` branch is up to date
|
|
193
|
-
Push your changes.
|
|
194
|
-
|
|
195
|
-
### 2. Ensure version contains a dev suffix
|
|
196
|
-
If not:
|
|
197
|
-
```bash
|
|
198
|
-
npm version prerelease --preid=dev
|
|
199
|
-
git push --follow-tags
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### 3. Open GitHub → Releases → Draft a new release
|
|
203
|
-
|
|
204
|
-
### 4. Create tag matching the version
|
|
205
|
-
Example:
|
|
206
|
-
```
|
|
207
|
-
v2.4.31-dev.0
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### 5. Select target branch = `develop`
|
|
211
|
-
|
|
212
|
-
### 6. Title = tag version
|
|
213
|
-
Description is optional.
|
|
214
|
-
|
|
215
|
-
### 7. Publish the release
|
|
216
|
-
Triggers:
|
|
217
|
-
```
|
|
218
|
-
npm publish --tag dev
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
# ⚙️ How GitHub Action Detects Release Type
|
|
224
|
-
|
|
225
|
-
If version contains `dev`:
|
|
226
|
-
```
|
|
227
|
-
npm publish --tag dev
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Otherwise:
|
|
231
|
-
```
|
|
232
|
-
npm publish
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
# 📊 Summary Table
|
|
238
|
-
|
|
239
|
-
| Step | Branch | Command | Tag | Publish Type |
|
|
240
|
-
|--------------------------|----------|------------------------------------------|------------------|--------------|
|
|
241
|
-
| Create task branch | master | `git checkout -b task/<ID>` | — | — |
|
|
242
|
-
| Merge task → develop | develop | `git merge task/<ID>` | — | — |
|
|
243
|
-
| Dev version | develop | `npm version prerelease --preid=dev` | `vX.Y.Z-dev.N` | dev |
|
|
244
|
-
| Publish dev build | develop | `git push --follow-tags` | — | dev |
|
|
245
|
-
| Merge develop → master | master | `git merge develop` | — | — |
|
|
246
|
-
| Stable version | master | `npm version patch/minor/major` | `vX.Y.Z` | latest |
|
|
247
|
-
| Publish stable build | master | `git push --follow-tags` | — | latest |
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
# ⚠️ Common Mistakes & Fixes
|
|
252
|
-
|
|
253
|
-
| Mistake | Issue | Fix |
|
|
254
|
-
|-------------------------------|----------------------|---------------------------------|
|
|
255
|
-
| Tag doesn't match version | Publish fails | Always use `npm version` |
|
|
256
|
-
| Manual tag creation | Version mismatch | Avoid manual tagging |
|
|
257
|
-
| Dev publish from master | Wrong channel | Verify branch before tagging |
|
|
258
|
-
| Not pushing tags | Workflow won’t run | Use `git push --follow-tags` |
|
|
259
|
-
| Merging incomplete tasks | Breaks dev builds | Test before merging |
|
|
260
|
-
|