@cleartrip/ct-design-counter 4.0.0 → 4.1.0-SNAPSHOT-native-main.1
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/README.md +72 -0
- package/dist/Counter.d.ts +3 -3
- package/dist/Counter.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/ct-design-counter.browser.cjs.js +1 -1
- package/dist/ct-design-counter.browser.cjs.js.map +1 -1
- package/dist/ct-design-counter.browser.esm.js +1 -1
- package/dist/ct-design-counter.browser.esm.js.map +1 -1
- package/dist/ct-design-counter.cjs.js +40 -42
- package/dist/ct-design-counter.cjs.js.map +1 -1
- package/dist/ct-design-counter.esm.js +37 -38
- package/dist/ct-design-counter.esm.js.map +1 -1
- package/dist/ct-design-counter.umd.js +42 -78
- package/dist/ct-design-counter.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/style.d.ts +26 -2
- package/dist/style.d.ts.map +1 -1
- package/dist/type.d.ts +16 -12
- package/dist/type.d.ts.map +1 -1
- package/package.json +28 -11
- package/src/Counter.tsx +92 -0
- package/src/constants.ts +1 -0
- package/src/index.ts +3 -0
- package/src/style.ts +43 -0
- package/src/type.ts +59 -0
- package/dist/StyledOperationWrapper/StyledOperationWrapper.d.ts +0 -7
- package/dist/StyledOperationWrapper/StyledOperationWrapper.d.ts.map +0 -1
- package/dist/StyledOperationWrapper/index.d.ts +0 -2
- package/dist/StyledOperationWrapper/index.d.ts.map +0 -1
- package/dist/StyledOperationWrapper/style.d.ts +0 -7
- package/dist/StyledOperationWrapper/style.d.ts.map +0 -1
- package/dist/StyledOperationWrapper/type.d.ts +0 -5
- package/dist/StyledOperationWrapper/type.d.ts.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Counter
|
|
2
|
+
|
|
3
|
+
A component for displaying numerical values with increment/decrement controls.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @cleartrip/ct-design-counter
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @cleartrip/ct-design-counter
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Peer dependencies
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Required for all targets
|
|
19
|
+
npm install react
|
|
20
|
+
|
|
21
|
+
# Web only
|
|
22
|
+
npm install react-dom
|
|
23
|
+
|
|
24
|
+
# React Native only
|
|
25
|
+
npm install react-native
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Basic
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Counter } from '@cleartrip/ct-design-counter';
|
|
36
|
+
|
|
37
|
+
function Example() {
|
|
38
|
+
return (
|
|
39
|
+
<Counter>
|
|
40
|
+
{/* Basic usage */}
|
|
41
|
+
</Counter>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Props
|
|
49
|
+
|
|
50
|
+
| Prop | Type | Default | Required | Description |
|
|
51
|
+
|------|------|---------|----------|-------------|
|
|
52
|
+
| `onChange` | `(value: number, operation: CounterOperation) => void` | — | ✅ Yes | Callback function triggered on counter value change. It provides the new |
|
|
53
|
+
| `minimumIntegerDigitsValue` | `number` | — | No | The minimum number of integer digits to be displayed in the value — |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Accessibility
|
|
58
|
+
|
|
59
|
+
- The component follows accessibility best practices
|
|
60
|
+
- Ensure proper ARIA attributes are provided where needed
|
|
61
|
+
- Test with screen readers to ensure usability
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Migration
|
|
66
|
+
|
|
67
|
+
If migrating from a previous version:
|
|
68
|
+
|
|
69
|
+
```diff
|
|
70
|
+
- import { Counter } from 'yagami/core/components';
|
|
71
|
+
+ import { Counter } from '@cleartrip/ct-design-counter';
|
|
72
|
+
```
|
package/dist/Counter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
declare const Counter:
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ICounterProps } from './type';
|
|
3
|
+
declare const Counter: FC<ICounterProps>;
|
|
4
4
|
export default Counter;
|
|
5
5
|
//# sourceMappingURL=Counter.d.ts.map
|
package/dist/Counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Counter.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/Counter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Counter.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/Counter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AAQxC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAUvC,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,aAAa,CAsE9B,CAAC;AAGF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),n=require("react"),i=require("@cleartrip/ct-design-container"),r=require("@cleartrip/ct-design-typography"),t=require("@cleartrip/ct-design-icons"),o=require("@cleartrip/ct-design-theme"),s=require("@cleartrip/ct-design-types");const l=require("@cleartrip/ct-design-style-manager").makeStyles(e=>({root:{display:"flex",flexDirection:"row",alignItems:"center",paddingVertical:null==e?void 0:e.spacing[4],columnGap:null==e?void 0:e.spacing[4]},valueContainer:{display:"flex",alignItems:"center",width:null==e?void 0:e.size[6]},minusIconContainer:{width:null==e?void 0:e.size[8],height:null==e?void 0:e.size[8]},plusIconContainer:{width:null==e?void 0:e.size[8],height:null==e?void 0:e.size[8]}})),a=(e,n)=>e?e.toLocaleString("en-US",{minimumIntegerDigits:n}):"",u=({min:u,max:c,value:C,isDisabled:d=!1,onChange:p,minimumIntegerDigitsValue:g=2,minusIconProps:m,plusIconProps:h,styleConfig:y})=>{const x=o.useTheme(),{root:f=[],minusIconContainer:v=[],valueContainer:j=[],value:I,plusIconContainer:b=[]}=y||{},q=d||C>=c,D=d||C<=u,E=n.useCallback(e=>()=>{let n=C;if(e===s.CounterOperation.DECREMENT){if(D)return;n--}else{if(q)return;n++}p(n,e)},[C,D,q,p]);return e.jsxs(i.Container,{styleConfig:{root:[l.root,...f]},children:[e.jsx(i.Container,{onClick:E(s.CounterOperation.DECREMENT),styleConfig:{root:[l.minusIconContainer,...v]},children:D?e.jsx(t.MinusDisabled,{}):e.jsx(t.MinusCounter,Object.assign({},x.color.counter.enabled,m||{}))}),e.jsx(i.Container,{styleConfig:{root:[l.valueContainer,...j]},children:e.jsx(r.Typography,{variant:"B1",styleConfig:I,children:a(C,g)})}),e.jsx(i.Container,{onClick:E(s.CounterOperation.INCREMENT),styleConfig:{root:[l.plusIconContainer,...b]},children:q?e.jsx(t.PlusDisabled,{}):e.jsx(t.PlusCounter,Object.assign({},x.color.counter.enabled,h||{}))})]})};u.displayName="Counter",Object.defineProperty(exports,"CounterOperation",{enumerable:!0,get:function(){return s.CounterOperation}}),exports.Counter=u;
|
|
2
2
|
//# sourceMappingURL=ct-design-counter.browser.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-design-counter.browser.cjs.js","sources":["../packages/components/Counter/src/
|
|
1
|
+
{"version":3,"file":"ct-design-counter.browser.cjs.js","sources":["../packages/components/Counter/src/style.ts","../packages/components/Counter/src/Counter.tsx"],"sourcesContent":[null,null],"names":["staticStyles","makeStyles","theme","root","display","flexDirection","alignItems","paddingVertical","spacing","columnGap","valueContainer","width","size","minusIconContainer","height","plusIconContainer","getCounterValue","value","minimumIntegerDigitsValue","toLocaleString","minimumIntegerDigits","Counter","min","max","isDisabled","onChange","minusIconProps","plusIconProps","styleConfig","useTheme","rootStyles","minusIconContainerStyles","valueContainerStyles","valueTypographyConfig","plusIconContainerStyles","isIncrementDisabled","isDecrementDisabled","onClickCounter","useCallback","operation","updatedVal","CounterOperation","DECREMENT","_jsxs","Container","children","_jsx","onClick","MinusDisabled","MinusCounter","Object","assign","color","counter","enabled","jsx","Typography","variant","INCREMENT","PlusDisabled","PlusCounter","displayName"],"mappings":"oRAOA,MAAMA,gDAAeC,WAAYC,IACxB,CACLC,KAAM,CACJC,QAAS,OACTC,cAAe,MACfC,WAAY,SACZC,gBAAiBL,aAAK,EAALA,EAAOM,QAAQ,GAChCC,UAAWP,aAAK,EAALA,EAAOM,QAAQ,IAE5BE,eAAgB,CACdN,QAAS,OACTE,WAAY,SACZK,MAAOT,aAAK,EAALA,EAAOU,KAAK,IAErBC,mBAAoB,CAClBF,MAAOT,aAAK,EAALA,EAAOU,KAAK,GACnBE,OAAQZ,aAAK,EAALA,EAAOU,KAAK,IAEtBG,kBAAmB,CACjBJ,MAAOT,aAAK,EAALA,EAAOU,KAAK,GACnBE,OAAQZ,aAAK,EAALA,EAAOU,KAAK,OCZpBI,EAAkB,CAACC,EAAeC,IACtCD,EAAQA,EAAME,eAAe,QAAS,CAAEC,qBAAsBF,IAA+B,GAEzFG,EAA6B,EACjCC,MACAC,MACAN,QACAO,cAAa,EACbC,WACAP,4BAA4B,EAC5BQ,iBACAC,gBACAC,kBAEA,MAAM1B,EAAQ2B,EAAAA,YAGZ1B,KAAM2B,EAAa,GACnBjB,mBAAoBkB,EAA2B,GAC/CrB,eAAg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"react/jsx-runtime";import{useCallback as n}from"react";import{Container as o}from"@cleartrip/ct-design-container";import{Typography as t}from"@cleartrip/ct-design-typography";import{MinusDisabled as r,MinusCounter as l,PlusDisabled as s,PlusCounter as a}from"@cleartrip/ct-design-icons";import{useTheme as c}from"@cleartrip/ct-design-theme";import{CounterOperation as m}from"@cleartrip/ct-design-types";export{CounterOperation}from"@cleartrip/ct-design-types";import{makeStyles as p}from"@cleartrip/ct-design-style-manager";const u=p(i=>({root:{display:"flex",flexDirection:"row",alignItems:"center",paddingVertical:null==i?void 0:i.spacing[4],columnGap:null==i?void 0:i.spacing[4]},valueContainer:{display:"flex",alignItems:"center",width:null==i?void 0:i.size[6]},minusIconContainer:{width:null==i?void 0:i.size[8],height:null==i?void 0:i.size[8]},plusIconContainer:{width:null==i?void 0:i.size[8],height:null==i?void 0:i.size[8]}})),d=(i,e)=>i?i.toLocaleString("en-US",{minimumIntegerDigits:e}):"",g=({min:p,max:g,value:C,isDisabled:f=!1,onChange:h,minimumIntegerDigitsValue:y=2,minusIconProps:v,plusIconProps:I,styleConfig:E})=>{const x=c(),{root:D=[],minusIconContainer:b=[],valueContainer:z=[],value:N,plusIconContainer:w=[]}=E||{},j=f||C>=g,M=f||C<=p,O=n(i=>()=>{let e=C;if(i===m.DECREMENT){if(M)return;e--}else{if(j)return;e++}h(e,i)},[C,M,j,h]);return i(o,{styleConfig:{root:[u.root,...D]},children:[e(o,{onClick:O(m.DECREMENT),styleConfig:{root:[u.minusIconContainer,...b]},children:M?e(r,{}):e(l,Object.assign({},x.color.counter.enabled,v||{}))}),e(o,{styleConfig:{root:[u.valueContainer,...z]},children:e(t,{variant:"B1",styleConfig:N,children:d(C,y)})}),e(o,{onClick:O(m.INCREMENT),styleConfig:{root:[u.plusIconContainer,...w]},children:j?e(s,{}):e(a,Object.assign({},x.color.counter.enabled,I||{}))})]})};g.displayName="Counter";export{g as Counter};
|
|
2
2
|
//# sourceMappingURL=ct-design-counter.browser.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-design-counter.browser.esm.js","sources":["../packages/components/Counter/src/
|
|
1
|
+
{"version":3,"file":"ct-design-counter.browser.esm.js","sources":["../packages/components/Counter/src/style.ts","../packages/components/Counter/src/Counter.tsx"],"sourcesContent":[null,null],"names":["staticStyles","makeStyles","theme","root","display","flexDirection","alignItems","paddingVertical","spacing","columnGap","valueContainer","width","size","minusIconContainer","height","plusIconContainer","getCounterValue","value","minimumIntegerDigitsValue","toLocaleString","minimumIntegerDigits","Counter","min","max","isDisabled","onChange","minusIconProps","plusIconProps","styleConfig","useTheme","rootStyles","minusIconContainerStyles","valueContainerStyles","valueTypographyConfig","plusIconContainerStyles","isIncrementDisabled","isDecrementDisabled","onClickCounter","useCallback","operation","updatedVal","CounterOperation","DECREMENT","_jsxs","Container","children","_jsx","onClick","MinusDisabled","MinusCounter","Object","assign","color","counter","enabled","Typography","variant","INCREMENT","PlusDisabled","PlusCounter","displayName"],"mappings":"2iBAOA,MAAMA,EAAeC,EAAYC,IACxB,CACLC,KAAM,CACJC,QAAS,OACTC,cAAe,MACfC,WAAY,SACZC,gBAAiBL,aAAK,EAALA,EAAOM,QAAQ,GAChCC,UAAWP,aAAK,EAALA,EAAOM,QAAQ,IAE5BE,eAAgB,CACdN,QAAS,OACTE,WAAY,SACZK,MAAOT,aAAK,EAALA,EAAOU,KAAK,IAErBC,mBAAoB,CAClBF,MAAOT,aAAK,EAALA,EAAOU,KAAK,GACnBE,OAAQZ,aAAK,EAALA,EAAOU,KAAK,IAEtBG,kBAAmB,CACjBJ,MAAOT,aAAK,EAALA,EAAOU,KAAK,GACnBE,OAAQZ,aAAK,EAALA,EAAOU,KAAK,OCZpBI,EAAkB,CAACC,EAAeC,IACtCD,EAAQA,EAAME,eAAe,QAAS,CAAEC,qBAAsBF,IAA+B,GAEzFG,EAA6B,EACjCC,MACAC,MACAN,QACAO,cAAa,EACbC,WACAP,4BAA4B,EAC5BQ,iBACAC,gBACAC,kBA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= require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var ctDesignContainer = require('@cleartrip/ct-design-container');
|
|
6
6
|
var ctDesignTypography = require('@cleartrip/ct-design-typography');
|
|
7
|
-
var react = require('react');
|
|
8
|
-
var styled = require('styled-components');
|
|
9
7
|
var ctDesignIcons = require('@cleartrip/ct-design-icons');
|
|
10
8
|
var ctDesignTheme = require('@cleartrip/ct-design-theme');
|
|
11
9
|
var ctDesignTypes = require('@cleartrip/ct-design-types');
|
|
10
|
+
var ctDesignStyleManager = require('@cleartrip/ct-design-style-manager');
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
16
|
-
|
|
17
|
-
var getStyledIconStyles = function (_a) {
|
|
18
|
-
_a.theme; var cursor = _a.cursor;
|
|
12
|
+
const staticStyles = ctDesignStyleManager.makeStyles((theme) => {
|
|
19
13
|
return {
|
|
20
|
-
|
|
14
|
+
root: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
paddingVertical: theme === null || theme === void 0 ? void 0 : theme.spacing[4],
|
|
19
|
+
columnGap: theme === null || theme === void 0 ? void 0 : theme.spacing[4],
|
|
20
|
+
},
|
|
21
|
+
valueContainer: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[6],
|
|
25
|
+
},
|
|
26
|
+
minusIconContainer: {
|
|
27
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
28
|
+
height: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
29
|
+
},
|
|
30
|
+
plusIconContainer: {
|
|
31
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
32
|
+
height: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
33
|
+
},
|
|
21
34
|
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
var StyledOperationWrapper = styled__default.default.i(function (_a) {
|
|
25
|
-
var theme = _a.theme, cursor = _a.cursor, _b = _a.css, css = _b === void 0 ? {} : _b;
|
|
26
|
-
return (tslib.__assign(tslib.__assign({}, getStyledIconStyles({ theme: theme, cursor: cursor })), css));
|
|
27
35
|
});
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
minimumIntegerDigits: minimumIntegerDigitsValue,
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
var Counter = function (_a) {
|
|
41
|
-
var min = _a.min, max = _a.max, value = _a.value, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.minimumIntegerDigitsValue, minimumIntegerDigitsValue = _c === void 0 ? 2 : _c, _d = _a.styleConfig, styleConfig = _d === void 0 ? {} : _d;
|
|
42
|
-
var theme = ctDesignTheme.useTheme();
|
|
43
|
-
var root = styleConfig.root, minusIconContainer = styleConfig.minusIconContainer, minusIcon = styleConfig.minusIcon, valueContainer = styleConfig.valueContainer, valueConfig = styleConfig.value, plusIconContainer = styleConfig.plusIconContainer, plusIcon = styleConfig.plusIcon;
|
|
44
|
-
var isIncrementDisabled = isDisabled || value >= max;
|
|
45
|
-
var isDecrementDisabled = isDisabled || value <= min;
|
|
46
|
-
var onClickCounter = react.useCallback(function (operation) { return function () {
|
|
47
|
-
var updatedVal = value;
|
|
37
|
+
const getCounterValue = (value, minimumIntegerDigitsValue) => value ? value.toLocaleString('en-US', { minimumIntegerDigits: minimumIntegerDigitsValue }) : '';
|
|
38
|
+
const Counter = ({ min, max, value, isDisabled = false, onChange, minimumIntegerDigitsValue = 2, minusIconProps, plusIconProps, styleConfig, }) => {
|
|
39
|
+
const theme = ctDesignTheme.useTheme();
|
|
40
|
+
const { root: rootStyles = [], minusIconContainer: minusIconContainerStyles = [], valueContainer: valueContainerStyles = [], value: valueTypographyConfig, plusIconContainer: plusIconContainerStyles = [], } = styleConfig || {};
|
|
41
|
+
const isIncrementDisabled = isDisabled || value >= max;
|
|
42
|
+
const isDecrementDisabled = isDisabled || value <= min;
|
|
43
|
+
const onClickCounter = react.useCallback((operation) => () => {
|
|
44
|
+
let updatedVal = value;
|
|
48
45
|
if (operation === ctDesignTypes.CounterOperation.DECREMENT) {
|
|
49
|
-
if (
|
|
46
|
+
if (isDecrementDisabled)
|
|
50
47
|
return;
|
|
51
|
-
}
|
|
52
48
|
updatedVal--;
|
|
53
49
|
}
|
|
54
50
|
else {
|
|
55
|
-
if (
|
|
51
|
+
if (isIncrementDisabled)
|
|
56
52
|
return;
|
|
57
|
-
}
|
|
58
53
|
updatedVal++;
|
|
59
54
|
}
|
|
60
55
|
onChange(updatedVal, operation);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var incrementIconStyles = react.useMemo(function () { return getCounterIconStyles(isIncrementDisabled); }, [isIncrementDisabled]);
|
|
64
|
-
return (jsxRuntime.jsxs(ctDesignContainer.Container, tslib.__assign({ display: 'flex', alignItems: 'center', className: root === null || root === void 0 ? void 0 : root.className, css: root === null || root === void 0 ? void 0 : root.css }, { children: [jsxRuntime.jsx(StyledOperationWrapper, tslib.__assign({}, decrementIconStyles, { onClick: onClickCounter(ctDesignTypes.CounterOperation.DECREMENT), className: minusIconContainer === null || minusIconContainer === void 0 ? void 0 : minusIconContainer.className, css: minusIconContainer === null || minusIconContainer === void 0 ? void 0 : minusIconContainer.css }, { children: isDecrementDisabled ? jsxRuntime.jsx(ctDesignIcons.MinusDisabled, {}) : jsxRuntime.jsx(ctDesignIcons.MinusCounter, tslib.__assign({}, theme.color.counter.enabled, minusIcon)) })), jsxRuntime.jsx(ctDesignContainer.Container, tslib.__assign({ paddingLeft: theme.spacing[4], paddingRight: theme.spacing[4], className: valueContainer === null || valueContainer === void 0 ? void 0 : valueContainer.className, css: valueContainer === null || valueContainer === void 0 ? void 0 : valueContainer.css }, { children: jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'B1', styleConfig: valueConfig }, { children: getCounterValue(value, minimumIntegerDigitsValue) })) })), jsxRuntime.jsx(StyledOperationWrapper, tslib.__assign({}, incrementIconStyles, { onClick: onClickCounter(ctDesignTypes.CounterOperation.INCREMENT), className: plusIconContainer === null || plusIconContainer === void 0 ? void 0 : plusIconContainer.className, css: plusIconContainer === null || plusIconContainer === void 0 ? void 0 : plusIconContainer.css }, { children: isIncrementDisabled ? jsxRuntime.jsx(ctDesignIcons.PlusDisabled, {}) : jsxRuntime.jsx(ctDesignIcons.PlusCounter, tslib.__assign({}, theme.color.counter.enabled, plusIcon)) }))] })));
|
|
56
|
+
}, [value, isDecrementDisabled, isIncrementDisabled, onChange]);
|
|
57
|
+
return (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: { root: [staticStyles.root, ...rootStyles] }, children: [jsxRuntime.jsx(ctDesignContainer.Container, { onClick: onClickCounter(ctDesignTypes.CounterOperation.DECREMENT), styleConfig: { root: [staticStyles.minusIconContainer, ...minusIconContainerStyles] }, children: isDecrementDisabled ? (jsxRuntime.jsx(ctDesignIcons.MinusDisabled, {})) : (jsxRuntime.jsx(ctDesignIcons.MinusCounter, Object.assign({}, theme.color.counter.enabled, (minusIconProps || {})))) }), jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticStyles.valueContainer, ...valueContainerStyles] }, children: jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B1', styleConfig: valueTypographyConfig, children: getCounterValue(value, minimumIntegerDigitsValue) }) }), jsxRuntime.jsx(ctDesignContainer.Container, { onClick: onClickCounter(ctDesignTypes.CounterOperation.INCREMENT), styleConfig: { root: [staticStyles.plusIconContainer, ...plusIconContainerStyles] }, children: isIncrementDisabled ? (jsxRuntime.jsx(ctDesignIcons.PlusDisabled, {})) : (jsxRuntime.jsx(ctDesignIcons.PlusCounter, Object.assign({}, theme.color.counter.enabled, (plusIconProps || {})))) })] }));
|
|
65
58
|
};
|
|
59
|
+
Counter.displayName = 'Counter';
|
|
66
60
|
|
|
61
|
+
Object.defineProperty(exports, 'CounterOperation', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return ctDesignTypes.CounterOperation; }
|
|
64
|
+
});
|
|
67
65
|
exports.Counter = Counter;
|
|
68
66
|
//# sourceMappingURL=ct-design-counter.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-design-counter.cjs.js","sources":["../packages/components/Counter/src/
|
|
1
|
+
{"version":3,"file":"ct-design-counter.cjs.js","sources":["../packages/components/Counter/src/style.ts","../packages/components/Counter/src/Counter.tsx"],"sourcesContent":[null,null],"names":["makeStyles","useTheme","useCallback","CounterOperation","_jsxs","Container","_jsx","MinusDisabled","MinusCounter","Typography","PlusDisabled","PlusCounter"],"mappings":";;;;;;;;;;;AAOA,MAAM,YAAY,GAAGA,+BAAU,CAAC,CAAC,KAAK,KAAI;IACxC,OAAO;AACL,QAAA,IAAI,EAAE;AACJ,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,aAAa,EAAE,KAAK;AACpB,YAAA,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;YAClC,SAAS,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;AAC7B,SAAA;AACD,QAAA,cAAc,EAAE;AACd,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,IAAI,CAAC,CAAC,CAAC;A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CAAC,cAAc,EAAE,GAAG,oBAAoB,CAAC,EAAE,EAAA,QAAA,EACtFC,eAACG,6BAAU,EAAA,EAAC,OAAO,EAAC,IAAI,EAAC,WAAW,EAAE,qBAAqB,EAAA,QAAA,EACxD,eAAe,CAAC,KAAK,EAAE,yBAAyB,CAAC,EACvC,CAAA,EAAA,CACH,EAEZH,cAAC,CAAAD,2BAAS,IACR,OAAO,EAAE,cAAc,CAACF,8BAAgB,CAAC,SAAS,CAAC,EACnD,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,iBAAiB,EAAE,GAAG,uBAAuB,CAAC,EAAE,EAElF,QAAA,EAAA,mBAAmB,IAClBG,cAAC,CAAAI,0BAAY,KAAG,KAEhBJ,cAAC,CAAAK,yBAAW,oBAAK,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAO,aAAa,IAAI,EAAE,EAAC,CAAI,CAC5E,EACS,CAAA,CAAA,EAAA,CACF,EACZ;AACJ,EAAE;AAEF,OAAO,CAAC,WAAW,GAAG,SAAS;;;;;;;;"}
|
|
@@ -1,62 +1,61 @@
|
|
|
1
|
-
import { __assign } from 'tslib';
|
|
2
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
3
|
import { Container } from '@cleartrip/ct-design-container';
|
|
4
4
|
import { Typography } from '@cleartrip/ct-design-typography';
|
|
5
|
-
import { useCallback, useMemo } from 'react';
|
|
6
|
-
import styled from 'styled-components';
|
|
7
5
|
import { MinusDisabled, MinusCounter, PlusDisabled, PlusCounter } from '@cleartrip/ct-design-icons';
|
|
8
6
|
import { useTheme } from '@cleartrip/ct-design-theme';
|
|
9
7
|
import { CounterOperation } from '@cleartrip/ct-design-types';
|
|
8
|
+
export { CounterOperation } from '@cleartrip/ct-design-types';
|
|
9
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
_a.theme; var cursor = _a.cursor;
|
|
11
|
+
const staticStyles = makeStyles((theme) => {
|
|
13
12
|
return {
|
|
14
|
-
|
|
13
|
+
root: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
paddingVertical: theme === null || theme === void 0 ? void 0 : theme.spacing[4],
|
|
18
|
+
columnGap: theme === null || theme === void 0 ? void 0 : theme.spacing[4],
|
|
19
|
+
},
|
|
20
|
+
valueContainer: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[6],
|
|
24
|
+
},
|
|
25
|
+
minusIconContainer: {
|
|
26
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
27
|
+
height: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
28
|
+
},
|
|
29
|
+
plusIconContainer: {
|
|
30
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
31
|
+
height: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
32
|
+
},
|
|
15
33
|
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
var StyledOperationWrapper = styled.i(function (_a) {
|
|
19
|
-
var theme = _a.theme, cursor = _a.cursor, _b = _a.css, css = _b === void 0 ? {} : _b;
|
|
20
|
-
return (__assign(__assign({}, getStyledIconStyles({ theme: theme, cursor: cursor })), css));
|
|
21
34
|
});
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
minimumIntegerDigits: minimumIntegerDigitsValue,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var Counter = function (_a) {
|
|
35
|
-
var min = _a.min, max = _a.max, value = _a.value, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.minimumIntegerDigitsValue, minimumIntegerDigitsValue = _c === void 0 ? 2 : _c, _d = _a.styleConfig, styleConfig = _d === void 0 ? {} : _d;
|
|
36
|
-
var theme = useTheme();
|
|
37
|
-
var root = styleConfig.root, minusIconContainer = styleConfig.minusIconContainer, minusIcon = styleConfig.minusIcon, valueContainer = styleConfig.valueContainer, valueConfig = styleConfig.value, plusIconContainer = styleConfig.plusIconContainer, plusIcon = styleConfig.plusIcon;
|
|
38
|
-
var isIncrementDisabled = isDisabled || value >= max;
|
|
39
|
-
var isDecrementDisabled = isDisabled || value <= min;
|
|
40
|
-
var onClickCounter = useCallback(function (operation) { return function () {
|
|
41
|
-
var updatedVal = value;
|
|
36
|
+
const getCounterValue = (value, minimumIntegerDigitsValue) => value ? value.toLocaleString('en-US', { minimumIntegerDigits: minimumIntegerDigitsValue }) : '';
|
|
37
|
+
const Counter = ({ min, max, value, isDisabled = false, onChange, minimumIntegerDigitsValue = 2, minusIconProps, plusIconProps, styleConfig, }) => {
|
|
38
|
+
const theme = useTheme();
|
|
39
|
+
const { root: rootStyles = [], minusIconContainer: minusIconContainerStyles = [], valueContainer: valueContainerStyles = [], value: valueTypographyConfig, plusIconContainer: plusIconContainerStyles = [], } = styleConfig || {};
|
|
40
|
+
const isIncrementDisabled = isDisabled || value >= max;
|
|
41
|
+
const isDecrementDisabled = isDisabled || value <= min;
|
|
42
|
+
const onClickCounter = useCallback((operation) => () => {
|
|
43
|
+
let updatedVal = value;
|
|
42
44
|
if (operation === CounterOperation.DECREMENT) {
|
|
43
|
-
if (
|
|
45
|
+
if (isDecrementDisabled)
|
|
44
46
|
return;
|
|
45
|
-
}
|
|
46
47
|
updatedVal--;
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
|
-
if (
|
|
50
|
+
if (isIncrementDisabled)
|
|
50
51
|
return;
|
|
51
|
-
}
|
|
52
52
|
updatedVal++;
|
|
53
53
|
}
|
|
54
54
|
onChange(updatedVal, operation);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var incrementIconStyles = useMemo(function () { return getCounterIconStyles(isIncrementDisabled); }, [isIncrementDisabled]);
|
|
58
|
-
return (jsxs(Container, __assign({ display: 'flex', alignItems: 'center', className: root === null || root === void 0 ? void 0 : root.className, css: root === null || root === void 0 ? void 0 : root.css }, { children: [jsx(StyledOperationWrapper, __assign({}, decrementIconStyles, { onClick: onClickCounter(CounterOperation.DECREMENT), className: minusIconContainer === null || minusIconContainer === void 0 ? void 0 : minusIconContainer.className, css: minusIconContainer === null || minusIconContainer === void 0 ? void 0 : minusIconContainer.css }, { children: isDecrementDisabled ? jsx(MinusDisabled, {}) : jsx(MinusCounter, __assign({}, theme.color.counter.enabled, minusIcon)) })), jsx(Container, __assign({ paddingLeft: theme.spacing[4], paddingRight: theme.spacing[4], className: valueContainer === null || valueContainer === void 0 ? void 0 : valueContainer.className, css: valueContainer === null || valueContainer === void 0 ? void 0 : valueContainer.css }, { children: jsx(Typography, __assign({ variant: 'B1', styleConfig: valueConfig }, { children: getCounterValue(value, minimumIntegerDigitsValue) })) })), jsx(StyledOperationWrapper, __assign({}, incrementIconStyles, { onClick: onClickCounter(CounterOperation.INCREMENT), className: plusIconContainer === null || plusIconContainer === void 0 ? void 0 : plusIconContainer.className, css: plusIconContainer === null || plusIconContainer === void 0 ? void 0 : plusIconContainer.css }, { children: isIncrementDisabled ? jsx(PlusDisabled, {}) : jsx(PlusCounter, __assign({}, theme.color.counter.enabled, plusIcon)) }))] })));
|
|
55
|
+
}, [value, isDecrementDisabled, isIncrementDisabled, onChange]);
|
|
56
|
+
return (jsxs(Container, { styleConfig: { root: [staticStyles.root, ...rootStyles] }, children: [jsx(Container, { onClick: onClickCounter(CounterOperation.DECREMENT), styleConfig: { root: [staticStyles.minusIconContainer, ...minusIconContainerStyles] }, children: isDecrementDisabled ? (jsx(MinusDisabled, {})) : (jsx(MinusCounter, Object.assign({}, theme.color.counter.enabled, (minusIconProps || {})))) }), jsx(Container, { styleConfig: { root: [staticStyles.valueContainer, ...valueContainerStyles] }, children: jsx(Typography, { variant: 'B1', styleConfig: valueTypographyConfig, children: getCounterValue(value, minimumIntegerDigitsValue) }) }), jsx(Container, { onClick: onClickCounter(CounterOperation.INCREMENT), styleConfig: { root: [staticStyles.plusIconContainer, ...plusIconContainerStyles] }, children: isIncrementDisabled ? (jsx(PlusDisabled, {})) : (jsx(PlusCounter, Object.assign({}, theme.color.counter.enabled, (plusIconProps || {})))) })] }));
|
|
59
57
|
};
|
|
58
|
+
Counter.displayName = 'Counter';
|
|
60
59
|
|
|
61
60
|
export { Counter };
|
|
62
61
|
//# sourceMappingURL=ct-design-counter.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-design-counter.esm.js","sources":["../packages/components/Counter/src/
|
|
1
|
+
{"version":3,"file":"ct-design-counter.esm.js","sources":["../packages/components/Counter/src/style.ts","../packages/components/Counter/src/Counter.tsx"],"sourcesContent":[null,null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAOA,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,KAAK,KAAI;IACxC,OAAO;AACL,QAAA,IAAI,EAAE;AACJ,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,aAAa,EAAE,KAAK;AACpB,YAAA,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;YAClC,SAAS,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,OAAO,CAAC,CAAC,CAAC;AAC7B,SAAA;AACD,QAAA,cAAc,EAAE;AACd,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,IAAI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,YAAY,CAAC,cAAc,EAAE,GAAG,oBAAoB,CAAC,EAAE,EAAA,QAAA,EACtFA,IAAC,UAAU,EAAA,EAAC,OAAO,EAAC,IAAI,EAAC,WAAW,EAAE,qBAAqB,EAAA,QAAA,EACxD,eAAe,CAAC,KAAK,EAAE,yBAAyB,CAAC,EACvC,CAAA,EAAA,CACH,EAEZA,GAAC,CAAA,SAAS,IACR,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACnD,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,iBAAiB,EAAE,GAAG,uBAAuB,CAAC,EAAE,EAElF,QAAA,EAAA,mBAAmB,IAClBA,GAAC,CAAA,YAAY,KAAG,KAEhBA,GAAC,CAAA,WAAW,oBAAK,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAO,aAAa,IAAI,EAAE,EAAC,CAAI,CAC5E,EACS,CAAA,CAAA,EAAA,CACF,EACZ;AACJ,EAAE;AAEF,OAAO,CAAC,WAAW,GAAG,SAAS;;;;"}
|
|
@@ -1,55 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@cleartrip/ct-design-container'), require('@cleartrip/ct-design-typography'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@cleartrip/ct-design-container', '@cleartrip/ct-design-typography', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemCounter = {}, global.jsxRuntime, global.
|
|
5
|
-
})(this, (function (exports, jsxRuntime, ctDesignContainer, ctDesignTypography,
|
|
6
|
-
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
10
|
-
|
|
11
|
-
/******************************************************************************
|
|
12
|
-
Copyright (c) Microsoft Corporation.
|
|
13
|
-
|
|
14
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
-
purpose with or without fee is hereby granted.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
18
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
20
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
21
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
22
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
24
|
-
***************************************************************************** */
|
|
25
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
26
|
-
|
|
27
|
-
var __assign = function () {
|
|
28
|
-
__assign = Object.assign || function __assign(t) {
|
|
29
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
30
|
-
s = arguments[i];
|
|
31
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
};
|
|
35
|
-
return __assign.apply(this, arguments);
|
|
36
|
-
};
|
|
37
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
38
|
-
var e = new Error(message);
|
|
39
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var getStyledIconStyles = function (_a) {
|
|
43
|
-
_a.theme; var cursor = _a.cursor;
|
|
44
|
-
return {
|
|
45
|
-
cursor: cursor,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
var StyledOperationWrapper = styled__default.default.i(function (_a) {
|
|
50
|
-
var theme = _a.theme, cursor = _a.cursor, _b = _a.css, css = _b === void 0 ? {} : _b;
|
|
51
|
-
return (__assign(__assign({}, getStyledIconStyles({ theme: theme, cursor: cursor })), css));
|
|
52
|
-
});
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@cleartrip/ct-design-container'), require('@cleartrip/ct-design-typography'), require('@cleartrip/ct-design-icons'), require('@cleartrip/ct-design-theme'), require('@cleartrip/ct-design-style-manager')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@cleartrip/ct-design-container', '@cleartrip/ct-design-typography', '@cleartrip/ct-design-icons', '@cleartrip/ct-design-theme', '@cleartrip/ct-design-style-manager'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemCounter = {}, global.jsxRuntime, global.React, global.ctDesignContainer, global.ctDesignTypography, global.ctDesignIcons, global.ctDesignTheme, global.ctDesignStyleManager));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, react, ctDesignContainer, ctDesignTypography, ctDesignIcons, ctDesignTheme, ctDesignStyleManager) { 'use strict';
|
|
53
6
|
|
|
54
7
|
var IconPosition;
|
|
55
8
|
(function (IconPosition) {
|
|
@@ -57,49 +10,60 @@
|
|
|
57
10
|
IconPosition["LEFT"] = "left";
|
|
58
11
|
IconPosition["RIGHT"] = "right";
|
|
59
12
|
})(IconPosition || (IconPosition = {}));
|
|
60
|
-
|
|
13
|
+
exports.CounterOperation = void 0;
|
|
61
14
|
(function (CounterOperation) {
|
|
62
15
|
CounterOperation["INCREMENT"] = "INCREMENT";
|
|
63
16
|
CounterOperation["DECREMENT"] = "DECREMENT";
|
|
64
|
-
})(CounterOperation || (CounterOperation = {}));
|
|
17
|
+
})(exports.CounterOperation || (exports.CounterOperation = {}));
|
|
65
18
|
|
|
66
|
-
|
|
19
|
+
const staticStyles = ctDesignStyleManager.makeStyles((theme) => {
|
|
67
20
|
return {
|
|
68
|
-
|
|
21
|
+
root: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
paddingVertical: theme === null || theme === void 0 ? void 0 : theme.spacing[4],
|
|
26
|
+
columnGap: theme === null || theme === void 0 ? void 0 : theme.spacing[4],
|
|
27
|
+
},
|
|
28
|
+
valueContainer: {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[6],
|
|
32
|
+
},
|
|
33
|
+
minusIconContainer: {
|
|
34
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
35
|
+
height: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
36
|
+
},
|
|
37
|
+
plusIconContainer: {
|
|
38
|
+
width: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
39
|
+
height: theme === null || theme === void 0 ? void 0 : theme.size[8],
|
|
40
|
+
},
|
|
69
41
|
};
|
|
70
|
-
};
|
|
42
|
+
});
|
|
71
43
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var isDecrementDisabled = isDisabled || value <= min;
|
|
83
|
-
var onClickCounter = react.useCallback(function (operation) { return function () {
|
|
84
|
-
var updatedVal = value;
|
|
85
|
-
if (operation === CounterOperation.DECREMENT) {
|
|
86
|
-
if (value <= min) {
|
|
44
|
+
const getCounterValue = (value, minimumIntegerDigitsValue) => value ? value.toLocaleString('en-US', { minimumIntegerDigits: minimumIntegerDigitsValue }) : '';
|
|
45
|
+
const Counter = ({ min, max, value, isDisabled = false, onChange, minimumIntegerDigitsValue = 2, minusIconProps, plusIconProps, styleConfig, }) => {
|
|
46
|
+
const theme = ctDesignTheme.useTheme();
|
|
47
|
+
const { root: rootStyles = [], minusIconContainer: minusIconContainerStyles = [], valueContainer: valueContainerStyles = [], value: valueTypographyConfig, plusIconContainer: plusIconContainerStyles = [], } = styleConfig || {};
|
|
48
|
+
const isIncrementDisabled = isDisabled || value >= max;
|
|
49
|
+
const isDecrementDisabled = isDisabled || value <= min;
|
|
50
|
+
const onClickCounter = react.useCallback((operation) => () => {
|
|
51
|
+
let updatedVal = value;
|
|
52
|
+
if (operation === exports.CounterOperation.DECREMENT) {
|
|
53
|
+
if (isDecrementDisabled)
|
|
87
54
|
return;
|
|
88
|
-
}
|
|
89
55
|
updatedVal--;
|
|
90
56
|
}
|
|
91
57
|
else {
|
|
92
|
-
if (
|
|
58
|
+
if (isIncrementDisabled)
|
|
93
59
|
return;
|
|
94
|
-
}
|
|
95
60
|
updatedVal++;
|
|
96
61
|
}
|
|
97
62
|
onChange(updatedVal, operation);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var incrementIconStyles = react.useMemo(function () { return getCounterIconStyles(isIncrementDisabled); }, [isIncrementDisabled]);
|
|
101
|
-
return (jsxRuntime.jsxs(ctDesignContainer.Container, __assign({ display: 'flex', alignItems: 'center', className: root === null || root === void 0 ? void 0 : root.className, css: root === null || root === void 0 ? void 0 : root.css }, { children: [jsxRuntime.jsx(StyledOperationWrapper, __assign({}, decrementIconStyles, { onClick: onClickCounter(CounterOperation.DECREMENT), className: minusIconContainer === null || minusIconContainer === void 0 ? void 0 : minusIconContainer.className, css: minusIconContainer === null || minusIconContainer === void 0 ? void 0 : minusIconContainer.css }, { children: isDecrementDisabled ? jsxRuntime.jsx(ctDesignIcons.MinusDisabled, {}) : jsxRuntime.jsx(ctDesignIcons.MinusCounter, __assign({}, theme.color.counter.enabled, minusIcon)) })), jsxRuntime.jsx(ctDesignContainer.Container, __assign({ paddingLeft: theme.spacing[4], paddingRight: theme.spacing[4], className: valueContainer === null || valueContainer === void 0 ? void 0 : valueContainer.className, css: valueContainer === null || valueContainer === void 0 ? void 0 : valueContainer.css }, { children: jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: 'B1', styleConfig: valueConfig }, { children: getCounterValue(value, minimumIntegerDigitsValue) })) })), jsxRuntime.jsx(StyledOperationWrapper, __assign({}, incrementIconStyles, { onClick: onClickCounter(CounterOperation.INCREMENT), className: plusIconContainer === null || plusIconContainer === void 0 ? void 0 : plusIconContainer.className, css: plusIconContainer === null || plusIconContainer === void 0 ? void 0 : plusIconContainer.css }, { children: isIncrementDisabled ? jsxRuntime.jsx(ctDesignIcons.PlusDisabled, {}) : jsxRuntime.jsx(ctDesignIcons.PlusCounter, __assign({}, theme.color.counter.enabled, plusIcon)) }))] })));
|
|
63
|
+
}, [value, isDecrementDisabled, isIncrementDisabled, onChange]);
|
|
64
|
+
return (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: { root: [staticStyles.root, ...rootStyles] }, children: [jsxRuntime.jsx(ctDesignContainer.Container, { onClick: onClickCounter(exports.CounterOperation.DECREMENT), styleConfig: { root: [staticStyles.minusIconContainer, ...minusIconContainerStyles] }, children: isDecrementDisabled ? (jsxRuntime.jsx(ctDesignIcons.MinusDisabled, {})) : (jsxRuntime.jsx(ctDesignIcons.MinusCounter, Object.assign({}, theme.color.counter.enabled, (minusIconProps || {})))) }), jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: { root: [staticStyles.valueContainer, ...valueContainerStyles] }, children: jsxRuntime.jsx(ctDesignTypography.Typography, { variant: 'B1', styleConfig: valueTypographyConfig, children: getCounterValue(value, minimumIntegerDigitsValue) }) }), jsxRuntime.jsx(ctDesignContainer.Container, { onClick: onClickCounter(exports.CounterOperation.INCREMENT), styleConfig: { root: [staticStyles.plusIconContainer, ...plusIconContainerStyles] }, children: isIncrementDisabled ? (jsxRuntime.jsx(ctDesignIcons.PlusDisabled, {})) : (jsxRuntime.jsx(ctDesignIcons.PlusCounter, Object.assign({}, theme.color.counter.enabled, (plusIconProps || {})))) })] }));
|
|
102
65
|
};
|
|
66
|
+
Counter.displayName = 'Counter';
|
|
103
67
|
|
|
104
68
|
exports.Counter = Counter;
|
|
105
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-design-counter.umd.js","sources":["../../../../node_modules/.pnpm/@rollup+plugin-typescript@9.0.2_rollup@3.29.4_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js","../packages/components/Counter/src/StyledOperationWrapper/style.ts","../packages/components/Counter/src/StyledOperationWrapper/StyledOperationWrapper.tsx","../../../core/types/dist/ct-design-types.esm.js","../packages/components/Counter/src/style.ts","../packages/components/Counter/src/Counter.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n",null,null,"var IconPosition;\n(function (IconPosition) {\n IconPosition[\"TOP\"] = \"top\";\n IconPosition[\"LEFT\"] = \"left\";\n IconPosition[\"RIGHT\"] = \"right\";\n})(IconPosition || (IconPosition = {}));\nvar CounterOperation;\n(function (CounterOperation) {\n CounterOperation[\"INCREMENT\"] = \"INCREMENT\";\n CounterOperation[\"DECREMENT\"] = \"DECREMENT\";\n})(CounterOperation || (CounterOperation = {}));\n\nexport { CounterOperation, IconPosition };\n//# sourceMappingURL=ct-design-types.esm.js.map\n",null,null],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","SuppressedError","error","suppressed","message","e","Error","name","styled","IconPosition","CounterOperation","useTheme","useCallback","useMemo","_jsxs","Container","_jsx","MinusDisabled","MinusCounter","Typography","PlusDisab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Y,EAAA,EAAA,CAAG,GAAGJ,cAAC,CAAAK,yBAAW,EAAK,QAAA,CAAA,EAAA,EAAA,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAM,QAAQ,CAAI,CAAA,EAAA,CAAA,CACjF,CACf,EAAA,CAAA,CAAA,EACZ;IACJ;;;;;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"ct-design-counter.umd.js","sources":["../../../core/types/dist/ct-design-types.esm.js","../packages/components/Counter/src/style.ts","../packages/components/Counter/src/Counter.tsx"],"sourcesContent":["var IconPosition;\n(function (IconPosition) {\n IconPosition[\"TOP\"] = \"top\";\n IconPosition[\"LEFT\"] = \"left\";\n IconPosition[\"RIGHT\"] = \"right\";\n})(IconPosition || (IconPosition = {}));\nvar CounterOperation;\n(function (CounterOperation) {\n CounterOperation[\"INCREMENT\"] = \"INCREMENT\";\n CounterOperation[\"DECREMENT\"] = \"DECREMENT\";\n})(CounterOperation || (CounterOperation = {}));\n\nexport { CounterOperation, IconPosition };\n//# sourceMappingURL=ct-design-types.esm.js.map\n",null,null],"names":["IconPosition","CounterOperation","makeStyles","useTheme","useCallback","_jsxs","Container","_jsx","MinusDisabled","MinusCounter","Typography","PlusDisabled","PlusCounter"],"mappings":";;;;;;QAmFYA,YAAA,CAAA;IAAZ,CAAA,UAAYA,YAAY,EAAA;IACtBA,EAAAA,YAAA,CAAW,KAAA,CAAA,GAAA,KAAA,CAAA;IACXA,EAAAA,YAAA,CAAa,MAAA,CAAA,GAAA,MAAA,CAAA;IACbA,EAAAA,YAAA,CAAe,OAAA,CAAA,GAAA,OAAA,CAAA;IACjB,CAAC,EAJWA,YAAY,KAAZA,YAAY,GAIvB,EAAA,CAAA,CAAA,CAAA;AAiDWC,sCAAA;IAAZ,CAAA,UAAYA,gBAAgB,EAAA;IAC1BA,EAAAA,gBAAA,CAAuB,WAAA,CAAA,GAAA,WAAA,CAAA;IACvBA,EAAAA,gBAAA,CAAuB,WAAA,CAAA,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AAW,oBAAK,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAO,aAAa,IAAI,EAAE,EAAC,CAAI,CAC5E,EACS,CAAA,CAAA,EAAA,CACF,EACZ;IACJ,EAAE;IAEF,OAAO,CAAC,WAAW,GAAG,SAAS;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,mBAAmB,QAAQ,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
package/dist/style.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const staticStyles: {
|
|
2
|
+
root: {
|
|
3
|
+
display: "flex";
|
|
4
|
+
flexDirection: "row";
|
|
5
|
+
alignItems: "center";
|
|
6
|
+
paddingVertical: 16;
|
|
7
|
+
columnGap: 16;
|
|
8
|
+
};
|
|
9
|
+
valueContainer: {
|
|
10
|
+
display: "flex";
|
|
11
|
+
alignItems: "center";
|
|
12
|
+
width: 24;
|
|
13
|
+
};
|
|
14
|
+
minusIconContainer: {
|
|
15
|
+
width: 32;
|
|
16
|
+
height: 32;
|
|
17
|
+
};
|
|
18
|
+
plusIconContainer: {
|
|
19
|
+
width: 32;
|
|
20
|
+
height: 32;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function getCounterCursor(isDisabled: boolean): {
|
|
24
|
+
cursor: "pointer" | "not-allowed";
|
|
25
|
+
};
|
|
26
|
+
export default staticStyles;
|
|
3
27
|
//# sourceMappingURL=style.d.ts.map
|
package/dist/style.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/style.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/style.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;CAuBhB,CAAC;AAMH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,OAAO;;EAInD;AAED,eAAe,YAAY,CAAC"}
|
package/dist/type.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
3
|
+
import type { CounterOperation } from '@cleartrip/ct-design-types';
|
|
4
|
+
import { TypographyStyleConfigProps } from '@cleartrip/ct-design-typography';
|
|
5
|
+
export interface ICounterStyleConfig {
|
|
6
|
+
root?: Styles[];
|
|
7
|
+
minusIconContainer?: Styles[];
|
|
8
|
+
valueContainer?: Styles[];
|
|
9
|
+
plusIconContainer?: Styles[];
|
|
10
|
+
value?: TypographyStyleConfigProps;
|
|
11
|
+
}
|
|
12
|
+
export interface ICounterProps {
|
|
4
13
|
min: number;
|
|
5
14
|
max: number;
|
|
6
15
|
value: number;
|
|
7
16
|
onChange: (value: number, operation: CounterOperation) => void;
|
|
8
17
|
isDisabled?: boolean;
|
|
9
18
|
minimumIntegerDigitsValue?: number;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
minusIcon?: React.SVGProps<SVGSVGElement>;
|
|
14
|
-
valueContainer?: BaseStyleConfigProps;
|
|
15
|
-
value?: TypographyStyleConfigProps;
|
|
16
|
-
plusIconContainer?: BaseStyleConfigProps;
|
|
17
|
-
plusIcon?: React.SVGProps<SVGSVGElement>;
|
|
18
|
-
};
|
|
19
|
+
minusIconProps?: SVGProps<SVGSVGElement>;
|
|
20
|
+
plusIconProps?: SVGProps<SVGSVGElement>;
|
|
21
|
+
styleConfig?: ICounterStyleConfig;
|
|
19
22
|
}
|
|
23
|
+
export type CounterProps = ICounterProps;
|
|
20
24
|
//# sourceMappingURL=type.d.ts.map
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/Counter/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAO7E,MAAM,WAAW,mBAAmB;IAElC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE9B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B,KAAK,CAAC,EAAE,0BAA0B,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAE5B,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;IAEZ,KAAK,EAAE,MAAM,CAAC;IAKd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE/D,UAAU,CAAC,EAAE,OAAO,CAAC;IAKrB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEzC,aAAa,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAExC,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AASD,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-design-counter",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "4.1.0-SNAPSHOT-native-main.1",
|
|
4
|
+
"description": "Counter Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"main": "dist/ct-design-counter.cjs.js",
|
|
6
|
+
"main": "./dist/ct-design-counter.cjs.js",
|
|
7
|
+
"react-native": "src/index.ts",
|
|
7
8
|
"jsnext:main": "dist/ct-design-counter.esm.js",
|
|
8
9
|
"module": "dist/ct-design-counter.esm.js",
|
|
9
10
|
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/ct-design-counter.esm.js",
|
|
15
|
+
"default": "./dist/ct-design-counter.cjs.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
10
18
|
"browser": {
|
|
11
19
|
"./dist/ct-design-counter.esm.js": "./dist/ct-design-counter.browser.esm.js",
|
|
12
20
|
"./dist/ct-design-counter.cjs.js": "./dist/ct-design-counter.browser.cjs.js"
|
|
13
21
|
},
|
|
14
22
|
"files": [
|
|
15
|
-
"dist"
|
|
23
|
+
"dist",
|
|
24
|
+
"src"
|
|
16
25
|
],
|
|
17
26
|
"dependencies": {
|
|
18
|
-
"@cleartrip/ct-design-
|
|
19
|
-
"@cleartrip/ct-design-
|
|
20
|
-
"@cleartrip/ct-design-
|
|
21
|
-
"@cleartrip/ct-design-theme": "4.0.0"
|
|
27
|
+
"@cleartrip/ct-design-container": "4.1.0-SNAPSHOT-native-main.1",
|
|
28
|
+
"@cleartrip/ct-design-icons": "4.0.0-SNAPSHOT-native-main.12",
|
|
29
|
+
"@cleartrip/ct-design-style-manager": "4.0.0-SNAPSHOT-native-main.12",
|
|
30
|
+
"@cleartrip/ct-design-theme": "4.0.0-SNAPSHOT-native-main.12",
|
|
31
|
+
"@cleartrip/ct-design-typography": "4.0.0-SNAPSHOT-native-main.12"
|
|
22
32
|
},
|
|
23
33
|
"devDependencies": {
|
|
24
|
-
"@cleartrip/ct-design-types": "4.0.0"
|
|
34
|
+
"@cleartrip/ct-design-types": "4.0.0-SNAPSHOT-native-main.12"
|
|
25
35
|
},
|
|
26
36
|
"peerDependencies": {
|
|
27
37
|
"react": ">=16.8.0",
|
|
28
38
|
"react-dom": ">=16.8.0",
|
|
29
|
-
"
|
|
39
|
+
"react-native": ">=0.68.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"react-native": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
30
45
|
},
|
|
31
46
|
"publishConfig": {
|
|
32
47
|
"access": "public"
|
|
@@ -37,6 +52,8 @@
|
|
|
37
52
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
38
53
|
"watch-package": "rollup -c -w",
|
|
39
54
|
"build-package": "rollup -c",
|
|
40
|
-
"build-package:clean": "rm -rf dist && rollup -c"
|
|
55
|
+
"build-package:clean": "rm -rf dist && rollup -c",
|
|
56
|
+
"publish-package:local": "yalc publish --no-scripts",
|
|
57
|
+
"publish-package:local:registry": "pnpm publish --registry http://localhost:4873 --no-git-checks --access public"
|
|
41
58
|
}
|
|
42
59
|
}
|
package/src/Counter.tsx
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { FC, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
4
|
+
import { Typography } from '@cleartrip/ct-design-typography';
|
|
5
|
+
import { MinusCounter, MinusDisabled, PlusCounter, PlusDisabled } from '@cleartrip/ct-design-icons';
|
|
6
|
+
import { useTheme } from '@cleartrip/ct-design-theme';
|
|
7
|
+
import { CounterOperation } from '@cleartrip/ct-design-types';
|
|
8
|
+
|
|
9
|
+
import { ICounterProps } from './type';
|
|
10
|
+
import staticStyles from './style';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Native Counter: same composition as web, but without the web-only `cursor`
|
|
14
|
+
* style since React Native presses are driven by `onClick` alone.
|
|
15
|
+
*/
|
|
16
|
+
const getCounterValue = (value: number, minimumIntegerDigitsValue: number) =>
|
|
17
|
+
value ? value.toLocaleString('en-US', { minimumIntegerDigits: minimumIntegerDigitsValue }) : '';
|
|
18
|
+
|
|
19
|
+
const Counter: FC<ICounterProps> = ({
|
|
20
|
+
min,
|
|
21
|
+
max,
|
|
22
|
+
value,
|
|
23
|
+
isDisabled = false,
|
|
24
|
+
onChange,
|
|
25
|
+
minimumIntegerDigitsValue = 2,
|
|
26
|
+
minusIconProps,
|
|
27
|
+
plusIconProps,
|
|
28
|
+
styleConfig,
|
|
29
|
+
}) => {
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
root: rootStyles = [],
|
|
34
|
+
minusIconContainer: minusIconContainerStyles = [],
|
|
35
|
+
valueContainer: valueContainerStyles = [],
|
|
36
|
+
value: valueTypographyConfig,
|
|
37
|
+
plusIconContainer: plusIconContainerStyles = [],
|
|
38
|
+
} = styleConfig || {};
|
|
39
|
+
|
|
40
|
+
const isIncrementDisabled = isDisabled || value >= max;
|
|
41
|
+
const isDecrementDisabled = isDisabled || value <= min;
|
|
42
|
+
|
|
43
|
+
const onClickCounter = useCallback(
|
|
44
|
+
(operation: CounterOperation) => () => {
|
|
45
|
+
let updatedVal = value;
|
|
46
|
+
if (operation === CounterOperation.DECREMENT) {
|
|
47
|
+
if (isDecrementDisabled) return;
|
|
48
|
+
updatedVal--;
|
|
49
|
+
} else {
|
|
50
|
+
if (isIncrementDisabled) return;
|
|
51
|
+
updatedVal++;
|
|
52
|
+
}
|
|
53
|
+
onChange(updatedVal, operation);
|
|
54
|
+
},
|
|
55
|
+
[value, isDecrementDisabled, isIncrementDisabled, onChange],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Container styleConfig={{ root: [staticStyles.root, ...rootStyles] }}>
|
|
60
|
+
<Container
|
|
61
|
+
onClick={onClickCounter(CounterOperation.DECREMENT)}
|
|
62
|
+
styleConfig={{ root: [staticStyles.minusIconContainer, ...minusIconContainerStyles] }}
|
|
63
|
+
>
|
|
64
|
+
{isDecrementDisabled ? (
|
|
65
|
+
<MinusDisabled />
|
|
66
|
+
) : (
|
|
67
|
+
<MinusCounter {...theme.color.counter.enabled} {...(minusIconProps || {})} />
|
|
68
|
+
)}
|
|
69
|
+
</Container>
|
|
70
|
+
|
|
71
|
+
<Container styleConfig={{ root: [staticStyles.valueContainer, ...valueContainerStyles] }}>
|
|
72
|
+
<Typography variant='B1' styleConfig={valueTypographyConfig}>
|
|
73
|
+
{getCounterValue(value, minimumIntegerDigitsValue)}
|
|
74
|
+
</Typography>
|
|
75
|
+
</Container>
|
|
76
|
+
|
|
77
|
+
<Container
|
|
78
|
+
onClick={onClickCounter(CounterOperation.INCREMENT)}
|
|
79
|
+
styleConfig={{ root: [staticStyles.plusIconContainer, ...plusIconContainerStyles] }}
|
|
80
|
+
>
|
|
81
|
+
{isIncrementDisabled ? (
|
|
82
|
+
<PlusDisabled />
|
|
83
|
+
) : (
|
|
84
|
+
<PlusCounter {...theme.color.counter.enabled} {...(plusIconProps || {})} />
|
|
85
|
+
)}
|
|
86
|
+
</Container>
|
|
87
|
+
</Container>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Counter.displayName = 'Counter';
|
|
92
|
+
export default Counter;
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CounterOperation } from '@cleartrip/ct-design-types';
|
package/src/index.ts
ADDED
package/src/style.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Static, platform-agnostic styles for Counter's composable slots. The cursor
|
|
5
|
+
* state depends on the enabled/disabled state of each press target and is
|
|
6
|
+
* therefore computed at render time via `useStyles` rather than baked in.
|
|
7
|
+
*/
|
|
8
|
+
const staticStyles = makeStyles((theme) => {
|
|
9
|
+
return {
|
|
10
|
+
root: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
paddingVertical: theme?.spacing[4],
|
|
15
|
+
columnGap: theme?.spacing[4],
|
|
16
|
+
},
|
|
17
|
+
valueContainer: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
width: theme?.size[6],
|
|
21
|
+
},
|
|
22
|
+
minusIconContainer: {
|
|
23
|
+
width: theme?.size[8],
|
|
24
|
+
height: theme?.size[8],
|
|
25
|
+
},
|
|
26
|
+
plusIconContainer: {
|
|
27
|
+
width: theme?.size[8],
|
|
28
|
+
height: theme?.size[8],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Web-only cursor style for the press targets. React Native strips unknown
|
|
35
|
+
* style keys, so this is only merged into the web Counter's Container slots.
|
|
36
|
+
*/
|
|
37
|
+
export function getCounterCursor(isDisabled: boolean) {
|
|
38
|
+
return {
|
|
39
|
+
cursor: isDisabled ? ('not-allowed' as const) : ('pointer' as const),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default staticStyles;
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Styles } from '@cleartrip/ct-design-types';
|
|
4
|
+
import type { CounterOperation } from '@cleartrip/ct-design-types';
|
|
5
|
+
import { TypographyStyleConfigProps } from '@cleartrip/ct-design-typography';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Style configuration for the Counter's composable slots. Slot names mirror
|
|
9
|
+
* the legacy surface; values are now `Styles[]` arrays aligned with the rest
|
|
10
|
+
* of the migrated components.
|
|
11
|
+
*/
|
|
12
|
+
export interface ICounterStyleConfig {
|
|
13
|
+
/** Styles for the outer flex-row container. */
|
|
14
|
+
root?: Styles[];
|
|
15
|
+
/** Styles for the minus icon press target. */
|
|
16
|
+
minusIconContainer?: Styles[];
|
|
17
|
+
/** Styles for the value text wrapper. */
|
|
18
|
+
valueContainer?: Styles[];
|
|
19
|
+
/** Styles for the plus icon press target. */
|
|
20
|
+
plusIconContainer?: Styles[];
|
|
21
|
+
/** Styles forwarded to the value Typography's `styleConfig` prop. */
|
|
22
|
+
value?: TypographyStyleConfigProps;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ICounterProps {
|
|
26
|
+
/** The minimum value allowed for the counter. */
|
|
27
|
+
min: number;
|
|
28
|
+
/** The maximum value allowed for the counter. */
|
|
29
|
+
max: number;
|
|
30
|
+
/** The current value of the counter. */
|
|
31
|
+
value: number;
|
|
32
|
+
/**
|
|
33
|
+
* Callback function triggered on counter value change. It provides the new
|
|
34
|
+
* value and the operation ('INCREMENT' or 'DECREMENT').
|
|
35
|
+
*/
|
|
36
|
+
onChange: (value: number, operation: CounterOperation) => void;
|
|
37
|
+
/** If true, the counter is disabled. */
|
|
38
|
+
isDisabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The minimum number of integer digits to be displayed in the value —
|
|
41
|
+
* e.g. with value `2`, `1` renders as `01`.
|
|
42
|
+
*/
|
|
43
|
+
minimumIntegerDigitsValue?: number;
|
|
44
|
+
/** Props spread onto the minus icon SVG (web only). */
|
|
45
|
+
minusIconProps?: SVGProps<SVGSVGElement>;
|
|
46
|
+
/** Props spread onto the plus icon SVG (web only). */
|
|
47
|
+
plusIconProps?: SVGProps<SVGSVGElement>;
|
|
48
|
+
/** Style configuration for different parts of the counter. */
|
|
49
|
+
styleConfig?: ICounterStyleConfig;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use `ICounterProps`. Kept as an alias for legacy consumers that
|
|
54
|
+
* imported `CounterProps` from `@cleartrip/ct-design-counter`. The
|
|
55
|
+
* `styleConfig` slots have been migrated from `{ css, className }` objects to
|
|
56
|
+
* `Styles[]` arrays, and the icon-props slots are now top-level
|
|
57
|
+
* `minusIconProps`/`plusIconProps`.
|
|
58
|
+
*/
|
|
59
|
+
export type CounterProps = ICounterProps;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from 'styled-components';
|
|
2
|
-
import { StyledIconProps } from './type';
|
|
3
|
-
declare const StyledOperationWrapper: import("styled-components").StyledComponent<"i", import("styled-components").DefaultTheme, StyledIconProps & {
|
|
4
|
-
css?: CSSProperties | undefined;
|
|
5
|
-
}, never>;
|
|
6
|
-
export default StyledOperationWrapper;
|
|
7
|
-
//# sourceMappingURL=StyledOperationWrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StyledOperationWrapper.d.ts","sourceRoot":"","sources":["../../packages/components/Counter/src/StyledOperationWrapper/StyledOperationWrapper.tsx"],"names":[],"mappings":"AAAA,OAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,QAAA,MAAM,sBAAsB;;SAA4I,CAAC;AAEzK,eAAe,sBAAsB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/components/Counter/src/StyledOperationWrapper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CSSObject } from 'styled-components';
|
|
2
|
-
import { Theme } from '@cleartrip/ct-design-theme';
|
|
3
|
-
import { StyledIconProps } from './type';
|
|
4
|
-
export declare const getStyledIconStyles: ({ theme, cursor }: StyledIconProps & {
|
|
5
|
-
theme: Theme;
|
|
6
|
-
}) => CSSObject;
|
|
7
|
-
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../packages/components/Counter/src/StyledOperationWrapper/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB;WAAkD,KAAK;MAAK,SAI3F,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../packages/components/Counter/src/StyledOperationWrapper/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC9B"}
|