@yup/taro-ui 0.1.0 → 1.1.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.
Files changed (62) hide show
  1. package/README.md +220 -6
  2. package/es/_virtual/_rollupPluginBabelHelpers.js +3 -1
  3. package/es/components/avatar/index.d.ts +18 -0
  4. package/es/components/avatar/index.js +1 -0
  5. package/es/components/avatar/style/index.css +28 -0
  6. package/es/components/avatar/style/index.d.ts +2 -0
  7. package/es/components/avatar/style/index.js +2 -0
  8. package/es/components/button/style/index.css +79 -61
  9. package/es/components/city-selector/hooks/useLevel2Multiple.d.ts +24 -0
  10. package/es/components/city-selector/hooks/useLevel2Multiple.js +1 -0
  11. package/es/components/city-selector/hooks/useLevel2Single.d.ts +19 -0
  12. package/es/components/city-selector/hooks/useLevel2Single.js +1 -0
  13. package/es/components/city-selector/hooks/useMultiple.d.ts +28 -0
  14. package/es/components/city-selector/hooks/useMultiple.js +1 -0
  15. package/es/components/city-selector/hooks/useSingle.d.ts +23 -0
  16. package/es/components/city-selector/hooks/useSingle.js +1 -0
  17. package/es/components/city-selector/index.d.ts +5 -0
  18. package/es/components/city-selector/index.js +1 -0
  19. package/es/components/city-selector/style/index.css +153 -0
  20. package/es/components/city-selector/style/index.d.ts +2 -0
  21. package/es/components/city-selector/util.d.ts +2 -0
  22. package/es/components/city-selector/util.js +1 -0
  23. package/es/components/dialog/context.d.ts +4 -0
  24. package/es/components/dialog/index.d.ts +31 -0
  25. package/es/components/dialog/index.js +1 -0
  26. package/es/components/dialog/style/index.css +113 -0
  27. package/es/components/dialog/style/index.d.ts +2 -0
  28. package/es/components/dialog/style/index.js +2 -0
  29. package/es/components/icon/index.js +1 -1
  30. package/es/components/icon/style/iconfont.css +16 -4
  31. package/es/components/input/style/index.css +19 -19
  32. package/es/components/media-uploader/index.d.ts +123 -0
  33. package/es/components/media-uploader/index.js +1 -0
  34. package/es/components/media-uploader/style/index.css +93 -0
  35. package/es/components/media-uploader/style/index.d.ts +2 -0
  36. package/es/components/media-uploader/style/index.js +2 -0
  37. package/es/components/picker-view/style/index.css +3 -3
  38. package/es/components/popup/style/index.css +3 -3
  39. package/es/components/radio/style/index.css +54 -0
  40. package/es/components/radio/style/index.d.ts +1 -2
  41. package/es/components/radio/style/index.js +1 -2
  42. package/es/components/switch/index.d.ts +12 -2
  43. package/es/components/switch/index.js +1 -1
  44. package/es/components/switch/style/index.css +40 -33
  45. package/es/components/tag/index.d.ts +18 -0
  46. package/es/components/tag/index.js +1 -0
  47. package/es/components/tag/style/index.css +92 -0
  48. package/es/components/tag/style/index.d.ts +2 -0
  49. package/es/components/tag/style/index.js +2 -0
  50. package/es/global/global.css +3 -0
  51. package/es/global/theme-default.css +3 -0
  52. package/es/index.d.ts +20 -0
  53. package/es/index.js +1 -1
  54. package/es/style/index.css +800 -84
  55. package/es/utils/is.js +1 -1
  56. package/package.json +7 -6
  57. package/es/components/icon/style/iconfont.ttf +0 -0
  58. package/es/components/icon/style/iconfont.woff +0 -0
  59. package/es/components/icon/style/iconfont.woff2 +0 -0
  60. package/es/style/iconfont.ttf +0 -0
  61. package/es/style/iconfont.woff +0 -0
  62. package/es/style/iconfont.woff2 +0 -0
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,225 @@ 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 # 样式入口(用于按需加载)导入index.less
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 注释说明每个属性
48
123
 
49
124
  ```tsx
50
- import Button from '@yup/taro-ui/es/components/button';
51
- import '@yup/taro-ui/es/components/button/style';
52
- import Input from '@yup/taro-ui/es/components/input';
53
- import '@yup/taro-ui/es/components/input/style';
125
+ export interface ButtonProps {
126
+ /**
127
+ * 按钮类型
128
+ */
129
+ type?: 'primary' | 'default';
130
+ /**
131
+ * 是否禁用
132
+ */
133
+ disabled?: boolean;
134
+ }
54
135
  ```
136
+
137
+ 3. **组件导出**
138
+ - 在 `src/index.ts` 中导出组件
139
+ - 同时导出类型定义
140
+
141
+ ```tsx
142
+ export { default as Button } from './components/button';
143
+ export type { ButtonProps } from './components/button';
144
+ ```
145
+
146
+ 4. **样式规范**
147
+ - 使用 Less 编写样式
148
+ - 支持 CSS 变量自定义
149
+ - `style/index.ts` 内容:
150
+
151
+ ```ts
152
+ import './index.less';
153
+ ```
154
+
155
+ > **⚠️ 重要提示:** 每新增一个组件时,需要在 `src/style/index.less` 中手动导入组件的 less 文件,这个样式文件用于提供给全局样式导入。
156
+
157
+ ### Demo 编写规范
158
+
159
+ ```tsx
160
+ /**
161
+ * title: 示例标题
162
+ * description: 示例描述
163
+ */
164
+ export default () => {
165
+ return (
166
+ <div style={{ padding: 16 }}>
167
+ <h5>基础用法</h5>
168
+ <Button>按钮</Button>
169
+ </div>
170
+ );
171
+ };
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 文档编写
177
+
178
+ ### 文档目录
179
+
180
+ ```
181
+ docs/components/
182
+ └── button/
183
+ └── index.md # 组件文档
184
+ ```
185
+
186
+ ### 文档模板
187
+
188
+ ```markdown
189
+ ---
190
+ sidebar: true
191
+ toc: content
192
+ ---
193
+
194
+ # Button 按钮
195
+
196
+ 组件描述。
197
+
198
+ ## 何时使用
199
+
200
+ - 使用场景1
201
+ - 使用场景2
202
+
203
+ ## 示例
204
+
205
+ <code src="../../../src/components/button/demos/demo1.tsx"></code>
206
+
207
+ ## API
208
+
209
+ ### 属性
210
+
211
+ | 属性 | 说明 | 类型 | 默认值 |
212
+ | --- | --- | --- | --- |
213
+ | `type` | 按钮类型 | `'primary'` \| `'default'` | `'default'` |
214
+
215
+ ### CSS 变量
216
+
217
+ | 变量 | 说明 | 默认值 |
218
+ | --- | --- | --- |
219
+ | `--button-color` | 按钮颜色 | `#1890ff` |
220
+ ```
221
+
222
+ ### 添加新组件文档
223
+
224
+ 1. 在 `docs/components/` 下创建组件目录和 `index.md`
225
+ 2. 在 `.dumirc.ts` 的 `sidebars` 中添加组件导航
226
+ 3. 在 `.dumirc.ts` 的 `sidebar` 配置中添加路由映射
227
+
228
+ ---
229
+
230
+ ## 新增组件流程
231
+
232
+ 1. 在 `src/components` 中新增组件文件夹
233
+ 2. 在新增的组件文件目录中增加 `index.tsx` 出口
234
+ 3. 在新增的组件文件目录中增加 `style` 文件目录
235
+ 4. 在 `style` 文件目录中增加 `index.ts` 样式导出入口
236
+ 5. 在 `style` 目录下增加 `index.less` 入口作为 less 文件的导入入口
237
+ 6. 编写组件
238
+ 7. 编写 demo,在组件目录下增加 `demos` 文件目录,并在其中实现 demo
239
+ 8. 组件编写完成后在 `src/style/index.less` 中导入组件的 less 文件(提供给全局引入样式的方式使用)
240
+ 9. 在根目录 `docs/components` 目录下增加组件文档说明
241
+ 10. 在 `.dumirc.ts` 文件中增加文档的配置
242
+ 11. `yarn start` 启动文档查看
243
+
244
+ ---
245
+
246
+ ## designWidth 适配说明
247
+
248
+ `@yup/taro-ui` 的 designWidth 为 **750**。
249
+
250
+ 如果你的项目 designWidth 为 375,显示效果会是两倍大。可以通过修改 Less 变量 `@hd` 进行适配:
251
+
252
+ ```js
253
+ // config/index.js
254
+ module.exports = {
255
+ // ...
256
+ less: {
257
+ modifyVars: {
258
+ "@hd": "1"
259
+ }
260
+ }
261
+ }
262
+ ```
263
+
264
+ ---
265
+
266
+ ## License
267
+
268
+ 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=m(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function o(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function i(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,i,a,u=[],l=!0,f=!1;try{if(i=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;l=!1}else for(;!(l=(n=i.call(e)).done)&&(u.push(n.value),u.length!==t);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(f)throw o}}return u}}function a(){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 u(){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 l(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 f(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?l(Object(e),!0).forEach(function(t){n(r,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):l(Object(e)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})}return r}function c(r,t){if(null==r)return{};var e,n,o=y(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 y(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 s(r,e){return t(r)||i(r,e)||O(r,e)||a()}function b(r){return e(r)||o(r)||O(r)||u()}function p(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 m(r){var t=p(r,"string");return"symbol"==typeof t?t:t+""}function v(r){return v="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},v(r)}function O(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,n as defineProperty,o as iterableToArray,i as iterableToArrayLimit,a as nonIterableRest,u as nonIterableSpread,f as objectSpread2,c as objectWithoutProperties,y as objectWithoutPropertiesLoose,s as slicedToArray,b as toConsumableArray,p as toPrimitive,m as toPropertyKey,v as typeof,O as unsupportedIterableToArray};
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
+ }
@@ -0,0 +1,2 @@
1
+ import '../../../global/theme-default.less';
2
+ import './index.less';
@@ -0,0 +1,2 @@
1
+ import '../../../global/theme-default.css';
2
+ import './index.css';
@@ -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
- --primary-button-background: var(--ypmini-primary-color);
15
- --primary-button-disabled-background: #99d3ff;
16
- --primary-button-disabled-text-color: rgba(255, 255, 255, 0.45);
17
- --primary-button-text-color: #fff;
18
- --secondary-button-background: #00cbff;
19
- --secondary-button-text-color: #ffffff;
20
- --warning-button-background: #FF5A57;
21
- --warning-button-text-color: #ffffff;
22
- --warning-button-outlined-color: #E8362E;
23
- --primary-button-outlined-color: var(--ypmini-primary-color);
24
- --default-button-outlined-color: rgba(0, 0, 0, 0.65);
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 #E8362E;
86
- color: #E8362E;
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;