@yup/taro-ui 0.1.0 → 1.0.0
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 +182 -6
- package/es/_virtual/_rollupPluginBabelHelpers.js +3 -1
- package/es/components/avatar/index.d.ts +18 -0
- package/es/components/avatar/index.js +1 -0
- package/es/components/avatar/style/index.css +28 -0
- package/es/components/avatar/style/index.d.ts +2 -0
- package/es/components/avatar/style/index.js +2 -0
- package/es/components/button/style/index.css +79 -61
- package/es/components/city-selector/hooks/useLevel2Multiple.d.ts +24 -0
- package/es/components/city-selector/hooks/useLevel2Multiple.js +1 -0
- package/es/components/city-selector/hooks/useLevel2Single.d.ts +19 -0
- package/es/components/city-selector/hooks/useLevel2Single.js +1 -0
- package/es/components/city-selector/hooks/useMultiple.d.ts +28 -0
- package/es/components/city-selector/hooks/useMultiple.js +1 -0
- package/es/components/city-selector/hooks/useSingle.d.ts +23 -0
- package/es/components/city-selector/hooks/useSingle.js +1 -0
- package/es/components/city-selector/index.d.ts +5 -0
- package/es/components/city-selector/index.js +1 -0
- package/es/components/city-selector/style/index.css +153 -0
- package/es/components/city-selector/style/index.d.ts +2 -0
- package/es/components/city-selector/util.d.ts +2 -0
- package/es/components/city-selector/util.js +1 -0
- package/es/components/dialog/context.d.ts +4 -0
- package/es/components/dialog/index.d.ts +31 -0
- package/es/components/dialog/index.js +1 -0
- package/es/components/dialog/style/index.css +113 -0
- package/es/components/dialog/style/index.d.ts +2 -0
- package/es/components/dialog/style/index.js +2 -0
- package/es/components/icon/index.js +1 -1
- package/es/components/icon/style/iconfont.css +13 -1
- package/es/components/icon/style/iconfont.ttf +0 -0
- package/es/components/icon/style/iconfont.woff +0 -0
- package/es/components/icon/style/iconfont.woff2 +0 -0
- package/es/components/input/style/index.css +19 -19
- package/es/components/media-uploader/index.d.ts +123 -0
- package/es/components/media-uploader/index.js +1 -0
- package/es/components/media-uploader/style/index.css +93 -0
- package/es/components/media-uploader/style/index.d.ts +2 -0
- package/es/components/media-uploader/style/index.js +2 -0
- package/es/components/tag/index.d.ts +18 -0
- package/es/components/tag/index.js +1 -0
- package/es/components/tag/style/index.css +92 -0
- package/es/components/tag/style/index.d.ts +2 -0
- package/es/components/tag/style/index.js +2 -0
- package/es/global/global.css +3 -0
- package/es/global/theme-default.css +3 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +1 -1
- package/es/style/iconfont.ttf +0 -0
- package/es/style/iconfont.woff +0 -0
- package/es/style/iconfont.woff2 +0 -0
- package/es/style/index.css +114 -81
- package/es/utils/is.js +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# yp-taro-ui
|
|
2
2
|
|
|
3
|
-
鱼泡Taro UI
|
|
3
|
+
鱼泡 Taro UI 组件库(抖音小程序)
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -44,11 +44,187 @@ npm install babel-plugin-import --save-dev
|
|
|
44
44
|
import { Button, Input } from '@yup/taro-ui';
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 开发指南
|
|
50
|
+
|
|
51
|
+
### 环境要求
|
|
52
|
+
|
|
53
|
+
- Node.js >= 16
|
|
54
|
+
- npm >= 8 或 yarn >= 1.22
|
|
55
|
+
|
|
56
|
+
### 开发命令
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 安装依赖
|
|
60
|
+
npm install
|
|
61
|
+
|
|
62
|
+
# 启动文档开发服务(端口 8888)
|
|
63
|
+
npm run dev
|
|
64
|
+
# 或
|
|
65
|
+
npm start
|
|
66
|
+
|
|
67
|
+
# 构建文档
|
|
68
|
+
npm run build:doc
|
|
69
|
+
|
|
70
|
+
# 构建组件库
|
|
71
|
+
npm run build:components
|
|
72
|
+
|
|
73
|
+
# 代码检查
|
|
74
|
+
npm run lint
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 发布说明
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 构建并发布(手动更新版本号)
|
|
81
|
+
npm run release
|
|
82
|
+
|
|
83
|
+
# 自动更新 patch 版本并发布
|
|
84
|
+
npm run release:patch
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
发布前请确保:
|
|
88
|
+
1. 代码已通过 lint 检查
|
|
89
|
+
2. 组件功能测试通过
|
|
90
|
+
3. 文档已更新
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 组件编写规范
|
|
95
|
+
|
|
96
|
+
### 目录结构
|
|
97
|
+
|
|
98
|
+
每个组件遵循以下目录结构:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
src/components/
|
|
102
|
+
└── button/ # 组件目录(小写,kebab-case)
|
|
103
|
+
├── index.tsx # 组件主文件
|
|
104
|
+
├── demos/ # 示例目录
|
|
105
|
+
│ ├── demo1.tsx # 示例1
|
|
106
|
+
│ ├── demo2.tsx # 示例2
|
|
107
|
+
│ └── ...
|
|
108
|
+
└── style/ # 样式目录
|
|
109
|
+
├── index.ts # 样式入口(用于按需加载)
|
|
110
|
+
└── index.less # 组件样式
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 组件编写规范
|
|
114
|
+
|
|
115
|
+
1. **命名规范**
|
|
116
|
+
- 组件目录:小写 + 连字符(如 `date-picker-view`)
|
|
117
|
+
- 组件名:大驼峰(如 `DatePickerView`)
|
|
118
|
+
- 样式类名前缀:`ypmini-组件名`(如 `ypmini-button`)
|
|
119
|
+
|
|
120
|
+
2. **类型定义**
|
|
121
|
+
- 导出组件的 Props 类型
|
|
122
|
+
- 使用 JSDoc 注释说明每个属性
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
export interface ButtonProps {
|
|
126
|
+
/**
|
|
127
|
+
* 按钮类型
|
|
128
|
+
*/
|
|
129
|
+
type?: 'primary' | 'default';
|
|
130
|
+
/**
|
|
131
|
+
* 是否禁用
|
|
132
|
+
*/
|
|
133
|
+
disabled?: boolean;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
3. **组件导出**
|
|
138
|
+
- 在 `src/index.ts` 中导出组件
|
|
139
|
+
- 同时导出类型定义
|
|
48
140
|
|
|
49
141
|
```tsx
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
import Input from '@yup/taro-ui/es/components/input';
|
|
53
|
-
import '@yup/taro-ui/es/components/input/style';
|
|
142
|
+
export { default as Button } from './components/button';
|
|
143
|
+
export type { ButtonProps } from './components/button';
|
|
54
144
|
```
|
|
145
|
+
|
|
146
|
+
4. **样式规范**
|
|
147
|
+
- 使用 Less 编写样式
|
|
148
|
+
- 支持 CSS 变量自定义
|
|
149
|
+
- `style/index.ts` 内容:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import './index.less';
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Demo 编写规范
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
/**
|
|
159
|
+
* title: 示例标题
|
|
160
|
+
* description: 示例描述
|
|
161
|
+
*/
|
|
162
|
+
export default () => {
|
|
163
|
+
return (
|
|
164
|
+
<div style={{ padding: 16 }}>
|
|
165
|
+
<h5>基础用法</h5>
|
|
166
|
+
<Button>按钮</Button>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 文档编写
|
|
175
|
+
|
|
176
|
+
### 文档目录
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
docs/components/
|
|
180
|
+
└── button/
|
|
181
|
+
└── index.md # 组件文档
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 文档模板
|
|
185
|
+
|
|
186
|
+
```markdown
|
|
187
|
+
---
|
|
188
|
+
sidebar: true
|
|
189
|
+
toc: content
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
# Button 按钮
|
|
193
|
+
|
|
194
|
+
组件描述。
|
|
195
|
+
|
|
196
|
+
## 何时使用
|
|
197
|
+
|
|
198
|
+
- 使用场景1
|
|
199
|
+
- 使用场景2
|
|
200
|
+
|
|
201
|
+
## 示例
|
|
202
|
+
|
|
203
|
+
<code src="../../../src/components/button/demos/demo1.tsx"></code>
|
|
204
|
+
|
|
205
|
+
## API
|
|
206
|
+
|
|
207
|
+
### 属性
|
|
208
|
+
|
|
209
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
210
|
+
| --- | --- | --- | --- |
|
|
211
|
+
| `type` | 按钮类型 | `'primary'` \| `'default'` | `'default'` |
|
|
212
|
+
|
|
213
|
+
### CSS 变量
|
|
214
|
+
|
|
215
|
+
| 变量 | 说明 | 默认值 |
|
|
216
|
+
| --- | --- | --- |
|
|
217
|
+
| `--button-color` | 按钮颜色 | `#1890ff` |
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 添加新组件文档
|
|
221
|
+
|
|
222
|
+
1. 在 `docs/components/` 下创建组件目录和 `index.md`
|
|
223
|
+
2. 在 `.dumirc.ts` 的 `sidebars` 中添加组件导航
|
|
224
|
+
3. 在 `.dumirc.ts` 的 `sidebar` 配置中添加路由映射
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
function r(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function t(r){if(Array.isArray(r))return r}function e(t){if(Array.isArray(t))return r(t)}function n(r,t,e){return(t=
|
|
1
|
+
function r(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function t(r){if(Array.isArray(r))return r}function e(t){if(Array.isArray(t))return r(t)}function n(r,t,e,n,o,i,a){try{var u=r[i](a),f=u.value}catch(r){return void e(r)}u.done?t(f):Promise.resolve(f).then(n,o)}function o(r){return function(){var t=this,e=arguments;return new Promise(function(o,i){var a=r.apply(t,e);function u(r){n(a,o,i,u,f,"next",r)}function f(r){n(a,o,i,u,f,"throw",r)}u(void 0)})}}function i(r,t){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!e){if(Array.isArray(r)||(e=S(r))||t&&r&&"number"==typeof r.length){e&&(r=e);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){e=e.call(r)},n:function(){var r=e.next();return a=r.done,r},e:function(r){u=!0,i=r},f:function(){try{a||null==e.return||e.return()}finally{if(u)throw i}}}}function a(r,t,e){return(t=j(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function u(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function f(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,i,a,u=[],f=!0,c=!1;try{if(i=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;f=!1}else for(;!(f=(n=i.call(e)).done)&&(u.push(n.value),u.length!==t);f=!0);}catch(r){c=!0,o=r}finally{try{if(!f&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}function c(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function y(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),e.push.apply(e,n)}return e}function s(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?y(Object(e),!0).forEach(function(t){a(r,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):y(Object(e)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})}return r}function p(r,t){if(null==r)return{};var e,n,o=b(r,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)e=i[n],-1===t.indexOf(e)&&{}.propertyIsEnumerable.call(r,e)&&(o[e]=r[e])}return o}function b(r,t){if(null==r)return{};var e={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(-1!==t.indexOf(n))continue;e[n]=r[n]}return e}function v(){
|
|
2
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
+
var r,t,e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function i(e,n,o,i){var f=n&&n.prototype instanceof u?n:u,c=Object.create(f.prototype);return m(c,"_invoke",function(e,n,o){var i,u,f,c=0,l=o||[],y=!1,s={p:0,n:0,v:r,a:p,f:p.bind(r,4),d:function(t,e){return i=t,u=0,f=r,s.n=e,a}};function p(e,n){for(u=e,f=n,t=0;!y&&c&&!o&&t<l.length;t++){var o,i=l[t],p=s.p,b=i[2];e>3?(o=b===n)&&(f=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=r):i[0]<=p&&((o=e<2&&p<i[1])?(u=0,s.v=n,s.n=i[1]):p<b&&(o=e<3||i[0]>n||n>b)&&(i[4]=e,i[5]=n,s.n=b,u=0))}if(o||e>1)return a;throw y=!0,n}return function(o,l,b){if(c>1)throw TypeError("Generator is already running");for(y&&1===l&&p(l,b),u=l,f=b;(t=u<2?r:f)||!y;){i||(u?u<3?(u>1&&(s.n=-1),p(u,f)):s.n=f:s.v=f);try{if(c=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,f)))throw TypeError("iterator result is not an object");if(!t.done)return t;f=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=r}else if((t=(y=s.n<0)?f:e.call(n,s))!==a)break}catch(t){i=r,u=1,f=t}finally{c=1}}return{value:t,done:y}}}(e,o,i),!0),c}var a={};function u(){}function f(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(m(t={},n,function(){return this}),t),y=c.prototype=u.prototype=Object.create(l);function s(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,c):(r.__proto__=c,m(r,o,"GeneratorFunction")),r.prototype=Object.create(y),r}return f.prototype=c,m(y,"constructor",c),m(c,"constructor",f),f.displayName="GeneratorFunction",m(c,o,"GeneratorFunction"),m(y),m(y,o,"Generator"),m(y,n,function(){return this}),m(y,"toString",function(){return"[object Generator]"}),(v=function(){return{w:i,m:s}})()}function m(r,t,e,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}m=function(r,t,e,n){function i(t,e){m(r,t,function(r){return this._invoke(t,e,r)})}t?o?o(r,t,{value:e,enumerable:!n,configurable:!n,writable:!n}):r[t]=e:(i("next",0),i("throw",1),i("return",2))},m(r,t,e,n)}function d(r){if(null!=r){var t=r["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],e=0;if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length))return{next:function(){return r&&e>=r.length&&(r=void 0),{value:r&&r[e++],done:!r}}}}throw new TypeError(typeof r+" is not iterable")}function h(r,e){return t(r)||f(r,e)||S(r,e)||c()}function O(r){return e(r)||u(r)||S(r)||l()}function g(r,t){if("object"!=typeof r||!r)return r;var e=r[Symbol.toPrimitive];if(void 0!==e){var n=e.call(r,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(r)}function j(r){var t=g(r,"string");return"symbol"==typeof t?t:t+""}function w(r){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},w(r)}function S(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}export{r as arrayLikeToArray,t as arrayWithHoles,e as arrayWithoutHoles,o as asyncToGenerator,i as createForOfIteratorHelper,a as defineProperty,u as iterableToArray,f as iterableToArrayLimit,c as nonIterableRest,l as nonIterableSpread,s as objectSpread2,p as objectWithoutProperties,b as objectWithoutPropertiesLoose,v as regenerator,m as regeneratorDefine,d as regeneratorValues,h as slicedToArray,O as toConsumableArray,g as toPrimitive,j as toPropertyKey,w as typeof,S as unsupportedIterableToArray};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps, ImageProps } from '@tarojs/components';
|
|
3
|
+
export interface AvatarProps extends ViewProps {
|
|
4
|
+
/**
|
|
5
|
+
* 头像路径
|
|
6
|
+
*/
|
|
7
|
+
src: string;
|
|
8
|
+
/**
|
|
9
|
+
* 大小规格
|
|
10
|
+
*/
|
|
11
|
+
size?: 'default' | 'middle';
|
|
12
|
+
/**
|
|
13
|
+
* 头像图片属性
|
|
14
|
+
*/
|
|
15
|
+
avatarImageProps?: ImageProps;
|
|
16
|
+
}
|
|
17
|
+
declare const Avatar: React.FC<AvatarProps>;
|
|
18
|
+
export default Avatar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{objectWithoutProperties as a,objectSpread2 as r}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as e}from"react/jsx-runtime";import s from"classnames";import{View as t,Image as o}from"@tarojs/components";var i=["src","size","className","avatarImageProps"],m=function(m){var c=m.src,l=m.size,p=void 0===l?"default":l,n=m.className,u=m.avatarImageProps,v=a(m,i);return e(t,r(r({className:s("ypmini-avatar","ypmini-avatar-".concat(p),n)},v),{},{children:e(o,r(r({mode:"aspectFill",className:"ypmini-avatar-image"},u||{}),{},{src:c}))}))};export{m as default};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
page,
|
|
2
|
+
:root {
|
|
3
|
+
--ypmini-avatar-size-default: calc(24px * var(--ypmini-hd));
|
|
4
|
+
--ypmini-avatar-size-middle: calc(48px * var(--ypmini-hd));
|
|
5
|
+
--ypmini-avatar-border-radius: 100%;
|
|
6
|
+
}
|
|
7
|
+
.ypmini-avatar {
|
|
8
|
+
--size: var(--ypmini-avatar-size-default);
|
|
9
|
+
--border-radius: var(--ypmini-avatar-border-radius);
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
width: var(--size);
|
|
15
|
+
height: var(--size);
|
|
16
|
+
border-radius: var(--border-radius);
|
|
17
|
+
}
|
|
18
|
+
.ypmini-avatar-default {
|
|
19
|
+
--size: var(--ypmini-avatar-size-default);
|
|
20
|
+
}
|
|
21
|
+
.ypmini-avatar-middle {
|
|
22
|
+
--size: var(--ypmini-avatar-size-middle);
|
|
23
|
+
}
|
|
24
|
+
.ypmini-avatar-image {
|
|
25
|
+
object-fit: cover;
|
|
26
|
+
height: 100%;
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
:root,
|
|
2
2
|
page {
|
|
3
|
-
--border-radius: calc(8px * var(--ypmini-hd));
|
|
4
|
-
--button-height-large: calc(48px * var(--ypmini-hd));
|
|
5
|
-
--button-height-default: calc(44px * var(--ypmini-hd));
|
|
6
|
-
--button-height-middle: calc(40px * var(--ypmini-hd));
|
|
7
|
-
--button-height-small: calc(32px * var(--ypmini-hd));
|
|
8
|
-
--button-font-size-samll: calc(14px * var(--ypmini-hd));
|
|
9
|
-
--button-font-size-moddle: calc(15px * var(--ypmini-hd));
|
|
10
|
-
--button-font-size-default: calc(17px * var(--ypmini-hd));
|
|
11
|
-
--button-font-size-large: calc(17px * var(--ypmini-hd));
|
|
12
|
-
--default-button-background: #f5f7fc;
|
|
13
|
-
--default-button-text-color: rgba(0, 0, 0, 0.65);
|
|
14
|
-
--
|
|
15
|
-
--primary-button-
|
|
16
|
-
--primary-button-
|
|
17
|
-
--primary-button-
|
|
18
|
-
--
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
24
|
-
--
|
|
3
|
+
--ypmini-border-radius: calc(8px * var(--ypmini-hd));
|
|
4
|
+
--ypmini-button-height-large: calc(48px * var(--ypmini-hd));
|
|
5
|
+
--ypmini-button-height-default: calc(44px * var(--ypmini-hd));
|
|
6
|
+
--ypmini-button-height-middle: calc(40px * var(--ypmini-hd));
|
|
7
|
+
--ypmini-button-height-small: calc(32px * var(--ypmini-hd));
|
|
8
|
+
--ypmini-button-font-size-samll: calc(14px * var(--ypmini-hd));
|
|
9
|
+
--ypmini-button-font-size-moddle: calc(15px * var(--ypmini-hd));
|
|
10
|
+
--ypmini-button-font-size-default: calc(17px * var(--ypmini-hd));
|
|
11
|
+
--ypmini-button-font-size-large: calc(17px * var(--ypmini-hd));
|
|
12
|
+
--ypmini-default-button-background: #f5f7fc;
|
|
13
|
+
--ypmini-default-button-text-color: rgba(0, 0, 0, 0.65);
|
|
14
|
+
--ypmini-default-button-ghost-color: rgba(0, 0, 0, 0.65);
|
|
15
|
+
--ypmini-primary-button-background: var(--ypmini-primary-color);
|
|
16
|
+
--ypmini-primary-button-ghost-color: var(--ypmini-primary-color);
|
|
17
|
+
--ypmini-primary-button-disabled-background: #99d3ff;
|
|
18
|
+
--ypmini-primary-button-disabled-text-color: rgba(255, 255, 255, 0.45);
|
|
19
|
+
--ypmini-primary-button-text-color: #fff;
|
|
20
|
+
--ypmini-secondary-button-background: #00cbff;
|
|
21
|
+
--ypmini-secondary-button-text-color: #ffffff;
|
|
22
|
+
--ypmini-secondary-button-ghost-color: #00cbff;
|
|
23
|
+
--ypmini-warning-button-background: #FF5A57;
|
|
24
|
+
--ypmini-warning-button-text-color: #ffffff;
|
|
25
|
+
--ypmini-warning-button-ghost-color: #FF5A57;
|
|
26
|
+
--ypmini-warning-button-outlined-color: #E8362E;
|
|
27
|
+
--ypmini-primary-button-outlined-color: var(--ypmini-primary-color);
|
|
28
|
+
--ypmini-default-button-outlined-color: rgba(0, 0, 0, 0.65);
|
|
25
29
|
}
|
|
26
30
|
.ypmini-taro-button {
|
|
27
31
|
padding: 0 24px;
|
|
28
32
|
border: unset;
|
|
29
33
|
font-weight: bold;
|
|
30
|
-
font-size: var(--button-font-size-default);
|
|
34
|
+
font-size: var(--ypmini-button-font-size-default);
|
|
31
35
|
width: auto;
|
|
32
|
-
height: var(--button-height-default);
|
|
33
|
-
line-height: var(--button-height-default);
|
|
36
|
+
height: var(--ypmini-button-height-default);
|
|
37
|
+
line-height: var(--ypmini-button-height-default);
|
|
34
38
|
color: var(--ypmini-color-text);
|
|
35
|
-
border-radius: var(--border-radius);
|
|
39
|
+
border-radius: var(--ypmini-border-radius);
|
|
36
40
|
display: inline-block;
|
|
37
41
|
white-space: nowrap;
|
|
38
42
|
}
|
|
39
43
|
.ypmini-taro-button:after {
|
|
40
44
|
display: none;
|
|
41
45
|
}
|
|
42
|
-
.ypmini-taro-button-ghost {
|
|
43
|
-
background: transparent;
|
|
44
|
-
}
|
|
45
46
|
.ypmini-taro-button-shape-default {
|
|
46
47
|
padding: 0 24px;
|
|
47
48
|
}
|
|
@@ -50,87 +51,104 @@ page {
|
|
|
50
51
|
border-radius: 1998px;
|
|
51
52
|
}
|
|
52
53
|
.ypmini-taro-button-size-large {
|
|
53
|
-
height: var(--button-height-large);
|
|
54
|
-
line-height: var(--button-height-large);
|
|
54
|
+
height: var(--ypmini-button-height-large);
|
|
55
|
+
line-height: var(--ypmini-button-height-large);
|
|
55
56
|
font-weight: bold;
|
|
56
|
-
font-size: var(--button-font-size-large);
|
|
57
|
+
font-size: var(--ypmini-button-font-size-large);
|
|
57
58
|
}
|
|
58
59
|
.ypmini-taro-button-size-middle {
|
|
59
60
|
font-weight: 400;
|
|
60
|
-
font-size: var(--button-font-size-middle);
|
|
61
|
-
height: var(--button-height-middle);
|
|
62
|
-
line-height: var(--button-height-middle);
|
|
61
|
+
font-size: var(--ypmini-button-font-size-middle);
|
|
62
|
+
height: var(--ypmini-button-height-middle);
|
|
63
|
+
line-height: var(--ypmini-button-height-middle);
|
|
63
64
|
}
|
|
64
65
|
.ypmini-taro-button-size-default {
|
|
65
|
-
height: var(--button-height-default);
|
|
66
|
-
line-height: var(--button-height-default);
|
|
66
|
+
height: var(--ypmini-button-height-default);
|
|
67
|
+
line-height: var(--ypmini-button-height-default);
|
|
67
68
|
}
|
|
68
69
|
.ypmini-taro-button-size-small {
|
|
69
70
|
font-weight: 400;
|
|
70
|
-
font-size: var(--button-font-size-middle);
|
|
71
|
-
height: var(--button-height-small);
|
|
72
|
-
line-height: var(--button-height-small);
|
|
71
|
+
font-size: var(--ypmini-button-font-size-middle);
|
|
72
|
+
height: var(--ypmini-button-height-small);
|
|
73
|
+
line-height: var(--ypmini-button-height-small);
|
|
73
74
|
}
|
|
74
75
|
.ypmini-taro-button-warning {
|
|
75
|
-
background: var(--warning-button-background);
|
|
76
|
-
color: var(--warning-button-text-color);
|
|
76
|
+
background: var(--ypmini-warning-button-background);
|
|
77
|
+
color: var(--ypmini-warning-button-text-color);
|
|
77
78
|
}
|
|
78
79
|
.ypmini-taro-button-warning.ypmini-taro-button-warning-disabled {
|
|
79
80
|
opacity: 0.6;
|
|
80
81
|
}
|
|
81
82
|
.ypmini-taro-button-warning.ypmini-taro-button-warning-disabled.ypmini-taro-button-warning.ypmini-taro-button-warning-disabled[disabled] {
|
|
82
|
-
color: var(--warning-button-text-color);
|
|
83
|
+
color: var(--ypmini-warning-button-text-color);
|
|
83
84
|
}
|
|
84
85
|
.ypmini-taro-button-warning.ypmini-taro-button-outlined {
|
|
85
|
-
border: 2px solid
|
|
86
|
-
color:
|
|
86
|
+
border: 2px solid var(--ypmini-warning-button-outlined-color);
|
|
87
|
+
color: var(--ypmini-warning-button-outlined-color);
|
|
87
88
|
background: transparent;
|
|
88
89
|
}
|
|
90
|
+
.ypmini-taro-button-warning.ypmini-taro-button-ghost {
|
|
91
|
+
background: transparent;
|
|
92
|
+
color: var(--ypmini-warning-button-ghost-color);
|
|
93
|
+
}
|
|
89
94
|
.ypmini-taro-button-primary {
|
|
90
|
-
background: var(--primary-button-background);
|
|
91
|
-
color: var(--primary-button-text-color);
|
|
95
|
+
background: var(--ypmini-primary-button-background);
|
|
96
|
+
color: var(--ypmini-primary-button-text-color);
|
|
92
97
|
}
|
|
93
98
|
.ypmini-taro-button-primary.ypmini-taro-button-primary-disabled {
|
|
94
|
-
color: var(--primary-button-disabled-text-color);
|
|
95
|
-
background: var(--primary-button-disabled-background);
|
|
99
|
+
color: var(--ypmini-primary-button-disabled-text-color);
|
|
100
|
+
background: var(--ypmini-primary-button-disabled-background);
|
|
96
101
|
}
|
|
97
102
|
.ypmini-taro-button-primary.ypmini-taro-button-outlined {
|
|
98
|
-
border: 2px solid var(--primary-button-outlined-color);
|
|
99
|
-
color: var(--primary-button-outlined-color);
|
|
103
|
+
border: 2px solid var(--ypmini-primary-button-outlined-color);
|
|
104
|
+
color: var(--ypmini-primary-button-outlined-color);
|
|
105
|
+
background: transparent;
|
|
106
|
+
}
|
|
107
|
+
.ypmini-taro-button-primary.ypmini-taro-button-ghost {
|
|
100
108
|
background: transparent;
|
|
109
|
+
color: var(--ypmini-primary-button-ghost-color);
|
|
101
110
|
}
|
|
102
111
|
.ypmini-taro-button-default {
|
|
103
|
-
background: var(--default-button-background);
|
|
104
|
-
color: var(--default-button-text-color);
|
|
112
|
+
background: var(--ypmini-default-button-background);
|
|
113
|
+
color: var(--ypmini-default-button-text-color);
|
|
105
114
|
}
|
|
106
115
|
.ypmini-taro-button-default.ypmini-taro-button-default-disabled {
|
|
107
116
|
opacity: 0.6;
|
|
108
117
|
}
|
|
109
118
|
.ypmini-taro-button-default.ypmini-taro-button-default-disabled.ypmini-taro-button-default.ypmini-taro-button-default-disabled[disabled] {
|
|
110
|
-
color: var(--default-button-text-color);
|
|
119
|
+
color: var(--ypmini-default-button-text-color);
|
|
111
120
|
}
|
|
112
121
|
.ypmini-taro-button-default.ypmini-taro-button-outlined {
|
|
113
|
-
border: 2px solid var(--default-button-outlined-color);
|
|
114
|
-
color: var(--default-button-outlined-color);
|
|
122
|
+
border: 2px solid var(--ypmini-default-button-outlined-color);
|
|
123
|
+
color: var(--ypmini-default-button-outlined-color);
|
|
124
|
+
background: transparent;
|
|
125
|
+
}
|
|
126
|
+
.ypmini-taro-button-default.ypmini-taro-button-ghost {
|
|
115
127
|
background: transparent;
|
|
128
|
+
color: var(--ypmini-default-button-ghost-color);
|
|
116
129
|
}
|
|
117
130
|
.ypmini-taro-button-secondary {
|
|
118
|
-
background: var(--secondary-button-background);
|
|
119
|
-
color: var(--secondary-button-text-color);
|
|
131
|
+
background: var(--ypmini-secondary-button-background);
|
|
132
|
+
color: var(--ypmini-secondary-button-text-color);
|
|
120
133
|
}
|
|
121
134
|
.ypmini-taro-button-secondary.ypmini-taro-button-secondary-disabled {
|
|
122
135
|
opacity: 0.6;
|
|
123
136
|
}
|
|
124
137
|
.ypmini-taro-button-secondary.ypmini-taro-button-secondary-disabled.ypmini-taro-button-secondary.ypmini-taro-button-secondary-disabled[disabled] {
|
|
125
|
-
color: var(--secondary-button-text-color);
|
|
138
|
+
color: var(--ypmini-secondary-button-text-color);
|
|
126
139
|
}
|
|
127
140
|
.ypmini-taro-button-secondary.ypmini-taro-button-outlined {
|
|
128
|
-
border: 2px solid var(--secondary-button-background);
|
|
129
|
-
color: var(--secondary-button-background);
|
|
141
|
+
border: 2px solid var(--ypmini-secondary-button-background);
|
|
142
|
+
color: var(--ypmini-secondary-button-background);
|
|
143
|
+
background: transparent;
|
|
144
|
+
}
|
|
145
|
+
.ypmini-taro-button-secondary.ypmini-taro-button-ghost {
|
|
130
146
|
background: transparent;
|
|
147
|
+
color: var(--ypmini-secondary-button-ghost-color);
|
|
131
148
|
}
|
|
132
149
|
.ypmini-taro-button-block {
|
|
133
150
|
display: block;
|
|
151
|
+
width: 100%;
|
|
134
152
|
}
|
|
135
153
|
.ypmini-taro-button-icon-wrapper {
|
|
136
154
|
display: flex;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OptionTreeData, ValueType, CitySelectorProps } from '../type';
|
|
2
|
+
export interface UseLevel2MultipleOption {
|
|
3
|
+
cityMap: {
|
|
4
|
+
[propsName: ValueType]: OptionTreeData;
|
|
5
|
+
};
|
|
6
|
+
defaultValue: ValueType[];
|
|
7
|
+
value?: ValueType[];
|
|
8
|
+
municipality: ValueType[];
|
|
9
|
+
max?: number;
|
|
10
|
+
onSelect?: CitySelectorProps['onSelect'];
|
|
11
|
+
onChange?: CitySelectorProps['onChange'];
|
|
12
|
+
onRemove: (item: OptionTreeData) => Promise<boolean>;
|
|
13
|
+
beforeSelect: (value: OptionTreeData[], selectedItem: OptionTreeData) => Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
declare function useLevel2Multiple({ cityMap, defaultValue, municipality, beforeSelect, onRemove, onSelect, onChange, max, ...rst }: UseLevel2MultipleOption): {
|
|
16
|
+
handleClear: () => void;
|
|
17
|
+
handleRemove: (item: OptionTreeData) => Promise<void>;
|
|
18
|
+
selectedDataTopLevel: OptionTreeData;
|
|
19
|
+
handleLevel1Click: (item: OptionTreeData) => void;
|
|
20
|
+
handleLevel2Click: (item: OptionTreeData) => void;
|
|
21
|
+
level1SelectedData: OptionTreeData | undefined;
|
|
22
|
+
level2SelectedData: OptionTreeData[] | undefined;
|
|
23
|
+
};
|
|
24
|
+
export default useLevel2Multiple;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{objectWithoutProperties as n,slicedToArray as e,toConsumableArray as l,asyncToGenerator as r,regenerator as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import u from"react";var a=["cityMap","defaultValue","municipality","beforeSelect","onRemove","onSelect","onChange","max"];function i(i){var o=i.cityMap,c=i.defaultValue;i.municipality;var v=i.beforeSelect,d=i.onRemove,f=i.onSelect,s=i.onChange,p=i.max,m=n(i,a),h=u.useState(),y=e(h,2),b=y[0],S=y[1],I=u.useState(),w=e(I,2),C=w[0],g=w[1],k=function(){var n=r(t().m(function n(e,r){var u;return t().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,v(e,r);case 1:if(n.v){n.n=2;break}return n.a(2);case 2:if(!(p&&(null==e?void 0:e.length)>p)){n.n=3;break}return n.a(2);case 3:u=null==e?void 0:e.map(function(n){return n.id}),f&&(null==f||f(u)),s&&(null==s||s(u)),g(l(e));case 4:return n.a(2)}},n)}));return function(e,l){return n.apply(this,arguments)}}(),x=function(){var n=r(t().m(function n(e){var r;return t().w(function(n){for(;;)switch(n.n){case 0:r=null==e?void 0:e.map(function(n){return n.id}),s&&(null==s||s(r)),g(l(e));case 1:return n.a(2)}},n)}));return function(e){return n.apply(this,arguments)}}(),D=function(){var n=r(t().m(function n(e){var l;return t().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,null==d?void 0:d(e);case 1:if(n.v){n.n=2;break}return n.a(2);case 2:l=null==C?void 0:C.filter(function(n){return n.id!==e.id}),x(l);case 3:return n.a(2)}},n)}));return function(e){return n.apply(this,arguments)}}();u.useEffect(function(){var n,e=null==c?void 0:c.map(function(n){return o[n]});if(g(e),null!=e&&null!==(n=e[0])&&void 0!==n&&n.parentId){var l,r=o[null==e||null===(l=e[0])||void 0===l?void 0:l.parentId];S(r)}},[o]),u.useEffect(function(){if("value"in m){var n,e,l=null==m||null===(n=m.value)||void 0===n?void 0:n.map(function(n){return o[n]});if(g(l),null!=l&&null!==(e=l[0])&&void 0!==e&&e.parentId){var r,t=o[null==l||null===(r=l[0])||void 0===r?void 0:r.parentId];S(t)}}},[o,null==m?void 0:m.value]);var L=u.useMemo(function(){var n;return o[null==C||null===(n=C[0])||void 0===n?void 0:n.parentId]},[C,o]);return{handleClear:function(){x([])},handleRemove:D,selectedDataTopLevel:L,handleLevel1Click:function(n){var e,l;(S(n),null!=n&&null!==(e=n.children)&&void 0!==e&&e[0])&&g([null==n||null===(l=n.children)||void 0===l?void 0:l[0]])},handleLevel2Click:function(n){var e,r;n.parentId===(null==C||null===(e=C[0])||void 0===e?void 0:e.parentId)?null!=C&&null!==(r=C.map(function(n){return n.id}))&&void 0!==r&&r.includes(n.id)?D(n):k([].concat(l(C||[]),[n]),n):k([n],n)},level1SelectedData:b,level2SelectedData:C}}export{i as default};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OptionTreeData, ValueType, CitySelectorProps } from '../type';
|
|
2
|
+
export interface UseLevel2SingleOption {
|
|
3
|
+
cityMap: {
|
|
4
|
+
[propsName: ValueType]: OptionTreeData;
|
|
5
|
+
};
|
|
6
|
+
defaultValue: ValueType;
|
|
7
|
+
value: ValueType;
|
|
8
|
+
municipality: ValueType[];
|
|
9
|
+
onChange?: CitySelectorProps['onChange'];
|
|
10
|
+
beforeSelect: (selectedItem: OptionTreeData) => Promise<boolean>;
|
|
11
|
+
}
|
|
12
|
+
declare function useLevel2Single({ cityMap, defaultValue, municipality, beforeSelect, onChange, ...rst }: UseLevel2SingleOption): {
|
|
13
|
+
selectedDataTopLevel: OptionTreeData;
|
|
14
|
+
handleLevel1Click: (item: OptionTreeData) => void;
|
|
15
|
+
handleLevel2Click: (item: OptionTreeData) => void;
|
|
16
|
+
level1SelectedData: OptionTreeData | undefined;
|
|
17
|
+
level2SelectedData: OptionTreeData | undefined;
|
|
18
|
+
};
|
|
19
|
+
export default useLevel2Single;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{objectWithoutProperties as e,slicedToArray as n,asyncToGenerator as l,regenerator as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import a from"react";var u=["cityMap","defaultValue","municipality","beforeSelect","onChange"];function i(i){var r=i.cityMap,o=i.defaultValue;i.municipality;var c=i.beforeSelect,d=i.onChange,v=e(i,u),f=a.useState(),s=n(f,2),p=s[0],m=s[1],h=a.useState(),y=n(h,2),S=y[0],I=y[1],b=function(){var e=l(t().m(function e(n){return t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,null==c?void 0:c(n);case 1:e.v||d&&(null==d||d(null==n?void 0:n.id)),"value"in v||I(n);case 2:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}();return a.useEffect(function(){var e=r[o];if(I(e),null!=e&&e.parentId){var n=r[null==e?void 0:e.parentId];m(n)}},[r]),a.useEffect(function(){if("value"in v){var e=r[null==v?void 0:v.value];if(I(e),null!=e&&e.parentId){var n=r[null==e?void 0:e.parentId];m(n)}}},[r,null==v?void 0:v.value]),{selectedDataTopLevel:a.useMemo(function(){return r[null==S?void 0:S.parentId]},[S,r]),handleLevel1Click:function(e){(null==e?void 0:e.id)!==(null==p?void 0:p.id)&&function(e){m(e)}(e)},handleLevel2Click:function(e){(null==e?void 0:e.id)!==(null==S?void 0:S.id)&&b(e)},level1SelectedData:p,level2SelectedData:S}}export{i as default};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { OptionTreeData, ValueType, CitySelectorProps } from '../type';
|
|
2
|
+
export interface UseMultipleOption {
|
|
3
|
+
cityMap: {
|
|
4
|
+
[propsName: ValueType]: OptionTreeData;
|
|
5
|
+
};
|
|
6
|
+
defaultValue: ValueType[];
|
|
7
|
+
value: ValueType[];
|
|
8
|
+
municipality: ValueType[];
|
|
9
|
+
max?: number;
|
|
10
|
+
onChange?: CitySelectorProps['onChange'];
|
|
11
|
+
onSelect?: CitySelectorProps['onSelect'];
|
|
12
|
+
onRemove: (item: OptionTreeData) => Promise<boolean>;
|
|
13
|
+
beforeSelect: (selectedItems: OptionTreeData[], selectedItem: OptionTreeData) => Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
declare function useMultiple({ cityMap, defaultValue, municipality, beforeSelect, onSelect, onChange, onRemove, max, ...rst }: UseMultipleOption): {
|
|
16
|
+
selectedDataSecondaryLevel: OptionTreeData;
|
|
17
|
+
selectedDataTopLevel: OptionTreeData;
|
|
18
|
+
level1SelectedData: OptionTreeData | undefined;
|
|
19
|
+
level2SelectedData: OptionTreeData | undefined;
|
|
20
|
+
level3SelectedData: OptionTreeData[] | undefined;
|
|
21
|
+
handleLevel1Click: (item: OptionTreeData) => void;
|
|
22
|
+
handleLevel2Click: (item: OptionTreeData) => void;
|
|
23
|
+
handleLevel3Click: (item: OptionTreeData) => void;
|
|
24
|
+
municipalitySelectedData: OptionTreeData[] | undefined;
|
|
25
|
+
handleRemove: (item: OptionTreeData) => Promise<void>;
|
|
26
|
+
handleClear: () => void;
|
|
27
|
+
};
|
|
28
|
+
export default useMultiple;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{objectWithoutProperties as n,slicedToArray as e,toConsumableArray as r,asyncToGenerator as t,regenerator as l}from"../../../_virtual/_rollupPluginBabelHelpers.js";import u from"react";import{isMunicipality as a}from"../util.js";var i=["cityMap","defaultValue","municipality","beforeSelect","onSelect","onChange","onRemove","max"];function o(o){var c=o.cityMap,d=o.defaultValue,v=o.municipality,f=o.beforeSelect,s=o.onSelect,p=o.onChange,m=o.onRemove,h=o.max,I=n(o,i),b=u.useState(),y=e(b,2),S=y[0],k=y[1],w=u.useState(),g=e(w,2),C=g[0],D=g[1],L=u.useState(),M=e(L,2),j=M[0],x=M[1],R=u.useState(),T=e(R,2),A=T[0],E=T[1],P=function(){var n=t(l().m(function n(e){var t;return l().w(function(n){for(;;)switch(n.n){case 0:t=null==e?void 0:e.map(function(n){return n.id}),E(r(e)),k([]),p&&(null==p||p(t));case 1:return n.a(2)}},n)}));return function(e){return n.apply(this,arguments)}}(),V=function(){var n=t(l().m(function n(e,t){var u,a;return l().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,f(e,t);case 1:if(u=n.v,a=null==e?void 0:e.map(function(n){return n.id}),u){n.n=2;break}return n.a(2);case 2:if(!(h&&h<(null==e?void 0:e.length))){n.n=3;break}return n.a(2);case 3:E(r(e)),k([]),s&&(null==s||s(a)),p&&(null==p||p(a));case 4:return n.a(2)}},n)}));return function(e,r){return n.apply(this,arguments)}}(),_=function(n){var e=null==n?void 0:n.map(function(n){return n.id});p&&(null==p||p(e)),k(r(n)),E([])},B=function(){var n=t(l().m(function n(e,t){var u;return l().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,f(e,t);case 1:if(n.v){n.n=2;break}return n.a(2);case 2:if(!(h&&h<(null==e?void 0:e.length))){n.n=3;break}return n.a(2);case 3:u=null==e?void 0:e.map(function(n){return n.id}),s&&(null==s||s(u)),p&&(null==p||p(u)),k(r(e)),E([]);case 4:return n.a(2)}},n)}));return function(e,r){return n.apply(this,arguments)}}(),G=function(){var n=t(l().m(function n(e){var t,u;return l().w(function(n){for(;;)switch(n.n){case 0:if(!a(e.parentId,v)){n.n=3;break}if(e.parentId===(null==S||null===(t=S[0])||void 0===t?void 0:t.parentId)){n.n=1;break}return B([e],e),n.a(2);case 1:if(null==S||null===(u=S.map(function(n){return n.id}))||void 0===u||!u.includes(e.id)){n.n=2;break}return H(e),n.a(2);case 2:return B([].concat(r(S||[]),[e]),e),n.a(2);case 3:x(e);case 4:return n.a(2)}},n)}));return function(e){return n.apply(this,arguments)}}(),H=function(){var n=t(l().m(function n(e){var t,u;return l().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,m(e);case 1:if(n.v){n.n=2;break}return n.a(2);case 2:if(!a(e.parentId,v)){n.n=3;break}return t=null==S?void 0:S.filter(function(n){return n.id!==e.id}),_(r(t)),n.a(2);case 3:u=null==A?void 0:A.filter(function(n){return n.id!==e.id}),P(u);case 4:return n.a(2)}},n)}));return function(e){return n.apply(this,arguments)}}();u.useEffect(function(){var n,e=null==d?void 0:d.map(function(n){return c[n]});if(E(e),null!=e&&null!==(n=e[0])&&void 0!==n&&n.parentId){var r,t=c[null==e||null===(r=e[0])||void 0===r?void 0:r.parentId];x(t),t&&D(c[t.parentId])}},[c]),u.useEffect(function(){if("value"in I){var n,e,r,t,l=null==I||null===(n=I.value)||void 0===n?void 0:n.map(function(n){return c[n]});if(E(l),a(null==l||null===(e=l[0])||void 0===e?void 0:e.parentId,v))return void D(c[null==l||null===(t=l[0])||void 0===t?void 0:t.parentId]);if(null!=l&&null!==(r=l[0])&&void 0!==r&&r.parentId){var u,i=c[null==l||null===(u=l[0])||void 0===u?void 0:u.parentId];x(i),i&&D(c[i.parentId])}}},[c,I,v]);var W=u.useMemo(function(){var n,e,r;return null!=S&&S.length?c[null==S||null===(r=S[0])||void 0===r?void 0:r.parentId]:c[null===(n=c[null==A||null===(e=A[0])||void 0===e?void 0:e.parentId])||void 0===n?void 0:n.parentId]},[c,A,S]);return{selectedDataSecondaryLevel:u.useMemo(function(){var n;return c[null==A||null===(n=A[0])||void 0===n?void 0:n.parentId]},[c,A]),selectedDataTopLevel:W,level1SelectedData:C,level2SelectedData:j,level3SelectedData:A,handleLevel1Click:function(n){n.id!==(null==C?void 0:C.id)&&function(n){var e,r;D(n),a(n.id,v)?(k([null==n||null===(e=n.children)||void 0===e?void 0:e[0]]),x(void 0)):(x(null==n||null===(r=n.children)||void 0===r?void 0:r[0]),k([])),E([])}(n)},handleLevel2Click:function(n){(n.id!==(null==C?void 0:C.id)||a(n.parentId,v))&&G(n)},handleLevel3Click:function(n){!function(n){var e,t;n.parentId===(null==A||null===(e=A[0])||void 0===e?void 0:e.parentId)?null!=A&&null!==(t=A.map(function(n){return n.id}))&&void 0!==t&&t.includes(n.id)?H(n):V([].concat(r(A||[]),[n]),n):V([n],n)}(n)},municipalitySelectedData:S,handleRemove:H,handleClear:function(){null!=S&&S.length?_([]):P([])}}}export{o as default};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OptionTreeData, ValueType, CitySelectorProps } from '../type';
|
|
2
|
+
export interface UseSingleOption {
|
|
3
|
+
cityMap: {
|
|
4
|
+
[propsName: ValueType]: OptionTreeData;
|
|
5
|
+
};
|
|
6
|
+
defaultValue: ValueType;
|
|
7
|
+
value: ValueType;
|
|
8
|
+
municipality: ValueType[];
|
|
9
|
+
onChange?: CitySelectorProps['onChange'];
|
|
10
|
+
beforeSelect: (item: OptionTreeData) => Promise<boolean>;
|
|
11
|
+
}
|
|
12
|
+
declare function useSingle({ cityMap, value, onChange, defaultValue, municipality, beforeSelect, ...rst }: UseSingleOption): {
|
|
13
|
+
selectedDataSecondaryLevel: OptionTreeData;
|
|
14
|
+
municipalitySelectedData: OptionTreeData | undefined;
|
|
15
|
+
selectedDataTopLevel: OptionTreeData;
|
|
16
|
+
level1SelectedData: OptionTreeData | undefined;
|
|
17
|
+
level2SelectedData: OptionTreeData | undefined;
|
|
18
|
+
level3SelectedData: OptionTreeData | undefined;
|
|
19
|
+
handleLevel1Click: (item: OptionTreeData) => void;
|
|
20
|
+
handleLevel2Click: (item: OptionTreeData) => void;
|
|
21
|
+
handleLevel3Click: (item: OptionTreeData) => void;
|
|
22
|
+
};
|
|
23
|
+
export default useSingle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{objectWithoutProperties as e,slicedToArray as n,asyncToGenerator as l,regenerator as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import t from"react";import{isMunicipality as a}from"../util.js";var r=["cityMap","value","onChange","defaultValue","municipality","beforeSelect"];function u(u){var d=u.cityMap,o=u.value,v=u.onChange,c=u.defaultValue,f=u.municipality,p=u.beforeSelect,s=e(u,r),h=t.useState(),m=n(h,2),I=m[0],S=m[1],y=t.useState(),D=n(y,2),b=D[0],C=D[1],L=t.useState(),g=n(L,2),k=g[0],M=g[1],j=t.useState(),T=n(j,2),w=T[0],E=T[1],P=function(){var e=l(i().m(function e(n){return i().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,p(n);case 1:if(e.v){e.n=2;break}return e.a(2);case 2:v&&(null==v||v(o));case 3:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}(),V=function(e){if(a(e.parentId,f))return"value"in s||S(e),void P(e);M(e)};t.useEffect(function(){var e=d[c];if(M(e),e){var n=d[e.parentId];M(n),n&&C(d[n.parentId])}},[d]),t.useEffect(function(){if("value"in s){var e=d[c];if(M(e),a(null==e?void 0:e.parentId,f))return void C(d[null==e?void 0:e.parentId]);if(e){var n=d[e.parentId];M(n),n&&C(d[n.parentId])}}},[d,s,f]);var _=t.useMemo(function(){var e;return I?d[null==I?void 0:I.parentId]:d[null===(e=d[null==w?void 0:w.parentId])||void 0===e?void 0:e.parentId]},[d,w,I]);return{selectedDataSecondaryLevel:t.useMemo(function(){return d[null==w?void 0:w.parentId]},[d,w]),municipalitySelectedData:I,selectedDataTopLevel:_,level1SelectedData:b,level2SelectedData:k,level3SelectedData:w,handleLevel1Click:function(e){e.id!==(null==b?void 0:b.id)&&function(e){var n,l,i;if(C(e),a(e.id,f))return S(null==e||null===(i=e.children)||void 0===i?void 0:i[0]),M(void 0),void E(void 0);S(void 0),M(null==e||null===(n=e.children)||void 0===n?void 0:n[0]),E(null==e||null===(l=e.children)||void 0===l||null===(l=l[0])||void 0===l||null===(l=l.children)||void 0===l?void 0:l[0])}(e)},handleLevel2Click:function(e){(a(e.parentId,f)&&(null==I?void 0:I.id)!==(null==e?void 0:e.id)||e.id!==(null==k?void 0:k.id))&&V(e)},handleLevel3Click:function(e){(null==w?void 0:w.id)!==(null==e?void 0:e.id)&&function(e){"value"in s||E(e),P(e)}(e)}}}export{u as default};
|