node-karin 1.3.0 → 1.3.2

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