@antscorp/antsomi-ui 1.3.2-beta.18 → 1.3.2-beta.22

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,31 @@
1
+ import React from 'react';
2
+ import { InputNumberProps } from '../InputNumber';
3
+ type TUnit = 'px' | '%' | any;
4
+ /**
5
+ * @default
6
+ * ```
7
+ * const DEFAULT_UNIT = {
8
+ PX: {
9
+ value: 'px',
10
+ label: 'PX',
11
+ },
12
+ PERCENT: {
13
+ value: '%',
14
+ label: '%',
15
+ },
16
+ };
17
+ * ```
18
+ */
19
+ interface unitData {
20
+ [key: string]: {
21
+ value: string;
22
+ label: string;
23
+ };
24
+ }
25
+ interface InputNumberWithUnitProps extends InputNumberProps {
26
+ unit?: TUnit;
27
+ unitData?: unitData;
28
+ onChangeUnit: (unit: TUnit) => void;
29
+ }
30
+ export declare const InputNumberWithUnit: React.FC<InputNumberWithUnitProps>;
31
+ export {};
@@ -0,0 +1,39 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ // Libraries
13
+ import { Text } from '@antscorp/antsomi-ui/es/components/atoms';
14
+ import React from 'react';
15
+ import { InputNumber } from '../InputNumber';
16
+ import { InputNumberWithUnitWrapper } from './styled';
17
+ // Constants
18
+ const DEFAULT_UNIT = {
19
+ PX: {
20
+ value: 'px',
21
+ label: 'PX',
22
+ },
23
+ PERCENT: {
24
+ value: '%',
25
+ label: '%',
26
+ },
27
+ };
28
+ export const InputNumberWithUnit = props => {
29
+ // Props
30
+ const { unit, unitData, onChangeUnit } = props, restOf = __rest(props, ["unit", "unitData", "onChangeUnit"]);
31
+ return (React.createElement(InputNumberWithUnitWrapper, null,
32
+ React.createElement(InputNumber, Object.assign({}, restOf)),
33
+ React.createElement("div", { className: "unit-selector" },
34
+ ' ',
35
+ Object.values(unitData || DEFAULT_UNIT).map(({ value, label }) => (React.createElement(Text, { key: value, className: `${unit === value ? 'selected' : ''}`, onClick: () => onChangeUnit(value) }, label))))));
36
+ };
37
+ InputNumberWithUnit.defaultProps = {
38
+ unit: 'px',
39
+ };
@@ -0,0 +1 @@
1
+ export declare const InputNumberWithUnitWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,28 @@
1
+ var _a, _b;
2
+ // Libraries
3
+ import styled from 'styled-components';
4
+ // Constants
5
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
6
+ export const InputNumberWithUnitWrapper = styled.div `
7
+ display: flex;
8
+ align-items: center;
9
+ margin-left: 10px;
10
+ margin-right: 10px;
11
+
12
+ .unit-selector {
13
+ display: flex;
14
+ align-items: center;
15
+ }
16
+
17
+ .unit-selector > div {
18
+ cursor: pointer;
19
+ color: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorIcon};
20
+ margin-left: 10px;
21
+ margin-right: 10px;
22
+
23
+ &.selected {
24
+ color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary};
25
+ font-weight: bold;
26
+ }
27
+ }
28
+ `;
@@ -21,6 +21,7 @@ export { EdgeSetting } from './EdgeSetting';
21
21
  export { TreeSelect } from './TreeSelect';
22
22
  export { Result } from './Result';
23
23
  export { Card } from './Card';
24
+ export { InputNumberWithUnit } from './InputNumberWithUnit';
24
25
  export type { AdvancedPickerProps, TAdvancedPickerOption, TAdvancedRangePickerTimeRange, } from './DatePicker';
25
26
  export type { ColorPickerProps } from './ColorPicker';
26
27
  export type { AlignEditProps, AlignSettingProps } from './AlignSetting';
@@ -21,3 +21,4 @@ export { EdgeSetting } from './EdgeSetting';
21
21
  export { TreeSelect } from './TreeSelect';
22
22
  export { Result } from './Result';
23
23
  export { Card } from './Card';
24
+ export { InputNumberWithUnit } from './InputNumberWithUnit';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.2-beta.18",
3
+ "version": "1.3.2-beta.22",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -179,4 +179,4 @@
179
179
  "react": ">=16.9.0",
180
180
  "react-dom": ">=16.9.0"
181
181
  }
182
- }
182
+ }