@capillarytech/blaze-ui 5.1.9 → 5.1.11

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.
@@ -0,0 +1,170 @@
1
+ # CapTimePicker Migration Guide
2
+
3
+ ## Overview
4
+
5
+ CapTimePicker has been migrated to support Ant Design v6 APIs while maintaining backward compatibility with deprecated props from v3-v5.
6
+
7
+ ## Breaking Changes
8
+
9
+ ### API Changes (v3 → v6)
10
+
11
+ | Old API (v3-v5) | New API (v6) | Migration |
12
+ |----------------|--------------|-----------|
13
+ | `allowEmpty` | `allowClear` | Use `allowClear` prop |
14
+ | `addon` | `renderExtraFooter` | Use `renderExtraFooter` prop |
15
+ | `dropdownClassName` | `classNames.popup.root` or `popupClassName` | Use `popupClassName` or `classNames.popup.root` |
16
+ | `popupStyle` (v5) | `styles.popup.root` or `popupStyle` | Use `popupStyle` or `styles.popup.root` |
17
+ | `bordered` | `variant` | Use `variant` prop (`'outlined'`, `'borderless'`, or `'filled'`) |
18
+
19
+ ## Deprecated Props
20
+
21
+ The following props are deprecated but still supported for backward compatibility. They will be removed in the next major version.
22
+
23
+ | Deprecated Prop | Replacement | Notes |
24
+ |----------------|-------------|-------|
25
+ | `allowEmpty` | `allowClear` | Maps to `allowClear` internally |
26
+ | `addon` | `renderExtraFooter` | Maps to `renderExtraFooter` internally |
27
+ | `dropdownClassName` | `popupClassName` or `classNames.popup.root` | Merged with `popupClassName` |
28
+ | `dropdownStyle` | `popupStyle` or `styles.popup.root` | Merged with `popupStyle` |
29
+ | `bordered` | `variant` | `bordered={false}` → `variant="borderless"`, `bordered={true}` → `variant="outlined"` |
30
+
31
+ ## Migration Examples
32
+
33
+ ### Example 1: Basic Usage
34
+
35
+ **Before (v3-v5):**
36
+ ```tsx
37
+ import CapTimePicker from '@capillarytech/blaze-ui/components/CapTimePicker';
38
+
39
+ <CapTimePicker
40
+ value={moment('12:00:00', 'HH:mm:ss')}
41
+ onChange={(time) => console.log(time)}
42
+ allowEmpty={false}
43
+ bordered={true}
44
+ />
45
+ ```
46
+
47
+ **After (v6):**
48
+ ```tsx
49
+ import CapTimePicker from '@capillarytech/blaze-ui/components/CapTimePicker';
50
+ import dayjs from 'dayjs';
51
+
52
+ <CapTimePicker
53
+ value={dayjs('12:00:00', 'HH:mm:ss')}
54
+ onChange={(time) => console.log(time)}
55
+ allowClear={false}
56
+ variant="outlined"
57
+ />
58
+ ```
59
+
60
+ ### Example 2: Custom Popup Styling
61
+
62
+ **Before (v5):**
63
+ ```tsx
64
+ <CapTimePicker
65
+ dropdownClassName="custom-popup"
66
+ dropdownStyle={{ zIndex: 1000 }}
67
+ />
68
+ ```
69
+
70
+ **After (v6) - Option 1 (Direct props):**
71
+ ```tsx
72
+ <CapTimePicker
73
+ popupClassName="custom-popup"
74
+ popupStyle={{ zIndex: 1000 }}
75
+ />
76
+ ```
77
+
78
+ **After (v6) - Option 2 (Object-based API):**
79
+ ```tsx
80
+ <CapTimePicker
81
+ classNames={{
82
+ popup: {
83
+ root: 'custom-popup'
84
+ }
85
+ }}
86
+ styles={{
87
+ popup: {
88
+ root: { zIndex: 1000 }
89
+ }
90
+ }}
91
+ />
92
+ ```
93
+
94
+ ### Example 3: Custom Footer
95
+
96
+ **Before (v5):**
97
+ ```tsx
98
+ <CapTimePicker
99
+ addon={() => <div>Custom Footer</div>}
100
+ />
101
+ ```
102
+
103
+ **After (v6):**
104
+ ```tsx
105
+ <CapTimePicker
106
+ renderExtraFooter={() => <div>Custom Footer</div>}
107
+ />
108
+ ```
109
+
110
+ ## Backward Compatibility
111
+
112
+ All deprecated props are automatically mapped to their new equivalents:
113
+
114
+ - `allowEmpty` → `allowClear`
115
+ - `addon` → `renderExtraFooter`
116
+ - `dropdownClassName` → merged with `popupClassName`
117
+ - `dropdownStyle` → merged with `popupStyle`
118
+ - `bordered` → converted to `variant` (`false` → `'borderless'`, `true` → `'outlined'`)
119
+
120
+ **Note:** Deprecated props will log warnings in development mode when used.
121
+
122
+ ## Moment.js → Day.js Migration
123
+
124
+ CapTimePicker supports both Moment.js and Day.js for backward compatibility:
125
+
126
+ ```tsx
127
+ // Both work:
128
+ <CapTimePicker value={moment('12:00:00', 'HH:mm:ss')} />
129
+ <CapTimePicker value={dayjs('12:00:00', 'HH:mm:ss')} />
130
+ ```
131
+
132
+ However, **Day.js is recommended** as Moment.js is deprecated. The component automatically detects and converts Moment objects to Day.js internally.
133
+
134
+ ## Theme Customization
135
+
136
+ CapTimePicker styling is now handled via design tokens in `getCapThemeConfig.ts`:
137
+
138
+ ```typescript
139
+ components: {
140
+ TimePicker: {
141
+ controlHeight: 40, // Input height
142
+ colorIcon: '#091e42', // Icon color
143
+ },
144
+ }
145
+ ```
146
+
147
+ All previous SCSS overrides have been migrated to design tokens. No `:global` overrides are needed.
148
+
149
+ ## TypeScript Support
150
+
151
+ Full TypeScript support is available:
152
+
153
+ ```tsx
154
+ import CapTimePicker, { CapTimePickerProps } from '@capillarytech/blaze-ui/components/CapTimePicker';
155
+
156
+ const props: CapTimePickerProps = {
157
+ value: dayjs('12:00:00', 'HH:mm:ss'),
158
+ onChange: (time, timeString) => {},
159
+ };
160
+ ```
161
+
162
+ ## Validation
163
+
164
+ This migration has been validated against:
165
+
166
+ - ✅ **SCSS File Content**: No `:global` or `.ant-` overrides without comments
167
+ - ✅ **Theme Config Update**: `getCapThemeConfig.ts` updated with TimePicker tokens
168
+ - ✅ **TypeScript Compilation**: Zero compilation errors
169
+ - ✅ **Backward Compatibility**: All deprecated props supported with warnings
170
+ - ✅ **CSS Modules**: Component uses CSS Modules pattern
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * CapTimePicker
4
+ *
5
+ */
6
+ import React from 'react';
7
+ import type { CapTimePickerProps } from './types';
8
+ declare const CapTimePicker: React.FC<CapTimePickerProps>;
9
+ export default CapTimePicker;
10
+ export type { CapTimePickerProps } from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapTimePicker/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIlD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAwF/C,CAAC;AAEF,eAAe,aAAa,CAAC;AAC7B,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
@@ -179,6 +179,24 @@ module.exports = require("dayjs/plugin/weekYear");
179
179
 
180
180
  /***/ }),
181
181
 
182
+ /***/ 19224:
183
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
184
+
185
+ "use strict";
186
+
187
+
188
+ exports.__esModule = true;
189
+ exports["default"] = logDeprecationWarning;
190
+ var _isNil = _interopRequireDefault(__webpack_require__(69843));
191
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
192
+ function logDeprecationWarning(componentName, deprecatedPropName, deprecatedPropValue, replacementPropName) {
193
+ // @ts-ignore - process.env is provided by webpack/build tools
194
+ if (false) // removed by dead control flow
195
+ {}
196
+ }
197
+
198
+ /***/ }),
199
+
182
200
  /***/ 21020:
183
201
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
184
202
 
@@ -940,6 +958,14 @@ module.exports = require("dayjs/plugin/isBetween");
940
958
 
941
959
  /***/ }),
942
960
 
961
+ /***/ 64273:
962
+ /***/ ((module) => {
963
+
964
+ "use strict";
965
+ module.exports = require("antd-v5");
966
+
967
+ /***/ }),
968
+
943
969
  /***/ 64284:
944
970
  /***/ ((module) => {
945
971
 
@@ -1483,12 +1509,10 @@ var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = __webpack_require__(31601);
1483
1509
  var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(76314);
1484
1510
  var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
1485
1511
  // Module
1486
- ___CSS_LOADER_EXPORT___.push([module.id, `.cap-timepicker-v2 .ant-time-picker-input{height:40px;padding:6px 11px}.cap-timepicker-v2 .ant-time-picker-clock-icon{color:#091e42}`, ""]);
1512
+ ___CSS_LOADER_EXPORT___.push([module.id, `.cap-timepicker-v2 .ant-picker-suffix{color:#091e42}`, ""]);
1487
1513
  // Exports
1488
1514
  ___CSS_LOADER_EXPORT___.locals = {
1489
- "cap-timepicker-v2": `cap-timepicker-v2`,
1490
- "ant-time-picker-input": `ant-time-picker-input`,
1491
- "ant-time-picker-clock-icon": `ant-time-picker-clock-icon`
1515
+ "cap-timepicker-v2": `cap-timepicker-v2`
1492
1516
  };
1493
1517
  module.exports = ___CSS_LOADER_EXPORT___;
1494
1518
 
@@ -1509,14 +1533,6 @@ module.exports = require("dayjs/plugin/isSameOrAfter");
1509
1533
  "use strict";
1510
1534
  module.exports = require("dayjs/plugin/advancedFormat");
1511
1535
 
1512
- /***/ }),
1513
-
1514
- /***/ 97185:
1515
- /***/ ((module) => {
1516
-
1517
- "use strict";
1518
- module.exports = require("antd");
1519
-
1520
1536
  /***/ })
1521
1537
 
1522
1538
  /******/ });
@@ -1613,58 +1629,89 @@ var exports = __webpack_exports__;
1613
1629
 
1614
1630
  exports.__esModule = true;
1615
1631
  exports["default"] = void 0;
1616
- var _antd = __webpack_require__(97185);
1632
+ var _antdV = __webpack_require__(64273);
1617
1633
  var _classnames = _interopRequireDefault(__webpack_require__(46942));
1618
1634
  var _react = _interopRequireDefault(__webpack_require__(9206));
1619
1635
  var _dayjs = __webpack_require__(25549);
1620
- __webpack_require__(83624);
1636
+ var _logDeprecationWarning = _interopRequireDefault(__webpack_require__(19224));
1637
+ var _styles = _interopRequireDefault(__webpack_require__(83624));
1621
1638
  var _jsxRuntime = __webpack_require__(74848);
1622
- const _excluded = ["className", "popupClassName", "value", "defaultValue", "defaultOpenValue", "onChange"];
1639
+ const _excluded = ["className", "popupClassName", "value", "defaultValue", "defaultOpenValue", "onChange", "allowEmpty", "allowClear", "addon", "renderExtraFooter", "dropdownClassName", "dropdownStyle", "popupStyle", "classNames", "styles", "bordered", "variant"];
1623
1640
  /**
1624
1641
  *
1625
1642
  * CapTimePicker
1626
1643
  *
1627
1644
  */
1628
- // import styled from 'styled-components';
1629
1645
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1630
1646
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
1631
1647
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
1632
1648
  const clsPrefix = 'cap-timepicker-v2';
1633
- class CapTimePicker extends _react.default.PureComponent {
1634
- render() {
1635
- const _this$props = this.props,
1636
- {
1637
- className,
1638
- popupClassName,
1639
- value,
1640
- defaultValue,
1641
- defaultOpenValue,
1642
- onChange
1643
- } = _this$props,
1644
- rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
1645
-
1646
- // Detect if consumer is using moment
1647
- const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value) || (0, _dayjs.isMomentObject)(defaultValue) || (0, _dayjs.isMomentObject)(defaultOpenValue);
1648
-
1649
- // Convert moment to dayjs
1650
- const dayjsValue = (0, _dayjs.momentToDayjs)(value);
1651
- const dayjsDefaultValue = (0, _dayjs.momentToDayjs)(defaultValue);
1652
- const dayjsDefaultOpenValue = (0, _dayjs.momentToDayjs)(defaultOpenValue);
1653
- const handleChange = (dayjsTime, timeString) => {
1654
- if (!onChange) return;
1655
- const result = (0, _dayjs.normalizeDateValue)(isConsumerUsingMoment, dayjsTime);
1656
- onChange(result, timeString);
1657
- };
1658
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.TimePicker, _extends({
1659
- className: (0, _classnames.default)(clsPrefix, className),
1660
- popupClassName: (0, _classnames.default)(clsPrefix + "-popup", popupClassName),
1661
- value: dayjsValue,
1662
- defaultValue: dayjsDefaultValue,
1663
- defaultOpenValue: dayjsDefaultOpenValue,
1664
- onChange: handleChange
1665
- }, rest));
1666
- }
1667
- }
1649
+ const CapTimePicker = _ref => {
1650
+ let {
1651
+ className,
1652
+ popupClassName,
1653
+ value,
1654
+ defaultValue,
1655
+ defaultOpenValue,
1656
+ onChange,
1657
+ allowEmpty,
1658
+ allowClear,
1659
+ addon,
1660
+ renderExtraFooter,
1661
+ dropdownClassName,
1662
+ dropdownStyle,
1663
+ popupStyle,
1664
+ classNames: classNamesProp,
1665
+ styles: stylesProp,
1666
+ bordered,
1667
+ variant
1668
+ } = _ref,
1669
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1670
+ // Deprecation warnings
1671
+ (0, _logDeprecationWarning.default)('CapTimePicker', 'allowEmpty', allowEmpty, 'allowClear');
1672
+ (0, _logDeprecationWarning.default)('CapTimePicker', 'addon', addon, 'renderExtraFooter');
1673
+ (0, _logDeprecationWarning.default)('CapTimePicker', 'dropdownClassName', dropdownClassName, 'classNames.popup.root or popupClassName');
1674
+ (0, _logDeprecationWarning.default)('CapTimePicker', 'dropdownStyle', dropdownStyle, 'styles.popup.root or popupStyle');
1675
+ (0, _logDeprecationWarning.default)('CapTimePicker', 'bordered', bordered, 'variant');
1676
+
1677
+ // Detect if consumer is using moment
1678
+ const isConsumerUsingMoment = (0, _dayjs.isMomentObject)(value) || (0, _dayjs.isMomentObject)(defaultValue) || (0, _dayjs.isMomentObject)(defaultOpenValue);
1679
+
1680
+ // Convert moment to dayjs
1681
+ const dayjsValue = (0, _dayjs.momentToDayjs)(value);
1682
+ const dayjsDefaultValue = (0, _dayjs.momentToDayjs)(defaultValue);
1683
+ const dayjsDefaultOpenValue = (0, _dayjs.momentToDayjs)(defaultOpenValue);
1684
+ const handleChange = (dayjsTime, timeString) => {
1685
+ if (!onChange) return;
1686
+ const result = (0, _dayjs.normalizeDateValue)(isConsumerUsingMoment, dayjsTime);
1687
+ onChange(result != null ? result : null, timeString != null ? timeString : null);
1688
+ };
1689
+
1690
+ // Backward compatibility: map deprecated props to new props
1691
+ const finalAllowClear = allowClear != null ? allowClear : allowEmpty;
1692
+ const finalRenderExtraFooter = renderExtraFooter != null ? renderExtraFooter : addon;
1693
+
1694
+ // Backward compatibility: merge deprecated props with new props
1695
+ const finalPopupClassName = (0, _classnames.default)(clsPrefix + "-popup", popupClassName, dropdownClassName);
1696
+ const finalPopupStyle = popupStyle != null ? popupStyle : dropdownStyle;
1697
+
1698
+ // Handle variant prop (v6 API)
1699
+ const finalVariant = variant != null ? variant : bordered === false ? 'borderless' : bordered === true ? 'outlined' : undefined;
1700
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antdV.TimePicker, _extends({
1701
+ className: (0, _classnames.default)(_styles.default[clsPrefix], className),
1702
+ popupClassName: finalPopupClassName,
1703
+ popupStyle: finalPopupStyle,
1704
+ classNames: classNamesProp,
1705
+ styles: stylesProp,
1706
+ variant: finalVariant,
1707
+ value: dayjsValue != null ? dayjsValue : undefined,
1708
+ defaultValue: dayjsDefaultValue != null ? dayjsDefaultValue : undefined,
1709
+ defaultOpenValue: dayjsDefaultOpenValue != null ? dayjsDefaultOpenValue : undefined,
1710
+ onChange: handleChange,
1711
+ allowClear: finalAllowClear,
1712
+ renderExtraFooter: finalRenderExtraFooter
1713
+ }, rest));
1714
+ };
1668
1715
  var _default = exports["default"] = CapTimePicker;
1669
1716
  })();
1670
1717