node-karin 1.3.1 → 1.3.3

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/index.js CHANGED
@@ -10029,14 +10029,20 @@ var init_config3 = __esm({
10029
10029
  init_env();
10030
10030
  init_router();
10031
10031
  init_response();
10032
- WEB_CONFIG_NAME = "web.config.js";
10032
+ WEB_CONFIG_NAME = "web.config.mjs";
10033
10033
  getConfigPath = (options) => {
10034
10034
  if (options.type === "npm") {
10035
10035
  const configPath3 = path15.join(process.cwd(), "node_modules", options.name, WEB_CONFIG_NAME);
10036
- if (!fs21.existsSync(configPath3)) {
10037
- return null;
10036
+ if (fs21.existsSync(configPath3)) {
10037
+ return configPath3;
10038
+ }
10039
+ if (isDev()) {
10040
+ const rootConfigPath = path15.join(process.cwd(), WEB_CONFIG_NAME);
10041
+ if (fs21.existsSync(rootConfigPath)) {
10042
+ return rootConfigPath;
10043
+ }
10038
10044
  }
10039
- return configPath3;
10045
+ return null;
10040
10046
  }
10041
10047
  let configPath2 = path15.join(process.cwd(), "plugins", options.name, WEB_CONFIG_NAME);
10042
10048
  if (fs21.existsSync(configPath2)) return configPath2;
@@ -10059,8 +10065,18 @@ var init_config3 = __esm({
10059
10065
  createSuccessResponse(res, null);
10060
10066
  return;
10061
10067
  }
10062
- const { components } = await loadConfig(configPath2);
10063
- createSuccessResponse(res, components());
10068
+ const list2 = [];
10069
+ const { components: components2 } = await loadConfig(configPath2);
10070
+ components2().forEach((item) => {
10071
+ if (typeof (item == null ? void 0 : item.toJSON) === "function") {
10072
+ list2.push(item.toJSON());
10073
+ } else {
10074
+ if (typeof item === "object" && item !== null) {
10075
+ list2.push(item);
10076
+ }
10077
+ }
10078
+ });
10079
+ createSuccessResponse(res, list2);
10064
10080
  };
10065
10081
  saveConfig = async (req, res) => {
10066
10082
  const options = req.body;
@@ -16530,6 +16546,992 @@ var init_types2 = __esm({
16530
16546
  }
16531
16547
  });
16532
16548
 
16549
+ // src/components/base.ts
16550
+ var Component;
16551
+ var init_base5 = __esm({
16552
+ "src/components/base.ts"() {
16553
+ "use strict";
16554
+ init_esm_shims();
16555
+ Component = class {
16556
+ _config;
16557
+ _componentType;
16558
+ constructor(componentType) {
16559
+ this._componentType = componentType;
16560
+ }
16561
+ /**
16562
+ * 转换为JSON字符串
16563
+ */
16564
+ toString() {
16565
+ return JSON.stringify(this.toJSON());
16566
+ }
16567
+ /**
16568
+ * 转换为JSON对象
16569
+ */
16570
+ toJSON() {
16571
+ return { componentType: this._componentType, ...this._config };
16572
+ }
16573
+ };
16574
+ }
16575
+ });
16576
+
16577
+ // src/components/accordion.ts
16578
+ var AccordionBase, Accordion, AccordionPro, AccordionItem, accordion, accordionPro, accordionItem;
16579
+ var init_accordion = __esm({
16580
+ "src/components/accordion.ts"() {
16581
+ "use strict";
16582
+ init_esm_shims();
16583
+ init_base5();
16584
+ AccordionBase = class extends Component {
16585
+ _config;
16586
+ constructor(key, componentType) {
16587
+ super(componentType);
16588
+ this._config = { key, componentType };
16589
+ }
16590
+ /**
16591
+ * 设置标题
16592
+ * @param title - 标题文本
16593
+ */
16594
+ title = (title) => {
16595
+ this._config.title = title;
16596
+ return this;
16597
+ };
16598
+ /**
16599
+ * 设置子组件
16600
+ * @param children - 子组件数组
16601
+ */
16602
+ children = (children) => {
16603
+ const childrens = [];
16604
+ for (const child of children) {
16605
+ if (typeof (child == null ? void 0 : child.toJSON) === "function") {
16606
+ childrens.push(child.toJSON());
16607
+ continue;
16608
+ }
16609
+ if (typeof child === "object" && child !== null) {
16610
+ childrens.push(child);
16611
+ continue;
16612
+ }
16613
+ }
16614
+ this._config.children = childrens;
16615
+ return this;
16616
+ };
16617
+ /**
16618
+ * 设置样式变体
16619
+ * @param variant - 样式类型
16620
+ */
16621
+ variant = (variant) => {
16622
+ this._config.variant = variant;
16623
+ return this;
16624
+ };
16625
+ /**
16626
+ * 设置选择模式
16627
+ * @param mode - 选择模式
16628
+ * - none: 无
16629
+ * - single: 单选
16630
+ * - multiple: 多选
16631
+ */
16632
+ selectionMode = (mode) => {
16633
+ this._config.selectionMode = mode;
16634
+ return this;
16635
+ };
16636
+ /**
16637
+ * 设置选择行为
16638
+ * @param behavior - 选择行为
16639
+ * - toggle: 切换
16640
+ * - replace: 替换
16641
+ */
16642
+ selectionBehavior = (behavior) => {
16643
+ this._config.selectionBehavior = behavior;
16644
+ return this;
16645
+ };
16646
+ /**
16647
+ * 设置是否紧凑模式
16648
+ * @param isCompact - 是否紧凑
16649
+ */
16650
+ compact = (isCompact = true) => {
16651
+ this._config.isCompact = isCompact;
16652
+ return this;
16653
+ };
16654
+ /**
16655
+ * 设置是否禁用
16656
+ * @param isDisabled - 是否禁用
16657
+ */
16658
+ disabled = (isDisabled = true) => {
16659
+ this._config.isDisabled = isDisabled;
16660
+ return this;
16661
+ };
16662
+ /**
16663
+ * 设置是否显示分隔线
16664
+ * @param show - 是否显示
16665
+ */
16666
+ showDivider = (show = true) => {
16667
+ this._config.showDivider = show;
16668
+ return this;
16669
+ };
16670
+ /**
16671
+ * 设置是否隐藏指示器
16672
+ * @param hide - 是否隐藏
16673
+ */
16674
+ hideIndicator = (hide = true) => {
16675
+ this._config.hideIndicator = hide;
16676
+ return this;
16677
+ };
16678
+ /**
16679
+ * 设置是否禁用动画
16680
+ * @param disable - 是否禁用
16681
+ */
16682
+ disableAnimation = (disable = true) => {
16683
+ this._config.disableAnimation = disable;
16684
+ return this;
16685
+ };
16686
+ /**
16687
+ * 设置是否禁用指示器动画
16688
+ * @param disable - 是否禁用
16689
+ */
16690
+ disableIndicatorAnimation = (disable = true) => {
16691
+ this._config.disableIndicatorAnimation = disable;
16692
+ return this;
16693
+ };
16694
+ /**
16695
+ * 设置是否不允许空选择
16696
+ * @param disallow - 是否不允许
16697
+ */
16698
+ disallowEmptySelection = (disallow = true) => {
16699
+ this._config.disallowEmptySelection = disallow;
16700
+ return this;
16701
+ };
16702
+ /**
16703
+ * 设置是否保持内容挂载
16704
+ * @param keep - 是否保持
16705
+ */
16706
+ keepContentMounted = (keep = true) => {
16707
+ this._config.keepContentMounted = keep;
16708
+ return this;
16709
+ };
16710
+ /**
16711
+ * 设置是否全宽
16712
+ * @param full - 是否全宽
16713
+ */
16714
+ fullWidth = (full = true) => {
16715
+ this._config.fullWidth = full;
16716
+ return this;
16717
+ };
16718
+ /**
16719
+ * 设置禁用的键
16720
+ * @param keys - 禁用的键数组
16721
+ */
16722
+ disabledKeys = (keys) => {
16723
+ this._config.disabledKeys = keys;
16724
+ return this;
16725
+ };
16726
+ /**
16727
+ * 设置选中项
16728
+ * @param keys - 选中的键数组
16729
+ */
16730
+ selectedKeys = (keys) => {
16731
+ this._config.selectedKeys = keys;
16732
+ return this;
16733
+ };
16734
+ /**
16735
+ * 设置默认选中项
16736
+ * @param keys - 默认选中的键数组
16737
+ */
16738
+ defaultSelectedKeys = (keys) => {
16739
+ this._config.defaultSelectedKeys = keys;
16740
+ return this;
16741
+ };
16742
+ /**
16743
+ * 自定义配置
16744
+ * @param options - 配置选项
16745
+ */
16746
+ options = (options) => {
16747
+ this._config = { ...this._config, ...options };
16748
+ return this;
16749
+ };
16750
+ /**
16751
+ * 转换为JSON对象
16752
+ * @description 手风琴比较特殊 需要子组件也进行转换
16753
+ */
16754
+ toJSON = () => {
16755
+ if (!this._config.children) this._config.children = [];
16756
+ return this._config;
16757
+ };
16758
+ };
16759
+ Accordion = class extends AccordionBase {
16760
+ constructor(key) {
16761
+ super(key, "accordion");
16762
+ }
16763
+ };
16764
+ AccordionPro = class extends AccordionBase {
16765
+ constructor(key) {
16766
+ super(key, "accordion-pro");
16767
+ }
16768
+ /**
16769
+ * 设置渲染数据
16770
+ * @param data - 渲染数据
16771
+ */
16772
+ data = (data) => {
16773
+ this._config.data = data;
16774
+ return this;
16775
+ };
16776
+ };
16777
+ AccordionItem = class extends Component {
16778
+ _config = { key: "", componentType: "accordion-item" };
16779
+ constructor(key) {
16780
+ super("accordion-item");
16781
+ this._config.key = key;
16782
+ }
16783
+ /**
16784
+ * 设置子组件
16785
+ * @param children - 子组件数组
16786
+ */
16787
+ children = (children) => {
16788
+ if (!Array.isArray(children)) children = [children];
16789
+ const childrens = [];
16790
+ children.forEach((child) => {
16791
+ if (typeof (child == null ? void 0 : child.toJSON) === "function") {
16792
+ childrens.push(child.toJSON());
16793
+ return;
16794
+ }
16795
+ if (typeof child === "object" && child !== null) {
16796
+ childrens.push(child);
16797
+ }
16798
+ });
16799
+ this._config.children = childrens;
16800
+ return this;
16801
+ };
16802
+ /**
16803
+ * 设置标题
16804
+ * @param title - 标题文本
16805
+ */
16806
+ title = (title) => {
16807
+ this._config.title = title;
16808
+ return this;
16809
+ };
16810
+ /**
16811
+ * 设置副标题
16812
+ * @param subtitle - 副标题文本
16813
+ */
16814
+ subtitle = (subtitle) => {
16815
+ this._config.subtitle = subtitle;
16816
+ return this;
16817
+ };
16818
+ /**
16819
+ * 设置是否显示指示器
16820
+ * @param hide - 是否隐藏
16821
+ */
16822
+ hideIndicator = (hide = true) => {
16823
+ this._config.hideIndicator = hide;
16824
+ return this;
16825
+ };
16826
+ // /**
16827
+ // * 设置开始内容
16828
+ // * @param content - 开始内容组件
16829
+ // */
16830
+ // startContent = (content: Component) => {
16831
+ // this.config.startContent = content
16832
+ // return this
16833
+ // }
16834
+ // /**
16835
+ // * 设置结束内容
16836
+ // * @param content - 结束内容组件
16837
+ // */
16838
+ // endContent = (content: Component) => {
16839
+ // this.config.endContent = content
16840
+ // return this
16841
+ // }
16842
+ /**
16843
+ * 设置是否紧凑模式
16844
+ * @param isCompact - 是否紧凑
16845
+ */
16846
+ compact = (isCompact = true) => {
16847
+ this._config.isCompact = isCompact;
16848
+ return this;
16849
+ };
16850
+ /**
16851
+ * 设置是否禁用
16852
+ * @param isDisabled - 是否禁用
16853
+ */
16854
+ disabled = (isDisabled = true) => {
16855
+ this._config.isDisabled = isDisabled;
16856
+ return this;
16857
+ };
16858
+ /**
16859
+ * 设置是否保持内容挂载
16860
+ * @param keep - 是否保持
16861
+ */
16862
+ keepContentMounted = (keep = true) => {
16863
+ this._config.keepContentMounted = keep;
16864
+ return this;
16865
+ };
16866
+ /**
16867
+ * 设置是否禁用动画
16868
+ * @param disable - 是否禁用
16869
+ */
16870
+ disableAnimation = (disable = true) => {
16871
+ this._config.disableAnimation = disable;
16872
+ return this;
16873
+ };
16874
+ /**
16875
+ * 设置是否禁用指示器动画
16876
+ * @param disable - 是否禁用
16877
+ */
16878
+ disableIndicatorAnimation = (disable = true) => {
16879
+ this._config.disableIndicatorAnimation = disable;
16880
+ return this;
16881
+ };
16882
+ // /**
16883
+ // * 设置标题组件
16884
+ // * @param component - 标题组件
16885
+ // */
16886
+ // headingComponent = (component: string) => {
16887
+ // this.config.headingComponent = component
16888
+ // return this
16889
+ // }
16890
+ /**
16891
+ * 自定义配置
16892
+ * @param options - 配置选项
16893
+ */
16894
+ options = (options) => {
16895
+ this._config = { ...this._config, ...options };
16896
+ return this;
16897
+ };
16898
+ /**
16899
+ * 转换为JSON对象
16900
+ * @description 手风琴比较特殊 需要子组件也进行转换
16901
+ */
16902
+ toJSON = () => {
16903
+ return this._config;
16904
+ };
16905
+ };
16906
+ accordion = {
16907
+ /**
16908
+ * 创建基础手风琴组件
16909
+ * @param key - 唯一标识符
16910
+ */
16911
+ create: (key) => new Accordion(key),
16912
+ /**
16913
+ * 创建默认配置的手风琴组件
16914
+ * @param key - 唯一标识符
16915
+ */
16916
+ default: (key) => {
16917
+ return new Accordion(key).title("\u6298\u53E0\u9762\u677F").variant("bordered").selectionMode("single").selectionBehavior("toggle").showDivider().fullWidth();
16918
+ },
16919
+ /**
16920
+ * 使用自定义配置创建手风琴组件
16921
+ * @param key - 唯一标识符
16922
+ * @param options - 配置选项
16923
+ */
16924
+ options: (key, options) => new Accordion(key).options(options),
16925
+ /**
16926
+ * 创建手风琴子项
16927
+ * @param key - 唯一标识符
16928
+ */
16929
+ createItem: (key) => new AccordionItem(key)
16930
+ };
16931
+ accordionPro = {
16932
+ /**
16933
+ * 创建基础手风琴组件
16934
+ * @param key - 唯一标识符
16935
+ */
16936
+ create: (key, data) => new AccordionPro(key).data(data),
16937
+ /**
16938
+ * 创建默认配置的手风琴组件
16939
+ * @param key - 唯一标识符
16940
+ */
16941
+ default: (key) => {
16942
+ return new AccordionPro(key).title("\u6298\u53E0\u9762\u677FPro").variant("bordered").selectionMode("single").selectionBehavior("toggle").showDivider().fullWidth();
16943
+ },
16944
+ /**
16945
+ * 使用自定义配置创建手风琴组件
16946
+ * @param key - 唯一标识符
16947
+ * @param options - 配置选项
16948
+ */
16949
+ options: (key, options) => new AccordionPro(key).options(options)
16950
+ };
16951
+ accordionItem = {
16952
+ /**
16953
+ * 创建手风琴子项
16954
+ * @param key - 唯一标识符
16955
+ */
16956
+ create: (key) => new AccordionItem(key)
16957
+ };
16958
+ }
16959
+ });
16960
+
16961
+ // src/types/components/types.ts
16962
+ var init_types3 = __esm({
16963
+ "src/types/components/types.ts"() {
16964
+ "use strict";
16965
+ init_esm_shims();
16966
+ }
16967
+ });
16968
+
16969
+ // src/types/components/base.ts
16970
+ var init_base6 = __esm({
16971
+ "src/types/components/base.ts"() {
16972
+ "use strict";
16973
+ init_esm_shims();
16974
+ }
16975
+ });
16976
+
16977
+ // src/types/components/input.ts
16978
+ var init_input = __esm({
16979
+ "src/types/components/input.ts"() {
16980
+ "use strict";
16981
+ init_esm_shims();
16982
+ }
16983
+ });
16984
+
16985
+ // src/types/components/divider.ts
16986
+ var init_divider = __esm({
16987
+ "src/types/components/divider.ts"() {
16988
+ "use strict";
16989
+ init_esm_shims();
16990
+ }
16991
+ });
16992
+
16993
+ // src/types/components/switch.ts
16994
+ var init_switch = __esm({
16995
+ "src/types/components/switch.ts"() {
16996
+ "use strict";
16997
+ init_esm_shims();
16998
+ }
16999
+ });
17000
+
17001
+ // src/types/components/accordion.ts
17002
+ var init_accordion2 = __esm({
17003
+ "src/types/components/accordion.ts"() {
17004
+ "use strict";
17005
+ init_esm_shims();
17006
+ }
17007
+ });
17008
+
17009
+ // src/types/components/all.ts
17010
+ var init_all = __esm({
17011
+ "src/types/components/all.ts"() {
17012
+ "use strict";
17013
+ init_esm_shims();
17014
+ }
17015
+ });
17016
+
17017
+ // src/types/components/index.ts
17018
+ var init_components = __esm({
17019
+ "src/types/components/index.ts"() {
17020
+ "use strict";
17021
+ init_esm_shims();
17022
+ init_types3();
17023
+ init_base6();
17024
+ init_input();
17025
+ init_divider();
17026
+ init_switch();
17027
+ init_accordion2();
17028
+ init_all();
17029
+ }
17030
+ });
17031
+
17032
+ // src/components/input.ts
17033
+ var Input, input;
17034
+ var init_input2 = __esm({
17035
+ "src/components/input.ts"() {
17036
+ "use strict";
17037
+ init_esm_shims();
17038
+ init_base5();
17039
+ init_components();
17040
+ Input = class extends Component {
17041
+ _config = { key: "", type: "text", componentType: "input" };
17042
+ constructor(key) {
17043
+ super("input");
17044
+ this._config.key = key;
17045
+ }
17046
+ /**
17047
+ * 内部属性 仅在`options`中可手动设置,其他方法请不要调用
17048
+ */
17049
+ _type(dataType) {
17050
+ const typeMap = {
17051
+ ["string" /* STRING */]: "text",
17052
+ ["number" /* NUMBER */]: "text",
17053
+ ["boolean" /* BOOLEAN */]: "text",
17054
+ ["date" /* DATE */]: "text",
17055
+ ["time" /* TIME */]: "text",
17056
+ ["datetime" /* DATETIME */]: "text",
17057
+ ["email" /* EMAIL */]: "email",
17058
+ ["url" /* URL */]: "url",
17059
+ ["tel" /* TEL */]: "tel",
17060
+ ["password" /* PASSWORD */]: "password",
17061
+ ["color" /* COLOR */]: "text",
17062
+ ["json" /* JSON */]: "text"
17063
+ };
17064
+ if (!typeMap[dataType]) return this;
17065
+ this._config.type = typeMap[dataType];
17066
+ return this;
17067
+ }
17068
+ /**
17069
+ * 设置标签
17070
+ */
17071
+ label(label) {
17072
+ this._config.label = label;
17073
+ return this;
17074
+ }
17075
+ /**
17076
+ * 设置占位符
17077
+ */
17078
+ placeholder(placeholder) {
17079
+ this._config.placeholder = placeholder;
17080
+ return this;
17081
+ }
17082
+ /**
17083
+ * 设置验证规则
17084
+ */
17085
+ validate(rules) {
17086
+ if (!Array.isArray(rules)) rules = [rules];
17087
+ rules.forEach((rule) => {
17088
+ if (rule.regex && rule.regex instanceof RegExp) {
17089
+ rule.regex = rule.regex.toString();
17090
+ }
17091
+ });
17092
+ this._config.rules = rules;
17093
+ return this;
17094
+ }
17095
+ /**
17096
+ * 设置大小
17097
+ * @param size 大小
17098
+ * @returns 输入框构建器
17099
+ */
17100
+ size(size) {
17101
+ this._config.size = size;
17102
+ return this;
17103
+ }
17104
+ /**
17105
+ * 设置颜色
17106
+ */
17107
+ color(color) {
17108
+ this._config.color = color;
17109
+ return this;
17110
+ }
17111
+ /**
17112
+ * 设置是否必填
17113
+ */
17114
+ required(required = true) {
17115
+ this._config.isRequired = required;
17116
+ return this;
17117
+ }
17118
+ /**
17119
+ * 设置清除按钮
17120
+ */
17121
+ clearable(clearable = true) {
17122
+ this._config.isClearable = clearable;
17123
+ return this;
17124
+ }
17125
+ /**
17126
+ * 设置描述
17127
+ */
17128
+ description(description) {
17129
+ this._config.description = description;
17130
+ return this;
17131
+ }
17132
+ /**
17133
+ * 自定义参数
17134
+ */
17135
+ options(options) {
17136
+ this._config = options;
17137
+ return this;
17138
+ }
17139
+ };
17140
+ input = {
17141
+ /**
17142
+ * 创建基础输入框
17143
+ * @param key 唯一标识符
17144
+ */
17145
+ create: (key) => new Input(key),
17146
+ /**
17147
+ * 字符串
17148
+ * @param key 唯一标识符
17149
+ */
17150
+ string: (key) => {
17151
+ const fnc2 = new Input(key)._type("string" /* STRING */);
17152
+ return fnc2.label("\u5B57\u7B26\u4E32").placeholder("\u8BF7\u8F93\u5165\u5B57\u7B26\u4E32").required().clearable().color("primary");
17153
+ },
17154
+ /**
17155
+ * 数字
17156
+ * @param key 唯一标识符
17157
+ */
17158
+ number: (key) => {
17159
+ const fnc2 = new Input(key)._type("number" /* NUMBER */);
17160
+ return fnc2.label("\u6570\u5B57").placeholder("\u8BF7\u8F93\u5165\u6570\u5B57").required().clearable().color("primary").validate([
17161
+ {
17162
+ min: 0,
17163
+ max: 100,
17164
+ error: "\u6570\u5B57\u5E94\u57280-100\u4E4B\u95F4"
17165
+ }
17166
+ ]);
17167
+ },
17168
+ /**
17169
+ * 布尔值
17170
+ * @param key 唯一标识符
17171
+ */
17172
+ boolean: (key) => {
17173
+ const fnc2 = new Input(key)._type("boolean" /* BOOLEAN */);
17174
+ return fnc2.label("\u5E03\u5C14\u503C").placeholder("\u8BF7\u8F93\u5165\u5E03\u5C14\u503C").required().clearable().color("primary").validate([
17175
+ {
17176
+ regex: /^(true|false)$/,
17177
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u5E03\u5C14\u503C"
17178
+ }
17179
+ ]);
17180
+ },
17181
+ /**
17182
+ * 日期
17183
+ * @param key 唯一标识符
17184
+ */
17185
+ date: (key) => {
17186
+ const fnc2 = new Input(key)._type("date" /* DATE */);
17187
+ return fnc2.label("\u65E5\u671F").placeholder("\u8BF7\u8F93\u5165\u65E5\u671F").required().clearable().color("primary").validate([
17188
+ {
17189
+ regex: /^\d{4}-\d{2}-\d{2}$/,
17190
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65E5\u671F\u683C\u5F0F"
17191
+ }
17192
+ ]);
17193
+ },
17194
+ /**
17195
+ * 时间
17196
+ * @param key 唯一标识符
17197
+ */
17198
+ time: (key) => {
17199
+ const fnc2 = new Input(key)._type("time" /* TIME */);
17200
+ return fnc2.label("\u65F6\u95F4").placeholder("\u8BF7\u8F93\u5165\u65F6\u95F4").required().clearable().color("primary").validate([
17201
+ {
17202
+ regex: /^\d{2}:\d{2}:\d{2}$/,
17203
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65F6\u95F4\u683C\u5F0F"
17204
+ }
17205
+ ]);
17206
+ },
17207
+ /**
17208
+ * 日期时间
17209
+ * @param key 唯一标识符
17210
+ */
17211
+ datetime: (key) => {
17212
+ const fnc2 = new Input(key)._type("datetime" /* DATETIME */);
17213
+ return fnc2.label("\u65E5\u671F\u65F6\u95F4").placeholder("\u8BF7\u8F93\u5165\u65E5\u671F\u65F6\u95F4").required().clearable().color("primary").validate([
17214
+ {
17215
+ regex: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/,
17216
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65E5\u671F\u65F6\u95F4\u683C\u5F0F"
17217
+ }
17218
+ ]);
17219
+ },
17220
+ /**
17221
+ * 邮箱
17222
+ * @param key 唯一标识符
17223
+ */
17224
+ email: (key) => {
17225
+ const fnc2 = new Input(key)._type("email" /* EMAIL */);
17226
+ return fnc2.label("\u90AE\u7BB1").placeholder("\u8BF7\u8F93\u5165\u90AE\u7BB1").required().clearable().color("primary").validate([
17227
+ {
17228
+ regex: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
17229
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u5730\u5740"
17230
+ },
17231
+ {
17232
+ minLength: 5,
17233
+ maxLength: 50,
17234
+ error: "\u90AE\u7BB1\u957F\u5EA6\u5E94\u57285-50\u4E2A\u5B57\u7B26\u4E4B\u95F4"
17235
+ }
17236
+ ]);
17237
+ },
17238
+ /**
17239
+ * URL
17240
+ * @param key 唯一标识符
17241
+ */
17242
+ url: (key) => {
17243
+ const fnc2 = new Input(key)._type("url" /* URL */);
17244
+ return fnc2.label("URL").placeholder("\u8BF7\u8F93\u5165URL").required().clearable().color("primary").validate([
17245
+ {
17246
+ regex: /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,
17247
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684URL\u5730\u5740"
17248
+ }
17249
+ ]);
17250
+ },
17251
+ /**
17252
+ * 电话
17253
+ * @param key 唯一标识符
17254
+ */
17255
+ tel: (key) => {
17256
+ const fnc2 = new Input(key)._type("tel" /* TEL */);
17257
+ return fnc2.label("\u7535\u8BDD").placeholder("\u8BF7\u8F93\u5165\u7535\u8BDD").required().clearable().color("primary").validate([
17258
+ {
17259
+ regex: /^1[3-9]\d{9}$/,
17260
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u624B\u673A\u53F7\u7801"
17261
+ }
17262
+ ]);
17263
+ },
17264
+ /**
17265
+ * 密码
17266
+ * @param key 唯一标识符
17267
+ */
17268
+ password: (key) => {
17269
+ const fnc2 = new Input(key)._type("password" /* PASSWORD */);
17270
+ return fnc2.label("\u5BC6\u7801").placeholder("\u8BF7\u8F93\u5165\u5BC6\u7801").required().clearable().color("primary").validate({
17271
+ minLength: 1,
17272
+ error: "\u5BC6\u7801\u957F\u5EA6\u4E0D\u80FD\u5C0F\u4E8E1\u4F4D"
17273
+ });
17274
+ },
17275
+ /**
17276
+ * 颜色
17277
+ * @param key 唯一标识符
17278
+ */
17279
+ color: (key) => {
17280
+ const fnc2 = new Input(key)._type("color" /* COLOR */);
17281
+ return fnc2.label("\u989C\u8272").placeholder("\u8BF7\u8F93\u5165\u989C\u8272").required().clearable().color("primary").validate([
17282
+ {
17283
+ regex: /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/,
17284
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u989C\u8272\u683C\u5F0F"
17285
+ }
17286
+ ]);
17287
+ },
17288
+ /**
17289
+ * JSON
17290
+ * @param key 唯一标识符
17291
+ */
17292
+ json: (key) => {
17293
+ const fnc2 = new Input(key)._type("json" /* JSON */);
17294
+ return fnc2.label("JSON").placeholder("\u8BF7\u8F93\u5165JSON").required().clearable().color("primary").validate([
17295
+ {
17296
+ regex: /^[^{}]*$/,
17297
+ error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684JSON\u683C\u5F0F"
17298
+ }
17299
+ ]);
17300
+ },
17301
+ /**
17302
+ * 自定义参数
17303
+ * @param key 键
17304
+ * @param options 参数
17305
+ * @returns 输入框构建器
17306
+ */
17307
+ options: (key, options) => new Input(key).options(options)
17308
+ };
17309
+ }
17310
+ });
17311
+
17312
+ // src/components/switch.ts
17313
+ var Switch, switchComponent;
17314
+ var init_switch2 = __esm({
17315
+ "src/components/switch.ts"() {
17316
+ "use strict";
17317
+ init_esm_shims();
17318
+ init_base5();
17319
+ Switch = class extends Component {
17320
+ _config = { key: "", componentType: "switch" };
17321
+ constructor(key) {
17322
+ super("switch");
17323
+ this._config.key = key;
17324
+ }
17325
+ /**
17326
+ * 设置开始文本
17327
+ * @param text 开始文本
17328
+ */
17329
+ startText = (text2) => {
17330
+ this._config.startText = text2;
17331
+ return this;
17332
+ };
17333
+ /**
17334
+ * 设置结束文本
17335
+ * @param text 结束文本
17336
+ */
17337
+ endText = (text2) => {
17338
+ this._config.endText = text2;
17339
+ return this;
17340
+ };
17341
+ /**
17342
+ * 设置大小
17343
+ * @param size 大小
17344
+ */
17345
+ size = (size) => {
17346
+ this._config.size = size;
17347
+ return this;
17348
+ };
17349
+ /**
17350
+ * 设置颜色
17351
+ * @param color 颜色
17352
+ */
17353
+ color = (color) => {
17354
+ this._config.color = color;
17355
+ return this;
17356
+ };
17357
+ /**
17358
+ * 设置开关图标
17359
+ * @param icon 图标
17360
+ */
17361
+ thumbIcon = (icon) => {
17362
+ this._config.thumbIcon = icon;
17363
+ return this;
17364
+ };
17365
+ /**
17366
+ * 设置开始内容图标
17367
+ * @param icon 图标
17368
+ */
17369
+ startContent = (icon) => {
17370
+ this._config.startContent = icon;
17371
+ return this;
17372
+ };
17373
+ /**
17374
+ * 设置结束内容图标
17375
+ * @param icon 图标
17376
+ */
17377
+ endContent = (icon) => {
17378
+ this._config.endContent = icon;
17379
+ return this;
17380
+ };
17381
+ /**
17382
+ * 设置是否被选中(只读)
17383
+ * @param selected 是否被选中
17384
+ */
17385
+ selected = (selected = true) => {
17386
+ this._config.isSelected = selected;
17387
+ return this;
17388
+ };
17389
+ /**
17390
+ * 设置默认选中状态
17391
+ * @param selected 是否默认选中
17392
+ */
17393
+ defaultSelected = (selected = true) => {
17394
+ this._config.defaultSelected = selected;
17395
+ return this;
17396
+ };
17397
+ /**
17398
+ * 设置是否只读
17399
+ * @param readonly 是否只读
17400
+ */
17401
+ readonly = (readonly = true) => {
17402
+ this._config.isReadOnly = readonly;
17403
+ return this;
17404
+ };
17405
+ /**
17406
+ * 设置是否禁用
17407
+ * @param disabled 是否禁用
17408
+ */
17409
+ disabled = (disabled = true) => {
17410
+ this._config.isDisabled = disabled;
17411
+ return this;
17412
+ };
17413
+ /**
17414
+ * 设置是否禁用动画
17415
+ * @param disable 是否禁用动画
17416
+ */
17417
+ disableAnimation = (disable = true) => {
17418
+ this._config.disableAnimation = disable;
17419
+ return this;
17420
+ };
17421
+ /**
17422
+ * 自定义参数
17423
+ * @param options 参数
17424
+ */
17425
+ options = (options) => {
17426
+ this._config = options;
17427
+ return this;
17428
+ };
17429
+ };
17430
+ switchComponent = {
17431
+ /**
17432
+ * 创建基础开关
17433
+ * @param key 唯一标识符
17434
+ */
17435
+ create: (key) => new Switch(key),
17436
+ /**
17437
+ * 自定义参数
17438
+ * @param key 唯一标识符
17439
+ * @param options 参数
17440
+ */
17441
+ options: (key, options) => new Switch(key).options(options)
17442
+ };
17443
+ }
17444
+ });
17445
+
17446
+ // src/components/divider.ts
17447
+ var Divider, divider;
17448
+ var init_divider2 = __esm({
17449
+ "src/components/divider.ts"() {
17450
+ "use strict";
17451
+ init_esm_shims();
17452
+ init_base5();
17453
+ Divider = class _Divider extends Component {
17454
+ _config;
17455
+ constructor() {
17456
+ super("divider");
17457
+ this._config = {
17458
+ key: "",
17459
+ componentType: "divider",
17460
+ transparent: false,
17461
+ orientation: "horizontal"
17462
+ };
17463
+ }
17464
+ /**
17465
+ * 设置透明
17466
+ * @param transparent 是否透明 默认不透明
17467
+ */
17468
+ transparent(transparent) {
17469
+ this._config.transparent = transparent;
17470
+ return this;
17471
+ }
17472
+ /**
17473
+ * 设置竖向分隔线
17474
+ * @param orientation 是否使用竖向分隔线 默认使用横向
17475
+ */
17476
+ vertical(orientation) {
17477
+ this._config.orientation = orientation ? "vertical" : "horizontal";
17478
+ return this;
17479
+ }
17480
+ /**
17481
+ * 转换为 JSON 对象
17482
+ * @returns JSON 对象
17483
+ */
17484
+ toJSON() {
17485
+ const data = new _Divider();
17486
+ const key = Math.random().toString(36).substring(2, 15);
17487
+ data._config = { ...this._config, key };
17488
+ return data._config;
17489
+ }
17490
+ };
17491
+ divider = new Divider();
17492
+ }
17493
+ });
17494
+
17495
+ // src/components/all.ts
17496
+ var components;
17497
+ var init_all2 = __esm({
17498
+ "src/components/all.ts"() {
17499
+ "use strict";
17500
+ init_esm_shims();
17501
+ init_input2();
17502
+ init_divider2();
17503
+ init_switch2();
17504
+ init_accordion();
17505
+ components = {
17506
+ /** 分隔线 */
17507
+ divider,
17508
+ /** 输入框 */
17509
+ input,
17510
+ /** 开关 */
17511
+ switch: switchComponent,
17512
+ /** 手风琴 */
17513
+ accordion,
17514
+ /** 手风琴Pro */
17515
+ accordionPro,
17516
+ /** 手风琴项 */
17517
+ accordionItem
17518
+ };
17519
+ }
17520
+ });
17521
+
17522
+ // src/components/index.ts
17523
+ var init_components2 = __esm({
17524
+ "src/components/index.ts"() {
17525
+ "use strict";
17526
+ init_esm_shims();
17527
+ init_accordion();
17528
+ init_input2();
17529
+ init_switch2();
17530
+ init_divider2();
17531
+ init_all2();
17532
+ }
17533
+ });
17534
+
16533
17535
  // src/plugin/class.ts
16534
17536
  var Plugin;
16535
17537
  var init_class2 = __esm({
@@ -16581,7 +17583,7 @@ var init_class2 = __esm({
16581
17583
  import fs30 from "node:fs";
16582
17584
  import path23 from "node:path";
16583
17585
  var index3, botID, AdapterConsole, adapter3;
16584
- var init_input = __esm({
17586
+ var init_input3 = __esm({
16585
17587
  "src/adapter/input/index.ts"() {
16586
17588
  "use strict";
16587
17589
  init_esm_shims();
@@ -16730,7 +17732,7 @@ var init_adapter3 = __esm({
16730
17732
  "src/adapter/index.ts"() {
16731
17733
  "use strict";
16732
17734
  init_esm_shims();
16733
- init_input();
17735
+ init_input3();
16734
17736
  init_adapter2();
16735
17737
  init_base();
16736
17738
  init_render2();
@@ -16740,6 +17742,7 @@ var init_adapter3 = __esm({
16740
17742
  // src/index.ts
16741
17743
  var index_exports = {};
16742
17744
  __export(index_exports, {
17745
+ AccordionItem: () => AccordionItem,
16743
17746
  AdapterBase: () => AdapterBase,
16744
17747
  BaseEvent: () => BaseEvent,
16745
17748
  Bot: () => Bot,
@@ -16793,6 +17796,9 @@ __export(index_exports, {
16793
17796
  Watcher: () => Watcher,
16794
17797
  YamlEditor: () => YamlEditor,
16795
17798
  absPath: () => absPath,
17799
+ accordion: () => accordion,
17800
+ accordionItem: () => accordionItem,
17801
+ accordionPro: () => accordionPro,
16796
17802
  app: () => app,
16797
17803
  applyComments: () => applyComments,
16798
17804
  base64: () => base64,
@@ -16808,6 +17814,7 @@ __export(index_exports, {
16808
17814
  comment: () => comment,
16809
17815
  commentPath: () => commentPath,
16810
17816
  common: () => common_exports,
17817
+ components: () => components,
16811
17818
  config: () => config_exports,
16812
17819
  configPath: () => configPath,
16813
17820
  consolePath: () => consolePath,
@@ -16859,6 +17866,7 @@ __export(index_exports, {
16859
17866
  default: () => karin,
16860
17867
  defaultConfigPath: () => defaultConfigPath,
16861
17868
  defaultViewPath: () => defaultViewPath,
17869
+ divider: () => divider,
16862
17870
  downFile: () => downFile,
16863
17871
  errorToString: () => errorToString,
16864
17872
  exec: () => exec,
@@ -16898,6 +17906,7 @@ __export(index_exports, {
16898
17906
  htmlPath: () => htmlPath,
16899
17907
  importModule: () => importModule,
16900
17908
  initOneBot: () => initOneBot,
17909
+ input: () => input,
16901
17910
  isClass: () => isClass,
16902
17911
  isDir: () => isDir,
16903
17912
  isDirSync: () => isDirSync,
@@ -16977,6 +17986,7 @@ __export(index_exports, {
16977
17986
  start: () => start2,
16978
17987
  stream: () => stream,
16979
17988
  stringifyError: () => stringifyError,
17989
+ switchComponent: () => switchComponent,
16980
17990
  system: () => system_exports,
16981
17991
  tempPath: () => tempPath,
16982
17992
  unregisterBot: () => unregisterBot,
@@ -17019,6 +18029,7 @@ var init_index = __esm({
17019
18029
  init_event2();
17020
18030
  init_cache2();
17021
18031
  init_types2();
18032
+ init_components2();
17022
18033
  init_base();
17023
18034
  init_list();
17024
18035
  init_class2();
@@ -17042,6 +18053,7 @@ var init_index = __esm({
17042
18053
  });
17043
18054
  init_index();
17044
18055
  export {
18056
+ AccordionItem,
17045
18057
  AdapterBase,
17046
18058
  BaseEvent,
17047
18059
  Bot,
@@ -17095,6 +18107,9 @@ export {
17095
18107
  Watcher,
17096
18108
  YamlEditor,
17097
18109
  absPath,
18110
+ accordion,
18111
+ accordionItem,
18112
+ accordionPro,
17098
18113
  app,
17099
18114
  applyComments,
17100
18115
  base64,
@@ -17110,6 +18125,7 @@ export {
17110
18125
  comment,
17111
18126
  commentPath,
17112
18127
  common_exports as common,
18128
+ components,
17113
18129
  config_exports as config,
17114
18130
  configPath,
17115
18131
  consolePath,
@@ -17161,6 +18177,7 @@ export {
17161
18177
  karin as default,
17162
18178
  defaultConfigPath,
17163
18179
  defaultViewPath,
18180
+ divider,
17164
18181
  downFile,
17165
18182
  errorToString,
17166
18183
  exec,
@@ -17200,6 +18217,7 @@ export {
17200
18217
  htmlPath,
17201
18218
  importModule,
17202
18219
  initOneBot,
18220
+ input,
17203
18221
  isClass,
17204
18222
  isDir,
17205
18223
  isDirSync,
@@ -17279,6 +18297,7 @@ export {
17279
18297
  start2 as start,
17280
18298
  stream,
17281
18299
  stringifyError,
18300
+ switchComponent,
17282
18301
  system_exports as system,
17283
18302
  tempPath,
17284
18303
  unregisterBot,