@trionesdev/antd-mobile-base-react 0.0.2-beta.13 → 0.0.2-beta.14
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/dist/Segmented/Segmented.d.ts +57 -0
- package/dist/Segmented/Segmented.js +82 -0
- package/dist/Segmented/index.d.ts +2 -0
- package/dist/Segmented/index.js +1 -0
- package/dist/Segmented/style.scss +75 -0
- package/dist/Tag/style.scss +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
- package/dist/SpinLoading/demo/base.d.ts +0 -3
- package/dist/SpinLoading/demo/base.js +0 -21
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
type SegmentedItemType = {
|
|
4
|
+
/**
|
|
5
|
+
* @description 分段项的显示文本
|
|
6
|
+
*/
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* @description 分段项的值
|
|
10
|
+
* @required
|
|
11
|
+
*/
|
|
12
|
+
value?: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* @description 分段项的图标
|
|
15
|
+
*/
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* @description 是否禁用
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @description 自定义样式类名
|
|
24
|
+
*/
|
|
25
|
+
className?: string;
|
|
26
|
+
};
|
|
27
|
+
export type SegmentedProps = {
|
|
28
|
+
className?: string;
|
|
29
|
+
style?: React.CSSProperties;
|
|
30
|
+
/**
|
|
31
|
+
* @description 将宽度调整为父元素宽度的选项
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
block?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @description 是否禁用
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @description 默认选中的值
|
|
42
|
+
* @default undefined
|
|
43
|
+
*/
|
|
44
|
+
defaultValue?: string | number;
|
|
45
|
+
/**
|
|
46
|
+
* @description 选项列表
|
|
47
|
+
* @required
|
|
48
|
+
*/
|
|
49
|
+
options: SegmentedItemType[];
|
|
50
|
+
/**
|
|
51
|
+
* @description 当前选中的值
|
|
52
|
+
*/
|
|
53
|
+
value?: string | number;
|
|
54
|
+
onChange?: (value: string | number) => void;
|
|
55
|
+
};
|
|
56
|
+
export declare const Segmented: FC<SegmentedProps>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import React, { useEffect, useState } from 'react';
|
|
12
|
+
import "./style.scss";
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
var clsPrefix = 'triones-antm-segmented';
|
|
15
|
+
function firstEnabledValue(options) {
|
|
16
|
+
var _options$find;
|
|
17
|
+
return (_options$find = options.find(function (o) {
|
|
18
|
+
return !o.disabled;
|
|
19
|
+
})) === null || _options$find === void 0 ? void 0 : _options$find.value;
|
|
20
|
+
}
|
|
21
|
+
export var Segmented = function Segmented(_ref) {
|
|
22
|
+
var className = _ref.className,
|
|
23
|
+
style = _ref.style,
|
|
24
|
+
block = _ref.block,
|
|
25
|
+
defaultValue = _ref.defaultValue,
|
|
26
|
+
options = _ref.options,
|
|
27
|
+
value = _ref.value,
|
|
28
|
+
onChange = _ref.onChange,
|
|
29
|
+
rootDisabled = _ref.disabled;
|
|
30
|
+
var isControlled = value !== undefined;
|
|
31
|
+
var _useState = useState(function () {
|
|
32
|
+
if (defaultValue !== undefined) return defaultValue;
|
|
33
|
+
return firstEnabledValue(options);
|
|
34
|
+
}),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
internalValue = _useState2[0],
|
|
37
|
+
setInternalValue = _useState2[1];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (!isControlled) {
|
|
40
|
+
setInternalValue(function (prev) {
|
|
41
|
+
if (defaultValue !== undefined) return defaultValue;
|
|
42
|
+
if (prev !== undefined && options.some(function (o) {
|
|
43
|
+
return o.value === prev && !o.disabled;
|
|
44
|
+
})) {
|
|
45
|
+
return prev;
|
|
46
|
+
}
|
|
47
|
+
return firstEnabledValue(options);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, [defaultValue, isControlled, options]);
|
|
51
|
+
var selectedValue = isControlled ? value : internalValue;
|
|
52
|
+
var handleSelect = function handleSelect(itemValue, itemDisabled) {
|
|
53
|
+
if (rootDisabled || itemDisabled || itemValue === undefined) return;
|
|
54
|
+
if (!isControlled) {
|
|
55
|
+
setInternalValue(itemValue);
|
|
56
|
+
}
|
|
57
|
+
onChange === null || onChange === void 0 || onChange(itemValue);
|
|
58
|
+
};
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: classNames(clsPrefix, className, _defineProperty(_defineProperty({}, "".concat(clsPrefix, "-block"), block), "".concat(clsPrefix, "-disabled"), rootDisabled)),
|
|
61
|
+
style: style,
|
|
62
|
+
role: "radiogroup"
|
|
63
|
+
}, options.map(function (item, index) {
|
|
64
|
+
var _item$value;
|
|
65
|
+
var itemDisabled = !!(rootDisabled || item.disabled);
|
|
66
|
+
var active = item.value !== undefined && selectedValue === item.value;
|
|
67
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
key: (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : index,
|
|
69
|
+
role: "radio",
|
|
70
|
+
"aria-checked": active,
|
|
71
|
+
"aria-disabled": itemDisabled,
|
|
72
|
+
className: classNames("".concat(clsPrefix, "-item"), item.className, _defineProperty(_defineProperty({}, "".concat(clsPrefix, "-item-active"), active), "".concat(clsPrefix, "-item-disabled"), itemDisabled)),
|
|
73
|
+
onClick: function onClick() {
|
|
74
|
+
return handleSelect(item.value, itemDisabled);
|
|
75
|
+
}
|
|
76
|
+
}, item.icon != null && /*#__PURE__*/React.createElement("span", {
|
|
77
|
+
className: "".concat(clsPrefix, "-item-icon")
|
|
78
|
+
}, item.icon), item.label != null && /*#__PURE__*/React.createElement("span", {
|
|
79
|
+
className: "".concat(clsPrefix, "-item-label")
|
|
80
|
+
}, item.label));
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Segmented } from "./Segmented";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@use "../style/variable" as variable;
|
|
2
|
+
|
|
3
|
+
$class-prefix-segmented: 'triones-antm-segmented';
|
|
4
|
+
|
|
5
|
+
.#{$class-prefix-segmented} {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
align-items: stretch;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: 2Px;
|
|
11
|
+
border-radius: variable.$trionesBorderRadius;
|
|
12
|
+
background: variable.$trionesColorFillTertiary;
|
|
13
|
+
gap: 0;
|
|
14
|
+
|
|
15
|
+
&-block {
|
|
16
|
+
display: flex;
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-disabled {
|
|
21
|
+
opacity: 0.45;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-item {
|
|
26
|
+
position: relative;
|
|
27
|
+
z-index: 0;
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
flex: 0 1 auto;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
min-height: 10Px;
|
|
33
|
+
padding: 0Px 11Px;
|
|
34
|
+
font-size: variable.$trionesFontSize;
|
|
35
|
+
line-height: variable.$trionesLineHeightSm;
|
|
36
|
+
color: variable.$trionesColorTextSecondary;
|
|
37
|
+
border-radius: variable.$trionesBorderRadiusXs;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
user-select: none;
|
|
40
|
+
transition:
|
|
41
|
+
color 0.2s,
|
|
42
|
+
background-color 0.2s,
|
|
43
|
+
box-shadow 0.2s;
|
|
44
|
+
|
|
45
|
+
&-icon {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
margin-inline-end: 4Px;
|
|
48
|
+
font-size: variable.$trionesFontSizeIcon;
|
|
49
|
+
line-height: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&-label {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
line-height: 28Px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&-active {
|
|
59
|
+
z-index: 1;
|
|
60
|
+
color: variable.$trionesColorTextHeading;
|
|
61
|
+
background: variable.$trionesColorBgBase;
|
|
62
|
+
box-shadow: 0 1Px 2Px rgba(0, 0, 0, 0.06);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&-disabled {
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
color: variable.$trionesColorTextDisabled;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&-block &-item {
|
|
72
|
+
flex: 1 1 0;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/Tag/style.scss
CHANGED
|
@@ -17,7 +17,7 @@ $tagCls: 'triones-antm-tag';
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
&-round {
|
|
20
|
-
border-radius:
|
|
20
|
+
border-radius: 12Px;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Default variant styles
|
|
@@ -100,6 +100,7 @@ $tagCls: 'triones-antm-tag';
|
|
|
100
100
|
|
|
101
101
|
&-close {
|
|
102
102
|
margin-inline-start: 4Px;
|
|
103
|
+
display: flex;
|
|
103
104
|
|
|
104
105
|
.triones-antm-icon {
|
|
105
106
|
font-size: 10Px;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export { default as SafeArea } from './SafeArea';
|
|
|
53
53
|
export type { SafeAreaProps } from './SafeArea';
|
|
54
54
|
export { default as Scaffold } from './Scaffold';
|
|
55
55
|
export type { ScaffoldProps } from './Scaffold';
|
|
56
|
+
export { Segmented } from './Segmented';
|
|
57
|
+
export type { SegmentedProps } from './Segmented';
|
|
56
58
|
export { default as Space } from './Space';
|
|
57
59
|
export type { SpaceProps } from './Space';
|
|
58
60
|
export { default as SpinLoading } from './SpinLoading';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { default as Rate } from "./Rate";
|
|
|
26
26
|
export { default as Result } from "./Result";
|
|
27
27
|
export { default as SafeArea } from "./SafeArea";
|
|
28
28
|
export { default as Scaffold } from "./Scaffold";
|
|
29
|
+
export { Segmented } from "./Segmented";
|
|
29
30
|
export { default as Space } from "./Space";
|
|
30
31
|
export { default as SpinLoading } from "./SpinLoading";
|
|
31
32
|
export { default as Steps } from "./Steps";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trionesdev/antd-mobile-base-react",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.14",
|
|
4
4
|
"description": "antd mobile base react",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"runes2": "^1.1.4"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"@trionesdev/antd-mobile-icons-react": "0.0.2-beta.
|
|
51
|
+
"@trionesdev/antd-mobile-icons-react": "0.0.2-beta.14"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "5d9e7dbf380ca19c5e35509f0a31865ec5bdcc06"
|
|
54
54
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { DemoBlock } from "../../DemoBlock";
|
|
3
|
-
import { SpinLoading } from "../spin-loading";
|
|
4
|
-
import Space from "../../Space";
|
|
5
|
-
export default (function () {
|
|
6
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DemoBlock, {
|
|
7
|
-
title: "\u57FA\u7840\u4F7F\u7528"
|
|
8
|
-
}, /*#__PURE__*/React.createElement(SpinLoading, null)), /*#__PURE__*/React.createElement(DemoBlock, {
|
|
9
|
-
title: "\u989C\u8272"
|
|
10
|
-
}, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(SpinLoading, null), /*#__PURE__*/React.createElement(SpinLoading, {
|
|
11
|
-
color: "primary"
|
|
12
|
-
}), /*#__PURE__*/React.createElement(SpinLoading, {
|
|
13
|
-
color: "white"
|
|
14
|
-
}))), /*#__PURE__*/React.createElement(DemoBlock, {
|
|
15
|
-
title: "\u5927\u5C0F"
|
|
16
|
-
}, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(SpinLoading, {
|
|
17
|
-
size: "small"
|
|
18
|
-
}), /*#__PURE__*/React.createElement(SpinLoading, null), /*#__PURE__*/React.createElement(SpinLoading, {
|
|
19
|
-
size: "large"
|
|
20
|
-
}))));
|
|
21
|
-
});
|