@inpageedit/core 0.4.0 → 0.5.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 (67) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +55 -55
  3. package/dist/ActionButton-BgbTKTg7.js +24 -0
  4. package/dist/ActionButton-BgbTKTg7.js.map +1 -0
  5. package/dist/InPageEdit.d.ts +8 -7
  6. package/dist/InputBox-FIzJ-rPN.js.map +1 -1
  7. package/dist/Preferences-Bg3J5Ur9.js.map +1 -1
  8. package/dist/{RadioBox-BZFhTEo5.js → RadioBox-CaA8VgLu.js} +16 -16
  9. package/dist/RadioBox-CaA8VgLu.js.map +1 -0
  10. package/dist/components/TwinSwapInput/index.d.ts +1 -0
  11. package/dist/components/index.js +21 -22
  12. package/dist/components/index.js.map +1 -1
  13. package/dist/{index-BPsDFq9U.js → index-Bh70Udzi.js} +14 -13
  14. package/dist/index-Bh70Udzi.js.map +1 -0
  15. package/dist/index-Bo1hNwWJ.js +96 -0
  16. package/dist/index-Bo1hNwWJ.js.map +1 -0
  17. package/dist/{index-Ch5DJDZZ.js → index-BxR7MsNM.js} +105 -102
  18. package/dist/index-BxR7MsNM.js.map +1 -0
  19. package/dist/{index-BsYzf3Yw.js → index-CUXLgVhg.js} +11 -11
  20. package/dist/index-CUXLgVhg.js.map +1 -0
  21. package/dist/index-CvhkVj_L.js.map +1 -1
  22. package/dist/{index-BByzm2Fz.js → index-D3yG7jFv.js} +119 -111
  23. package/dist/{index-BByzm2Fz.js.map → index-D3yG7jFv.js.map} +1 -1
  24. package/dist/{index-D-zQLFuZ.js → index-K73DMVec.js} +13 -20
  25. package/dist/index-K73DMVec.js.map +1 -0
  26. package/dist/index-jKU6cYcH.js +165 -0
  27. package/dist/index-jKU6cYcH.js.map +1 -0
  28. package/dist/{index-X1X416tZ.js → index-mMAGhnbR.js} +40 -24
  29. package/dist/index-mMAGhnbR.js.map +1 -0
  30. package/dist/index-z5MR2HJ2.js +4820 -0
  31. package/dist/index-z5MR2HJ2.js.map +1 -0
  32. package/dist/index.js +3008 -2546
  33. package/dist/index.js.map +1 -1
  34. package/dist/plugins/BasePlugin.d.ts +1 -1
  35. package/dist/plugins/_debug/index.d.ts +1 -1
  36. package/dist/plugins/quick-diff/PluginQuickDiffCore.d.ts +2 -1
  37. package/dist/plugins/quick-edit/index.d.ts +2 -1
  38. package/dist/plugins/quick-move/index.d.ts +1 -1
  39. package/dist/plugins/quick-preview/index.d.ts +4 -3
  40. package/dist/plugins/quick-redirect/index.d.ts +1 -1
  41. package/dist/plugins/toolbox/index.d.ts +2 -2
  42. package/dist/services/ModalService/IPEModal.d.ts +235 -0
  43. package/dist/services/ModalService/index.d.ts +35 -0
  44. package/dist/sleep-DpyIipK-.js.map +1 -1
  45. package/dist/style.css +1 -1
  46. package/dist/utils/interpolate.d.ts +20 -0
  47. package/dist/utils/interpolate.spec.d.ts +1 -0
  48. package/lib/index.umd.js +53 -26
  49. package/lib/index.umd.js.map +1 -1
  50. package/lib/style.css +1 -1
  51. package/package.json +8 -9
  52. package/dist/ActionButton-ByMKIthQ.js +0 -24
  53. package/dist/ActionButton-ByMKIthQ.js.map +0 -1
  54. package/dist/RadioBox-BZFhTEo5.js.map +0 -1
  55. package/dist/index-BPsDFq9U.js.map +0 -1
  56. package/dist/index-BTngTj1f.js +0 -4682
  57. package/dist/index-BTngTj1f.js.map +0 -1
  58. package/dist/index-BsYzf3Yw.js.map +0 -1
  59. package/dist/index-Ch5DJDZZ.js.map +0 -1
  60. package/dist/index-Cq9xxVsu.js +0 -149
  61. package/dist/index-Cq9xxVsu.js.map +0 -1
  62. package/dist/index-D-zQLFuZ.js.map +0 -1
  63. package/dist/index-HyxA2rYz.js +0 -87
  64. package/dist/index-HyxA2rYz.js.map +0 -1
  65. package/dist/index-X1X416tZ.js.map +0 -1
  66. package/dist/services/SsiModalService.d.ts +0 -36
  67. package/dist/utils/Logger.d.ts +0 -106
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 dragon-fish
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 dragon-fish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,55 +1,55 @@
1
- <div align="center">
2
-
3
- [![InPageEdit Logo](https://ipe.js.org/images/logo/InPageEdit.png)](https://ipe.js.org/images/logo/InPageEdit.png)
4
-
5
- # InPageEdit NEXT
6
-
7
- 🚀 MediaWiki 的模块化、可扩展超级增强插件
8
-
9
- **InPageEdit NEXT**是由机智的小鱼君开发的一款 MediaWiki 多功能插件。主要功能旨在使许多 MediaWiki 的功能在不打开新标签页的情况下完成(包括但不限于编辑),极大加快维护 wiki 的速度。模块化设计、类型定义清晰完整,插件可自由热插拔。
10
-
11
- </div>
12
-
13
- ## 快速上手 / Quick Start
14
-
15
- [![](https://data.jsdelivr.com/v1/package/npm/@inpageedit/core/badge)](https://www.jsdelivr.com/package/npm/@inpageedit/core)
16
-
17
- 在*个人 JS 页*添加以下代码:
18
-
19
- <!-- prettier-ignore -->
20
- ```javascript
21
- // InPageEdit NEXT
22
- $('<script src="https://unpkg.com/@inpageedit/core" type="module"></script>').appendTo('body')
23
- ```
24
-
25
- ## 特色功能 / Features
26
-
27
- **编辑者视角 / For wiki editors**
28
-
29
- - 快速编辑 / Quick Edit
30
- - 快速移动 / Quick Move
31
- - 快速重定向 / Quick Redirect
32
- - 快速差异 / Quick Diff
33
- - 快速预览 / Quick Preview
34
-
35
- **开发者视角 / For developers**
36
-
37
- - 可热插拔的模块化设计
38
- - 完全使用 TypeScript 编写
39
- - 超简单的扩展能力,示例插件:[hello-world](./docs/.templates/examples/plugins/hello-world.js)
40
-
41
- ## Supported languages
42
-
43
- > [!NOTE]
44
- >
45
- > Currently only English is supported. We're working on i18n support.
46
-
47
- ---
48
-
49
- 🚀 Modular, Extensible Supercharged Plugin for MediaWiki.
50
-
51
- > [MIT License](https://opensource.org/licenses/MIT)
52
- >
53
- > InPageEdit-NEXT Copyright © 2025-present dragon-fish
54
-
55
- See more: [GitHub](https://github.com/inpageedit/inpageedit-next) | [Update logs](https://ipe.js.org/update/) | [File issues](https://github.com/inpageedit/inpageedit-next/issues)
1
+ <div align="center">
2
+
3
+ [![InPageEdit Logo](https://ipe.js.org/images/logo/InPageEdit.png)](https://ipe.js.org/images/logo/InPageEdit.png)
4
+
5
+ # InPageEdit NEXT
6
+
7
+ 🚀 MediaWiki 的模块化、可扩展超级增强插件
8
+
9
+ **InPageEdit NEXT**是由机智的小鱼君开发的一款 MediaWiki 多功能插件。主要功能旨在使许多 MediaWiki 的功能在不打开新标签页的情况下完成(包括但不限于编辑),极大加快维护 wiki 的速度。模块化设计、类型定义清晰完整,插件可自由热插拔。
10
+
11
+ </div>
12
+
13
+ ## 快速上手 / Quick Start
14
+
15
+ [![](https://data.jsdelivr.com/v1/package/npm/@inpageedit/core/badge)](https://www.jsdelivr.com/package/npm/@inpageedit/core)
16
+
17
+ 在*个人 JS 页*添加以下代码:
18
+
19
+ <!-- prettier-ignore -->
20
+ ```javascript
21
+ // InPageEdit NEXT
22
+ $('<script src="https://unpkg.com/@inpageedit/core" type="module"></script>').appendTo('body')
23
+ ```
24
+
25
+ ## 特色功能 / Features
26
+
27
+ **编辑者视角 / For wiki editors**
28
+
29
+ - 快速编辑 / Quick Edit
30
+ - 快速移动 / Quick Move
31
+ - 快速重定向 / Quick Redirect
32
+ - 快速差异 / Quick Diff
33
+ - 快速预览 / Quick Preview
34
+
35
+ **开发者视角 / For developers**
36
+
37
+ - 可热插拔的模块化设计
38
+ - 完全使用 TypeScript 编写
39
+ - 超简单的扩展能力,示例插件:[hello-world](./docs/.templates/examples/plugins/hello-world.js)
40
+
41
+ ## Supported languages
42
+
43
+ > [!NOTE]
44
+ >
45
+ > Currently only English is supported. We're working on i18n support.
46
+
47
+ ---
48
+
49
+ 🚀 Modular, Extensible Supercharged Plugin for MediaWiki.
50
+
51
+ > [MIT License](https://opensource.org/licenses/MIT)
52
+ >
53
+ > InPageEdit-NEXT Copyright © 2025-present dragon-fish
54
+
55
+ See more: [GitHub](https://github.com/inpageedit/inpageedit-next) | [Update logs](https://ipe.js.org/update/) | [File issues](https://github.com/inpageedit/inpageedit-next/issues)
@@ -0,0 +1,24 @@
1
+ import { c as s } from "./index-CvhkVj_L.js";
2
+ const d = window?.location?.origin, p = ({
3
+ type: n,
4
+ tag: t,
5
+ href: i,
6
+ target: o,
7
+ children: a,
8
+ ...e
9
+ }) => (t = t || (i ? "a" : "button"), typeof o > "u" && i && i.startsWith("http") && !i.startsWith(d) && (o = "_blank"), s(
10
+ t,
11
+ {
12
+ className: `theme-ipe ipe-action-button ipe-modal-btn is-${n || "default"}`,
13
+ // @ts-ignore
14
+ href: t === "a" ? i : void 0,
15
+ target: t === "a" ? o : void 0,
16
+ "data-href": t !== "a" ? i : void 0,
17
+ ...e
18
+ },
19
+ a
20
+ ));
21
+ export {
22
+ p as A
23
+ };
24
+ //# sourceMappingURL=ActionButton-BgbTKTg7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionButton-BgbTKTg7.js","sources":["../src/components/ActionButton.tsx"],"sourcesContent":["import { h, JSX, ReactNode } from 'jsx-dom'\n\nexport interface ActionButtonProps {\n type?: 'primary' | 'secondary' | 'danger' | 'default'\n tag?: 'a' | 'button' | 'div'\n}\n\nconst origin = window?.location?.origin\n\nexport const ActionButton = ({\n type,\n tag,\n href,\n target,\n children,\n ...rest\n}: ActionButtonProps &\n Omit<JSX.IntrinsicElements['button'], 'type'> &\n JSX.IntrinsicElements['a']) => {\n tag = tag || (href ? 'a' : 'button')\n if (\n typeof target === 'undefined' &&\n href &&\n href.startsWith('http') &&\n !href.startsWith(origin)\n ) {\n target = '_blank'\n }\n return h(\n tag,\n {\n className: `theme-ipe ipe-action-button ipe-modal-btn is-${type || 'default'}`,\n // @ts-ignore\n href: tag === 'a' ? href : undefined,\n target: tag === 'a' ? target : undefined,\n 'data-href': tag !== 'a' ? href : undefined,\n ...rest,\n },\n children\n )\n}\n"],"names":["origin","ActionButton","type","tag","href","target","children","rest","h"],"mappings":";AAOA,MAAMA,IAAS,QAAQ,UAAU,QAEpBC,IAAe,CAAC;AAAA,EAC3B,MAAAC;AAAA,EACA,KAAAC;AAAA,EACA,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,OAGEJ,IAAMA,MAAQC,IAAO,MAAM,WAEzB,OAAOC,IAAW,OAClBD,KACAA,EAAK,WAAW,MAAM,KACtB,CAACA,EAAK,WAAWJ,CAAM,MAEvBK,IAAS,WAEJG;AAAAA,EACLL;AAAA,EACA;AAAA,IACE,WAAW,gDAAgDD,KAAQ,SAAS;AAAA;AAAA,IAE5E,MAAMC,MAAQ,MAAMC,IAAO;AAAA,IAC3B,QAAQD,MAAQ,MAAME,IAAS;AAAA,IAC/B,aAAaF,MAAQ,MAAMC,IAAO;AAAA,IAClC,GAAGG;AAAA,EAAA;AAAA,EAELD;AAAA;"}
@@ -1,10 +1,5 @@
1
1
  import { Context, Inject, Events as CordisEvents } from '@cordisjs/core';
2
- import { Logger } from './utils/Logger';
3
- export interface InPageEditCoreConfig {
4
- baseURL: string | URL;
5
- legacyPreferences: Record<string, any>;
6
- logLevel: number;
7
- }
2
+ import { Logger } from '@inpageedit/logger';
8
3
  /**
9
4
  * ✏️ InPageEdit NEXT
10
5
  *
@@ -13,6 +8,7 @@ export interface InPageEditCoreConfig {
13
8
  * @author dragon-fish <dragon-fish@qq.com>
14
9
  * @license MIT
15
10
  * @see https://github.com/inpageedit/inpageedit-next
11
+ * @see https://www.ipe.wiki/
16
12
  */
17
13
  export declare class InPageEdit extends Context {
18
14
  #private;
@@ -25,8 +21,13 @@ export declare class InPageEdit extends Context {
25
21
  constructor(config?: Partial<InPageEditCoreConfig>);
26
22
  useScope(inject: Inject): Promise<this>;
27
23
  }
24
+ export interface InPageEditCoreConfig {
25
+ baseURL: string | URL;
26
+ legacyPreferences: Record<string, any>;
27
+ logLevel: number;
28
+ }
28
29
  export { default as Schema } from 'schemastery';
29
- export * from './utils/Logger';
30
+ export * from '@inpageedit/logger';
30
31
  export { Inject, Service } from '@cordisjs/core';
31
32
  export interface Events<C extends InPageEdit = InPageEdit> extends CordisEvents<C> {
32
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InputBox-FIzJ-rPN.js","sources":["../src/components/CheckBox.tsx","../src/components/InputBox.tsx"],"sourcesContent":["import { JSX, ReactNode } from 'jsx-dom'\r\n\r\nexport type CheckBoxProps = {\r\n id?: string\r\n name: string\r\n label?: string | HTMLElement\r\n checked?: boolean\r\n inputProps?: JSX.IntrinsicElements['input']\r\n labelProps?: JSX.IntrinsicElements['span']\r\n} & JSX.IntrinsicElements['label']\r\n\r\nexport const CheckBox = (props: CheckBoxProps) => {\r\n const { id, name, label, checked, inputProps, labelProps, children, ...rest } = props\r\n return (\r\n <label className=\"theme-ipe ipe-checkbox\" {...rest}>\r\n <input type=\"checkbox\" id={id} name={name} checked={checked} {...inputProps} />\r\n <span className=\"ipe-checkbox-box\"></span>\r\n <span {...labelProps}>{label || children}</span>\r\n </label>\r\n )\r\n}\r\n","import { JSX } from 'jsx-dom'\r\n\r\nexport type InputBoxProps = {\r\n label: string\r\n id?: string\r\n name: string\r\n value?: string\r\n disabled?: boolean\r\n labelProps?: JSX.IntrinsicElements['label']\r\n inputProps?: JSX.IntrinsicElements['input']\r\n} & JSX.IntrinsicElements['div']\r\n\r\nexport const InputBox = (props: InputBoxProps) => {\r\n const { label, id, name, value, disabled, labelProps, inputProps, ...rest } = props\r\n return (\r\n <div className=\"theme-ipe ipe-input-box\" {...rest}>\r\n <label htmlFor={id} style={{ display: 'block' }} {...labelProps}>\r\n {label}\r\n </label>\r\n <input\r\n id={id}\r\n name={name}\r\n value={value}\r\n disabled={disabled}\r\n style={{ width: '100%' }}\r\n {...inputProps}\r\n />\r\n </div>\r\n )\r\n}\r\n"],"names":["CheckBox","props","id","name","label","checked","inputProps","labelProps","children","rest","jsxs","jsx","InputBox","value","disabled"],"mappings":";AAWO,MAAMA,IAAW,CAACC,MAAyB;AAChD,QAAM,EAAE,IAAAC,GAAI,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,YAAAC,GAAY,YAAAC,GAAY,UAAAC,GAAU,GAAGC,EAAA,IAASR;AAChF,SACES,gBAAAA,EAAC,SAAA,EAAM,WAAU,0BAA0B,GAAGD,GAC5C,UAAA;AAAA,IAAA,gBAAAE,EAAC,WAAM,MAAK,YAAW,IAAAT,GAAQ,MAAAC,GAAY,SAAAE,GAAmB,GAAGC,GAAY;AAAA,IAC7E,gBAAAK,EAAC,QAAA,EAAK,WAAU,mBAAA,CAAmB;AAAA,IACnC,gBAAAA,EAAC,QAAA,EAAM,GAAGJ,GAAa,eAASC,EAAA,CAAS;AAAA,EAAA,GAC3C;AAEJ,GCRaI,IAAW,CAACX,MAAyB;AAChD,QAAM,EAAE,OAAAG,GAAO,IAAAF,GAAI,MAAAC,GAAM,OAAAU,GAAO,UAAAC,GAAU,YAAAP,GAAY,YAAAD,GAAY,GAAGG,EAAA,IAASR;AAC9E,SACES,gBAAAA,EAAC,OAAA,EAAI,WAAU,2BAA2B,GAAGD,GAC3C,UAAA;AAAA,IAAA,gBAAAE,EAAC,SAAA,EAAM,SAAST,GAAI,OAAO,EAAE,SAAS,QAAA,GAAY,GAAGK,GAClD,UAAAH,EAAA,CACH;AAAA,IACA,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAAT;AAAA,QACA,MAAAC;AAAA,QACA,OAAAU;AAAA,QACA,UAAAC;AAAA,QACA,OAAO,EAAE,OAAO,OAAA;AAAA,QACf,GAAGR;AAAA,MAAA;AAAA,IAAA;AAAA,EACN,GACF;AAEJ;"}
1
+ {"version":3,"file":"InputBox-FIzJ-rPN.js","sources":["../src/components/CheckBox.tsx","../src/components/InputBox.tsx"],"sourcesContent":["import { JSX, ReactNode } from 'jsx-dom'\n\nexport type CheckBoxProps = {\n id?: string\n name: string\n label?: string | HTMLElement\n checked?: boolean\n inputProps?: JSX.IntrinsicElements['input']\n labelProps?: JSX.IntrinsicElements['span']\n} & JSX.IntrinsicElements['label']\n\nexport const CheckBox = (props: CheckBoxProps) => {\n const { id, name, label, checked, inputProps, labelProps, children, ...rest } = props\n return (\n <label className=\"theme-ipe ipe-checkbox\" {...rest}>\n <input type=\"checkbox\" id={id} name={name} checked={checked} {...inputProps} />\n <span className=\"ipe-checkbox-box\"></span>\n <span {...labelProps}>{label || children}</span>\n </label>\n )\n}\n","import { JSX } from 'jsx-dom'\n\nexport type InputBoxProps = {\n label: string\n id?: string\n name: string\n value?: string\n disabled?: boolean\n labelProps?: JSX.IntrinsicElements['label']\n inputProps?: JSX.IntrinsicElements['input']\n} & JSX.IntrinsicElements['div']\n\nexport const InputBox = (props: InputBoxProps) => {\n const { label, id, name, value, disabled, labelProps, inputProps, ...rest } = props\n return (\n <div className=\"theme-ipe ipe-input-box\" {...rest}>\n <label htmlFor={id} style={{ display: 'block' }} {...labelProps}>\n {label}\n </label>\n <input\n id={id}\n name={name}\n value={value}\n disabled={disabled}\n style={{ width: '100%' }}\n {...inputProps}\n />\n </div>\n )\n}\n"],"names":["CheckBox","props","id","name","label","checked","inputProps","labelProps","children","rest","jsxs","jsx","InputBox","value","disabled"],"mappings":";AAWO,MAAMA,IAAW,CAACC,MAAyB;AAChD,QAAM,EAAE,IAAAC,GAAI,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,YAAAC,GAAY,YAAAC,GAAY,UAAAC,GAAU,GAAGC,EAAA,IAASR;AAChF,SACES,gBAAAA,EAAC,SAAA,EAAM,WAAU,0BAA0B,GAAGD,GAC5C,UAAA;AAAA,IAAA,gBAAAE,EAAC,WAAM,MAAK,YAAW,IAAAT,GAAQ,MAAAC,GAAY,SAAAE,GAAmB,GAAGC,GAAY;AAAA,IAC7E,gBAAAK,EAAC,QAAA,EAAK,WAAU,mBAAA,CAAmB;AAAA,IACnC,gBAAAA,EAAC,QAAA,EAAM,GAAGJ,GAAa,eAASC,EAAA,CAAS;AAAA,EAAA,GAC3C;AAEJ,GCRaI,IAAW,CAACX,MAAyB;AAChD,QAAM,EAAE,OAAAG,GAAO,IAAAF,GAAI,MAAAC,GAAM,OAAAU,GAAO,UAAAC,GAAU,YAAAP,GAAY,YAAAD,GAAY,GAAGG,EAAA,IAASR;AAC9E,SACES,gBAAAA,EAAC,OAAA,EAAI,WAAU,2BAA2B,GAAGD,GAC3C,UAAA;AAAA,IAAA,gBAAAE,EAAC,SAAA,EAAM,SAAST,GAAI,OAAO,EAAE,SAAS,QAAA,GAAY,GAAGK,GAClD,UAAAH,EAAA,CACH;AAAA,IACA,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAAT;AAAA,QACA,MAAAC;AAAA,QACA,OAAAU;AAAA,QACA,UAAAC;AAAA,QACA,OAAO,EAAE,OAAO,OAAA;AAAA,QACf,GAAGR;AAAA,MAAA;AAAA,IAAA;AAAA,EACN,GACF;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Preferences-Bg3J5Ur9.js","sources":["../src/decorators/Preferences.ts"],"sourcesContent":["import type Schema from 'schemastery'\r\n\r\ntype AnyConstructor<T = any> = new (...args: any[]) => T\r\n\r\nexport type PreferenceAugmented<C extends AnyConstructor, D extends Record<string, any>> = C & {\r\n PreferencesSchema: Schema<D>\r\n PreferencesDefaults: D\r\n}\r\n\r\n/**\r\n * Decorator for registering preferences\r\n *\r\n * ```ts\r\n * @RegisterPreferences(\r\n * Schema.object({\r\n * foo: Schema.string().description('Foo description'),\r\n * }),\r\n * {\r\n * foo: 'default foo value',\r\n * }\r\n * )\r\n * class Foo {}\r\n * ```\r\n *\r\n * same as:\r\n *\r\n * ```ts\r\n * class Foo {\r\n * static ConfigSchema = Schema.object({\r\n * foo: Schema.string().description('Foo description')\r\n * })\r\n * static ConfigDefaults = {\r\n * foo: 'default foo value'\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport function RegisterPreferences<D extends Record<string, any>>(schema: Schema<D>, defaults: D) {\r\n return function <T extends AnyConstructor>(target: T): PreferenceAugmented<T, D> {\r\n ;(target as any).PreferencesSchema = schema\r\n ;(target as any).PreferencesDefaults = defaults\r\n return target as PreferenceAugmented<T, D>\r\n }\r\n}\r\n"],"names":["RegisterPreferences","schema","defaults","target"],"mappings":"AAqCO,SAASA,EAAmDC,GAAmBC,GAAa;AACjG,SAAO,SAAoCC,GAAsC;AAC7E,WAAAA,EAAe,oBAAoBF,GACnCE,EAAe,sBAAsBD,GAChCC;AAAA,EACT;AACF;"}
1
+ {"version":3,"file":"Preferences-Bg3J5Ur9.js","sources":["../src/decorators/Preferences.ts"],"sourcesContent":["import type Schema from 'schemastery'\n\ntype AnyConstructor<T = any> = new (...args: any[]) => T\n\nexport type PreferenceAugmented<C extends AnyConstructor, D extends Record<string, any>> = C & {\n PreferencesSchema: Schema<D>\n PreferencesDefaults: D\n}\n\n/**\n * Decorator for registering preferences\n *\n * ```ts\n * @RegisterPreferences(\n * Schema.object({\n * foo: Schema.string().description('Foo description'),\n * }),\n * {\n * foo: 'default foo value',\n * }\n * )\n * class Foo {}\n * ```\n *\n * same as:\n *\n * ```ts\n * class Foo {\n * static ConfigSchema = Schema.object({\n * foo: Schema.string().description('Foo description')\n * })\n * static ConfigDefaults = {\n * foo: 'default foo value'\n * }\n * }\n * ```\n */\nexport function RegisterPreferences<D extends Record<string, any>>(schema: Schema<D>, defaults: D) {\n return function <T extends AnyConstructor>(target: T): PreferenceAugmented<T, D> {\n ;(target as any).PreferencesSchema = schema\n ;(target as any).PreferencesDefaults = defaults\n return target as PreferenceAugmented<T, D>\n }\n}\n"],"names":["RegisterPreferences","schema","defaults","target"],"mappings":"AAqCO,SAASA,EAAmDC,GAAmBC,GAAa;AACjG,SAAO,SAAoCC,GAAsC;AAC7E,WAAAA,EAAe,oBAAoBF,GACnCE,EAAe,sBAAsBD,GAChCC;AAAA,EACT;AACF;"}
@@ -1,10 +1,10 @@
1
1
  import { j as e } from "./index-CvhkVj_L.js";
2
- const f = "_mbox_v5fz5_1", u = "_title_v5fz5_12", v = "_content_v5fz5_19", _ = "_close_v5fz5_27", s = {
3
- mbox: f,
4
- title: u,
5
- content: v,
6
- close: _
7
- }, P = (i) => {
2
+ const u = "_mbox_5x43w_1", _ = "_title_5x43w_12", f = "_content_5x43w_19", v = "_close_5x43w_27", s = {
3
+ mbox: u,
4
+ title: _,
5
+ content: f,
6
+ close: v
7
+ }, N = (i) => {
8
8
  const {
9
9
  type: t = "default",
10
10
  title: n,
@@ -15,9 +15,9 @@ const f = "_mbox_v5fz5_1", u = "_title_v5fz5_12", v = "_content_v5fz5_19", _ = "
15
15
  children: p,
16
16
  ...m
17
17
  } = i;
18
- let d = n;
19
- typeof n > "u" && t !== "default" && (d = t[0].toUpperCase() + t.slice(1).toLowerCase());
20
- const x = async () => {
18
+ let x = n;
19
+ typeof n > "u" && t !== "default" && (x = t[0].toUpperCase() + t.slice(1).toLowerCase());
20
+ const d = async () => {
21
21
  if (!o)
22
22
  return Promise.resolve();
23
23
  const { promise: h, resolve: b } = Promise.withResolvers();
@@ -34,12 +34,12 @@ const f = "_mbox_v5fz5_1", u = "_title_v5fz5_12", v = "_content_v5fz5_19", _ = "
34
34
  o.remove(), b();
35
35
  }), h;
36
36
  }, o = /* @__PURE__ */ e("div", { className: `theme-ipe ipe-mbox mbox-type-${t || "default"} ${s.mbox}`, ...m, children: [
37
- d && /* @__PURE__ */ e("div", { className: `ipe-mbox-title ${s.title}`, ...a, children: d }),
37
+ x && /* @__PURE__ */ e("div", { className: `ipe-mbox-title ${s.title}`, ...a, children: x }),
38
38
  /* @__PURE__ */ e("div", { className: `ipe-mbox-content ${s.content}`, ...r, children: p || c }),
39
- l && /* @__PURE__ */ e("a", { onClick: x, className: `ipe-mbox-close ${s.close}`, children: "×" })
39
+ l && /* @__PURE__ */ e("a", { onClick: d, className: `ipe-mbox-close ${s.close}`, children: "×" })
40
40
  ] });
41
- return o.close = x, o;
42
- }, g = (i) => {
41
+ return o.close = d, o;
42
+ }, P = (i) => {
43
43
  const { id: t, name: n, value: c, label: l, inputProps: a, labelProps: r, children: p, ...m } = i;
44
44
  return /* @__PURE__ */ e("label", { className: "theme-ipe ipe-radio-box", ...m, children: [
45
45
  /* @__PURE__ */ e("input", { type: "radio", id: t, name: n, value: c, ...a }),
@@ -48,7 +48,7 @@ const f = "_mbox_v5fz5_1", u = "_title_v5fz5_12", v = "_content_v5fz5_19", _ = "
48
48
  ] });
49
49
  };
50
50
  export {
51
- P as M,
52
- g as R
51
+ N as M,
52
+ P as R
53
53
  };
54
- //# sourceMappingURL=RadioBox-BZFhTEo5.js.map
54
+ //# sourceMappingURL=RadioBox-CaA8VgLu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioBox-CaA8VgLu.js","sources":["../src/components/MBox/index.tsx","../src/components/RadioBox.tsx"],"sourcesContent":["import { ReactNode } from 'jsx-dom'\nimport { JSX } from 'jsx-dom/jsx-runtime'\nimport styles from './styles.module.sass'\n\nexport type MBoxProps = {\n type?:\n | ''\n | 'default'\n | 'note'\n | 'info'\n | 'tip'\n | 'success'\n | 'important'\n | 'done'\n | 'warning'\n | 'caution'\n | 'error'\n title?: ReactNode\n content?: ReactNode\n closeable?: boolean\n titleProps?: JSX.IntrinsicElements['div']\n contentProps?: JSX.IntrinsicElements['div']\n} & JSX.IntrinsicElements['div']\n\nexport type MBoxElement = HTMLElement & {\n close: () => Promise<void>\n}\n\nexport const MBox = (props: MBoxProps) => {\n const {\n type = 'default',\n title,\n content,\n closeable = true,\n titleProps,\n contentProps,\n children,\n ...rest\n } = props\n let titleContent = title\n if (typeof title === 'undefined' && type !== 'default') {\n titleContent = type[0].toUpperCase() + type.slice(1).toLowerCase()\n }\n\n const close = async () => {\n if (!box) {\n return Promise.resolve()\n }\n const { promise, resolve } = Promise.withResolvers<void>()\n\n const animation = box.animate(\n [\n { opacity: '1', height: box.clientHeight + 'px' },\n { opacity: '0', height: '0px', margin: '0px' },\n ],\n {\n duration: 300,\n easing: 'ease',\n }\n )\n\n animation.addEventListener('finish', () => {\n box.remove()\n resolve()\n })\n\n return promise\n }\n\n const box = (\n <div className={`theme-ipe ipe-mbox mbox-type-${type || 'default'} ${styles.mbox}`} {...rest}>\n {titleContent && (\n <div className={`ipe-mbox-title ${styles.title}`} {...titleProps}>\n {titleContent}\n </div>\n )}\n <div className={`ipe-mbox-content ${styles.content}`} {...contentProps}>\n {children || content}\n </div>\n {closeable && (\n <a onClick={close} className={`ipe-mbox-close ${styles.close}`}>\n ×\n </a>\n )}\n </div>\n ) as MBoxElement\n box.close = close\n return box\n}\n","import { JSX, ReactNode } from 'jsx-dom'\n\nexport type RadioBoxProps = {\n id?: string\n name: string\n value: string\n label?: string | HTMLElement\n inputProps?: JSX.IntrinsicElements['input']\n labelProps?: JSX.IntrinsicElements['span']\n} & JSX.IntrinsicElements['label']\n\nexport const RadioBox = (props: RadioBoxProps) => {\n const { id, name, value, label, inputProps, labelProps, children, ...rest } = props\n return (\n <label className=\"theme-ipe ipe-radio-box\" {...rest}>\n <input type=\"radio\" id={id} name={name} value={value} {...inputProps} />\n <span className=\"ipe-checkbox-box\"></span>\n <span {...labelProps}>{label || children}</span>\n </label>\n )\n}\n"],"names":["MBox","props","type","title","content","closeable","titleProps","contentProps","children","rest","titleContent","close","box","promise","resolve","jsxs","styles","jsx","RadioBox","id","name","value","label","inputProps","labelProps"],"mappings":";;;;;;GA4BaA,IAAO,CAACC,MAAqB;AACxC,QAAM;AAAA,IACJ,MAAAC,IAAO;AAAA,IACP,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACDR;AACJ,MAAIS,IAAeP;AACnB,EAAI,OAAOA,IAAU,OAAeD,MAAS,cAC3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2BAA2B,GAAGN,GAC7C,UAAA;AAAA,IAAA,gBAAAQ,EAAC,WAAM,MAAK,SAAQ,IAAAE,GAAQ,MAAAC,GAAY,OAAAC,GAAe,GAAGE,GAAY;AAAA,IACtE,gBAAAN,EAAC,QAAA,EAAK,WAAU,mBAAA,CAAmB;AAAA,IACnC,gBAAAA,EAAC,QAAA,EAAM,GAAGO,GAAa,eAAShB,EAAA,CAAS;AAAA,EAAA,GAC3C;AAEJ;"}
@@ -9,6 +9,7 @@ export interface TwinSwapInputInput {
9
9
  name: string;
10
10
  value?: string;
11
11
  disabled?: boolean;
12
+ required?: boolean;
12
13
  inputProps?: Omit<JSX.IntrinsicElements['input'], 'name' | 'value'>;
13
14
  }
14
15
  export type TwinSwapElement = HTMLDivElement & {
@@ -1,35 +1,34 @@
1
- import { M as y, R as x } from "../RadioBox-BZFhTEo5.js";
2
- import { j as i } from "../index-CvhkVj_L.js";
1
+ import { M as y, R as x } from "../RadioBox-CaA8VgLu.js";
2
+ import { j as n } from "../index-CvhkVj_L.js";
3
3
  import { P as L } from "../index-CvhkVj_L.js";
4
- import { T as A } from "../index-BPsDFq9U.js";
5
- import { A as N } from "../ActionButton-ByMKIthQ.js";
4
+ import { T as g } from "../index-Bh70Udzi.js";
5
+ import { A as N } from "../ActionButton-BgbTKTg7.js";
6
6
  import { C as z, I as $ } from "../InputBox-FIzJ-rPN.js";
7
- const r = "_tabview_zlbug_1", _ = "_labels_container_zlbug_4", b = "_label_zlbug_4", d = "_active_zlbug_32", m = "_contents_container_zlbug_35", t = {
7
+ const r = "_tabview_zlbug_1", _ = "_labels_container_zlbug_4", b = "_label_zlbug_4", d = "_active_zlbug_32", m = "_contents_container_zlbug_35", i = {
8
8
  tabview: r,
9
9
  labels_container: _,
10
10
  label: b,
11
11
  active: d,
12
12
  contents_container: m
13
13
  };
14
- console.log(t);
15
14
  function h({
16
- tabs: n = [],
15
+ tabs: t = [],
17
16
  defaultActiveIndex: l = 0
18
17
  }) {
19
- const c = /* @__PURE__ */ i("div", { className: `ipe-tabView ${t.tabview}`, children: [
20
- /* @__PURE__ */ i("ul", { className: `ipe-tabView__labels-container ${t.labels_container}`, children: n.map((a) => /* @__PURE__ */ i(f, { name: a.name, children: a.children }, a.name)) }),
21
- /* @__PURE__ */ i("div", { className: `ipe-tabView__contents ${t.contents_container}`, children: n.map((a) => /* @__PURE__ */ i(p, { name: a.name, children: a.content }, a.name)) })
18
+ const c = /* @__PURE__ */ n("div", { className: `ipe-tabView ${i.tabview}`, children: [
19
+ /* @__PURE__ */ n("ul", { className: `ipe-tabView__labels-container ${i.labels_container}`, children: t.map((a) => /* @__PURE__ */ n(f, { name: a.name, children: a.children }, a.name)) }),
20
+ /* @__PURE__ */ n("div", { className: `ipe-tabView__contents ${i.contents_container}`, children: t.map((a) => /* @__PURE__ */ n(p, { name: a.name, children: a.content }, a.name)) })
22
21
  ] }), s = c.querySelector(
23
22
  `.ipe-tabView__labels-container > .ipe-tabView__label:nth-child(${l + 1})`
24
23
  );
25
24
  return s && s.click(), c;
26
25
  }
27
- function f({ name: n, children: l }) {
28
- return /* @__PURE__ */ i(
26
+ function f({ name: t, children: l }) {
27
+ return /* @__PURE__ */ n(
29
28
  "li",
30
29
  {
31
- "data-tab-name": n,
32
- className: `ipe-tabView__label ${t.label}`,
30
+ "data-tab-name": t,
31
+ className: `ipe-tabView__label ${i.label}`,
33
32
  onClick: function(c) {
34
33
  c.preventDefault();
35
34
  const s = this.closest(".ipe-tabView");
@@ -38,24 +37,24 @@ function f({ name: n, children: l }) {
38
37
  (e) => e.classList.contains("ipe-tabView__labels")
39
38
  )?.children;
40
39
  a && Array.from(a).forEach((e) => {
41
- e.classList.remove(t.active);
42
- }), this.classList.add(t.active);
40
+ e.classList.remove(i.active);
41
+ }), this.classList.add(i.active);
43
42
  const o = Array.from(s.children).find(
44
43
  (e) => e.classList.contains("ipe-tabView__contents")
45
44
  )?.children;
46
45
  o && Array.from(o).forEach((e) => {
47
- e instanceof HTMLElement && (e.dataset.tabName === n ? (e.style.display = "", e.classList.add(t.active)) : (e.style.display = "none", e.classList.remove(t.active)));
46
+ e instanceof HTMLElement && (e.dataset.tabName === t ? (e.style.display = "", e.classList.add(i.active)) : (e.style.display = "none", e.classList.remove(i.active)));
48
47
  });
49
48
  },
50
- children: /* @__PURE__ */ i("a", { children: l || n })
49
+ children: /* @__PURE__ */ n("a", { children: l || t })
51
50
  }
52
51
  );
53
52
  }
54
- function p({ name: n, children: l }) {
55
- return /* @__PURE__ */ i(
53
+ function p({ name: t, children: l }) {
54
+ return /* @__PURE__ */ n(
56
55
  "div",
57
56
  {
58
- "data-tab-name": n,
57
+ "data-tab-name": t,
59
58
  className: "ipe-tabView__content-body",
60
59
  style: {
61
60
  display: "none"
@@ -74,6 +73,6 @@ export {
74
73
  p as TabContent,
75
74
  f as TabLabel,
76
75
  h as TabView,
77
- A as TwinSwapInput
76
+ g as TwinSwapInput
78
77
  };
79
78
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/TabView/index.tsx"],"sourcesContent":["import { ReactNode } from 'jsx-dom'\r\nimport styles from './styles.module.sass'\r\n\r\nexport interface TabViewLabelOptions {\r\n name: string\r\n children: ReactNode\r\n}\r\n\r\nconsole.log(styles)\r\n\r\nexport function TabView({\r\n tabs = [],\r\n defaultActiveIndex = 0,\r\n}: {\r\n tabs: (TabViewLabelOptions & { content: ReactNode })[]\r\n defaultActiveIndex?: number\r\n}) {\r\n const el = (\r\n <div className={`ipe-tabView ${styles.tabview}`}>\r\n <ul className={`ipe-tabView__labels-container ${styles.labels_container}`}>\r\n {tabs.map((tab) => (\r\n <TabLabel key={tab.name} name={tab.name}>\r\n {tab.children}\r\n </TabLabel>\r\n ))}\r\n </ul>\r\n <div className={`ipe-tabView__contents ${styles.contents_container}`}>\r\n {tabs.map((tab) => (\r\n <TabContent key={tab.name} name={tab.name}>\r\n {tab.content}\r\n </TabContent>\r\n ))}\r\n </div>\r\n </div>\r\n )\r\n\r\n const defaultActiveLabel = el.querySelector<HTMLAnchorElement>(\r\n `.ipe-tabView__labels-container > .ipe-tabView__label:nth-child(${defaultActiveIndex + 1})`\r\n )\r\n if (defaultActiveLabel) {\r\n defaultActiveLabel.click()\r\n }\r\n\r\n return el\r\n}\r\n\r\nexport function TabLabel({ name, children }: { name: string; children: ReactNode }) {\r\n return (\r\n <li\r\n data-tab-name={name}\r\n className={`ipe-tabView__label ${styles.label}`}\r\n onClick={function (e) {\r\n e.preventDefault()\r\n const container = this.closest('.ipe-tabView')\r\n if (!container) return\r\n const labels = Array.from(container.children).find((el) =>\r\n el.classList.contains('ipe-tabView__labels')\r\n )?.children\r\n if (labels) {\r\n Array.from(labels).forEach((label) => {\r\n label.classList.remove(styles.active)\r\n })\r\n }\r\n this.classList.add(styles.active)\r\n const contents = Array.from(container.children).find((el) =>\r\n el.classList.contains('ipe-tabView__contents')\r\n )?.children\r\n if (contents) {\r\n Array.from(contents).forEach((content) => {\r\n if (content instanceof HTMLElement) {\r\n if (content.dataset.tabName === name) {\r\n content.style.display = ''\r\n content.classList.add(styles.active)\r\n } else {\r\n content.style.display = 'none'\r\n content.classList.remove(styles.active)\r\n }\r\n }\r\n })\r\n }\r\n }}\r\n >\r\n <a>{children || name}</a>\r\n </li>\r\n )\r\n}\r\n\r\nexport function TabContent({ name, children }: { name: string; children: ReactNode }) {\r\n return (\r\n <div\r\n data-tab-name={name}\r\n className=\"ipe-tabView__content-body\"\r\n style={{\r\n display: 'none',\r\n }}\r\n >\r\n {children}\r\n </div>\r\n )\r\n}\r\n"],"names":["styles","TabView","tabs","defaultActiveIndex","el","jsxs","jsx","tab","TabLabel","TabContent","defaultActiveLabel","name","children","e","container","labels","label","contents","content"],"mappings":";;;;;;;;;;;;;AAQA,QAAQ,IAAIA,CAAM;AAEX,SAASC,EAAQ;AAAA,EACtB,MAAAC,IAAO,CAAA;AAAA,EACP,oBAAAC,IAAqB;AACvB,GAGG;AACD,QAAMC,IACJC,gBAA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QAAA,GAC5C;AACH,QAAIa,KACF,MAAM,KAAKA,CAAQ,EAAE,QAAQ,CAACC,MAAY;AACxC,UAAIA,aAAmB,gBACjBA,EAAQ,QAAQ,YAAYP,KAC9BO,EAAQ,MAAM,UAAU,IACxBA,EAAQ,UAAU,IAAIlB,EAAO,MAAM,MAEnCkB,EAAQ,MAAM,UAAU,QACxBA,EAAQ,UAAU,OAAOlB,EAAO,MAAM;AAAA,QAG5C,CAAC;AAAA,MAEL;AAAA,MAEA,UAAA,gBAAAM,EAAC,KAAA,EAAG,UAAAM,KAAYD,EAAA,CAAK;AAAA,IAAA;AAAA,EAAA;AAG3B;AAEO,SAASF,EAAW,EAAE,MAAAE,GAAM,UAAAC,KAAmD;AACpF,SACE,gBAAAN;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,iBAAeK;AAAA,MACf,WAAU;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,MAAA;AAAA,MAGV,UAAAC;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/components/TabView/index.tsx"],"sourcesContent":["import { ReactNode } from 'jsx-dom'\nimport styles from './styles.module.sass'\n\nexport interface TabViewLabelOptions {\n name: string\n children: ReactNode\n}\n\nconsole.log(styles)\n\nexport function TabView({\n tabs = [],\n defaultActiveIndex = 0,\n}: {\n tabs: (TabViewLabelOptions & { content: ReactNode })[]\n defaultActiveIndex?: number\n}) {\n const el = (\n <div className={`ipe-tabView ${styles.tabview}`}>\n <ul className={`ipe-tabView__labels-container ${styles.labels_container}`}>\n {tabs.map((tab) => (\n <TabLabel key={tab.name} name={tab.name}>\n {tab.children}\n </TabLabel>\n ))}\n </ul>\n <div className={`ipe-tabView__contents ${styles.contents_container}`}>\n {tabs.map((tab) => (\n <TabContent key={tab.name} name={tab.name}>\n {tab.content}\n </TabContent>\n ))}\n </div>\n </div>\n )\n\n const defaultActiveLabel = el.querySelector<HTMLAnchorElement>(\n `.ipe-tabView__labels-container > .ipe-tabView__label:nth-child(${defaultActiveIndex + 1})`\n )\n if (defaultActiveLabel) {\n defaultActiveLabel.click()\n }\n\n return el\n}\n\nexport function TabLabel({ name, children }: { name: string; children: ReactNode }) {\n return (\n <li\n data-tab-name={name}\n className={`ipe-tabView__label ${styles.label}`}\n onClick={function (e) {\n e.preventDefault()\n const container = this.closest('.ipe-tabView')\n if (!container) return\n const labels = Array.from(container.children).find((el) =>\n el.classList.contains('ipe-tabView__labels')\n )?.children\n if (labels) {\n Array.from(labels).forEach((label) => {\n label.classList.remove(styles.active)\n })\n }\n this.classList.add(styles.active)\n const contents = Array.from(container.children).find((el) =>\n el.classList.contains('ipe-tabView__contents')\n )?.children\n if (contents) {\n Array.from(contents).forEach((content) => {\n if (content instanceof HTMLElement) {\n if (content.dataset.tabName === name) {\n content.style.display = ''\n content.classList.add(styles.active)\n } else {\n content.style.display = 'none'\n content.classList.remove(styles.active)\n }\n }\n })\n }\n }}\n >\n <a>{children || name}</a>\n </li>\n )\n}\n\nexport function TabContent({ name, children }: { name: string; children: ReactNode }) {\n return (\n <div\n data-tab-name={name}\n className=\"ipe-tabView__content-body\"\n style={{\n display: 'none',\n }}\n >\n {children}\n </div>\n )\n}\n"],"names":["TabView","tabs","defaultActiveIndex","el","jsxs","styles","jsx","tab","TabLabel","TabContent","defaultActiveLabel","name","children","e","container","labels","label","contents","content"],"mappings":";;;;;;;;;;;;;AAUO,SAASA,EAAQ;AAAA,EACtB,MAAAC,IAAO,CAAA;AAAA,EACP,oBAAAC,IAAqB;AACvB,GAGG;AACD,QAAMC,IACJC,gBAAAA,EAAC,OAAA,EAAI,WAAW,eAAeC,EAAO,OAAO,IAC3C,UAAA;AAAA,IAAA,gBAAAC,EAAC,MAAA,EAAG,WAAW,iCAAiCD,EAAO,gBAAgB,IACpE,UAAAJ,EAAK,IAAI,CAACM,wBACRC,GAAA,EAAwB,MAAMD,EAAI,MAChC,UAAAA,EAAI,YADQA,EAAI,IAEnB,CACD,EAAA,CACH;AAAA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O,MAAM;AAAA,QAG5C,CAAC;AAAA,MAEL;AAAA,MAEA,UAAA,gBAAAC,EAAC,KAAA,EAAG,UAAAM,KAAYD,EAAA,CAAK;AAAA,IAAA;AAAA,EAAA;AAG3B;AAEO,SAASF,EAAW,EAAE,MAAAE,GAAM,UAAAC,KAAmD;AACpF,SACE,gBAAAN;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,iBAAeK;AAAA,MACf,WAAU;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,MAAA;AAAA,MAGV,UAAAC;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -1,11 +1,11 @@
1
1
  import { j as n } from "./index-CvhkVj_L.js";
2
- const x = "_twinSwapInput_1gdgl_9", y = "_inputWrapper_1gdgl_23", L = "_inputLeft_1gdgl_27", W = "_inputRight_1gdgl_30", $ = "_swapButton_1gdgl_46", i = {
3
- twinSwapInput: x,
4
- inputWrapper: y,
5
- inputLeft: L,
6
- inputRight: W,
7
- swapButton: $
8
- }, C = (f) => {
2
+ const y = "_twinSwapInput_1gdgl_9", L = "_inputWrapper_1gdgl_23", W = "_inputLeft_1gdgl_27", $ = "_inputRight_1gdgl_30", j = "_swapButton_1gdgl_46", i = {
3
+ twinSwapInput: y,
4
+ inputWrapper: L,
5
+ inputLeft: W,
6
+ inputRight: $,
7
+ swapButton: j
8
+ }, M = (f) => {
9
9
  const { inputs: l, enableSwap: b = !0, ...v } = f, _ = l?.length === 2 ? l : [l?.[0] ?? {}, l?.[1] ?? {}], s = [null, null];
10
10
  let c = 0, o = null, p = null;
11
11
  const d = () => s.some((t) => t && t.disabled), w = () => {
@@ -50,23 +50,24 @@ const x = "_twinSwapInput_1gdgl_9", y = "_inputWrapper_1gdgl_23", L = "_inputLef
50
50
  }
51
51
  ), r = /* @__PURE__ */ n("div", { className: `twin-swap-input ${i.twinSwapInput}`, ...v, children: [
52
52
  _.map((t, e) => {
53
- const { label: a, id: u, name: h, value: S, disabled: k, inputProps: B } = t, E = e === 0, g = u || h;
53
+ const { label: a, id: u, name: h, value: S, disabled: k, required: B, inputProps: E } = t, R = e === 0, g = u || h;
54
54
  return /* @__PURE__ */ n(
55
55
  "div",
56
56
  {
57
- className: `${i.inputWrapper} ${E ? i.inputLeft : i.inputRight}`,
57
+ className: `${i.inputWrapper} ${R ? i.inputLeft : i.inputRight}`,
58
58
  children: [
59
59
  a && /* @__PURE__ */ n("label", { htmlFor: g, children: a }),
60
60
  /* @__PURE__ */ n(
61
61
  "input",
62
62
  {
63
- ref: (R) => s[e] = R,
63
+ ref: (x) => s[e] = x,
64
64
  type: "text",
65
65
  id: g,
66
66
  name: h,
67
67
  value: S,
68
68
  disabled: k,
69
- ...B
69
+ required: B,
70
+ ...E
70
71
  }
71
72
  )
72
73
  ]
@@ -78,6 +79,6 @@ const x = "_twinSwapInput_1gdgl_9", y = "_inputWrapper_1gdgl_23", L = "_inputLef
78
79
  return r.swap = w, r.toggleEnableSwap = m, r;
79
80
  };
80
81
  export {
81
- C as T
82
+ M as T
82
83
  };
83
- //# sourceMappingURL=index-BPsDFq9U.js.map
84
+ //# sourceMappingURL=index-Bh70Udzi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Bh70Udzi.js","sources":["../src/components/TwinSwapInput/index.tsx"],"sourcesContent":["import { JSX } from 'jsx-dom/jsx-runtime'\nimport styles from './styles.module.sass'\n\nexport type TwinSwapInputProps = {\n inputs: [TwinSwapInputInput, TwinSwapInputInput]\n enableSwap?: boolean\n} & JSX.IntrinsicElements['div']\n\nexport interface TwinSwapInputInput {\n label?: string\n id?: string\n name: string\n value?: string\n disabled?: boolean\n required?: boolean\n inputProps?: Omit<JSX.IntrinsicElements['input'], 'name' | 'value'>\n}\n\nexport type TwinSwapElement = HTMLDivElement & {\n swap: () => void\n toggleEnableSwap: (enable?: boolean) => void\n}\n\nexport const TwinSwapInput = (props: TwinSwapInputProps) => {\n const { inputs, enableSwap = true, ...rest } = props\n\n const normalizedInputs =\n inputs?.length === 2\n ? inputs\n : ([inputs?.[0] ?? {}, inputs?.[1] ?? {}] as [TwinSwapInputInput, TwinSwapInputInput])\n\n // 内部稳定引用\n const inputRefs: [HTMLInputElement | null, HTMLInputElement | null] = [null, null]\n\n let swapCount = 0\n let swapBtnRef: HTMLButtonElement | null = null\n let svgRef: SVGElement | null = null\n\n const checkIfInputDisabled = () => inputRefs.some((el) => el && el.disabled)\n\n const swap = () => {\n if (!inputRefs[0] || !inputRefs[1]) return\n if (checkIfInputDisabled()) return\n\n const a = inputRefs[0]\n const b = inputRefs[1]\n const va = a.value\n const vb = b.value\n a.value = vb\n b.value = va\n\n // 与原实现一致:派发 change(不冒泡)\n a.dispatchEvent(new Event('change'))\n b.dispatchEvent(new Event('change'))\n\n swapCount++\n if (svgRef) {\n svgRef.style.transform = `rotateY(${swapCount * -180}deg)`\n svgRef.style.transition = 'transform 200ms ease'\n }\n }\n\n const toggleEnableSwap = (enable?: boolean) => {\n if (!swapBtnRef) return\n const next = enable ?? !swapBtnRef.disabled\n swapBtnRef.disabled = !next\n if (next) {\n // 与原实现一致:开启时把 inputs 解禁\n inputRefs.forEach((el) => {\n if (el) el.disabled = false\n })\n }\n }\n\n const swapButton = (\n <button\n type=\"button\"\n aria-label=\"Swap values\"\n onClick={swap}\n disabled={checkIfInputDisabled() || !enableSwap}\n ref={(el) => (swapBtnRef = el as HTMLButtonElement)}\n >\n <svg\n ref={(el) => (svgRef = el as unknown as SVGElement)}\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon-tabler icons-tabler-outline icon-tabler-transfer\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M20 10h-16l5.5 -6\" />\n <path d=\"M4 14h16l-5.5 6\" />\n </svg>\n </button>\n ) as HTMLButtonElement\n\n const container = (\n <div className={`twin-swap-input ${styles.twinSwapInput}`} {...rest}>\n {normalizedInputs.map((input, index) => {\n const { label, id, name, value, disabled, required, inputProps } = input\n const isLeft = index === 0\n const inputId = id || name\n\n return (\n <div\n className={`${styles.inputWrapper} ${isLeft ? styles.inputLeft : styles.inputRight}`}\n >\n {label && <label htmlFor={inputId}>{label}</label>}\n <input\n ref={(el) => (inputRefs[index] = el as HTMLInputElement)}\n type=\"text\"\n id={inputId}\n name={name}\n value={value}\n disabled={disabled}\n required={required}\n {...inputProps}\n />\n </div>\n )\n })}\n\n <div className={styles.swapButton}>{swapButton}</div>\n </div>\n ) as TwinSwapElement\n\n container.swap = swap\n container.toggleEnableSwap = toggleEnableSwap\n\n return container\n}\n"],"names":["TwinSwapInput","props","inputs","enableSwap","rest","normalizedInputs","inputRefs","swapCount","swapBtnRef","svgRef","checkIfInputDisabled","el","swap","a","b","va","vb","toggleEnableSwap","enable","next","swapButton","jsx","jsxs","container","styles","input","index","label","id","name","value","disabled","required","inputProps","isLeft","inputId"],"mappings":";;;;;;;GAuBaA,IAAgB,CAACC,MAA8B;AAC1D,QAAM,EAAE,QAAAC,GAAQ,YAAAC,IAAa,IAAM,GAAGC,MAASH,GAEzCI,IACJH,GAAQ,WAAW,IACfA,IACC,CAACA,IAAS,CAAC,KAAK,CAAA,GAAIA,IAAS,CAAC,KAAK,CAAA,CAAE,GAGtCI,IAAgE,CAAC,MAAM,IAAI;AAEjF,MAAIC,IAAY,GACZC,IAAuC,MACvCC,IAA4B;AAEhC,QAAMC,IAAuB,MAAMJ,EAAU,KAAK,CAACK,MAAOA,KAAMA,EAAG,QAAQ,GAErEC,IAAO,MAAM;AAEjB,QADI,CAACN,EAAU,CAAC,KAAK,CAACA,EAAU,CAAC,KAC7BI,IAAwB;AAE5B,UAAMG,IAAIP,EAAU,CAAC,GACfQ,IAAIR,EAAU,CAAC,GACfS,IAAKF,EAAE,OACPG,IAAKF,EAAE;AACb,IAAAD,EAAE,QAAQG,GACVF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AI,CAACoB,GAAOC,MAAU;AACtC,YAAM,EAAE,OAAAC,GAAO,IAAAC,GAAI,MAAAC,GAAM,OAAAC,GAAO,UAAAC,GAAU,UAAAC,GAAU,YAAAC,MAAeR,GAC7DS,IAASR,MAAU,GACnBS,IAAUP,KAAMC;AAEtB,aACEP,gBAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,GAAGE,EAAO,YAAY,IAAIU,IAASV,EAAO,YAAYA,EAAO,UAAU;AAAA,UAEjF,UAAA;AAAA,YAAAG,KAAS,gBAAAN,EAAC,SAAA,EAAM,SAASc,GAAU,UAAAR,GAAM;AAAA,YAC1C,gBAAAN;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAK,CAACV,MAAQL,EAAUoB,CAAK,IAAIf;AAAA,gBACjC,MAAK;AAAA,gBACL,IAAIwB;AAAA,gBACJ,MAAAN;AAAA,gBACA,OAAAC;AAAA,gBACA,UAAAC;AAAA,gBACA,UAAAC;AAAA,gBACC,GAAGC;AAAA,cAAA;AAAA,YAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN,CAAC;AAAA,IAED,gBAAAZ,EAAC,OAAA,EAAI,WAAWG,EAAO,YAAa,UAAAJ,EAAA,CAAW;AAAA,EAAA,GACjD;AAGF,SAAAG,EAAU,OAAOX,GACjBW,EAAU,mBAAmBN,GAEtBM;AACT;"}
@@ -0,0 +1,96 @@
1
+ import { j as s, F as m, P as j } from "./index-CvhkVj_L.js";
2
+ import { BasePlugin as E, Inject as y } from "./index.js";
3
+ var S = Object.create, _ = Object.defineProperty, F = Object.getOwnPropertyDescriptor, k = (t, i) => (i = Symbol[t]) ? i : Symbol.for("Symbol." + t), x = (t) => {
4
+ throw TypeError(t);
5
+ }, O = (t, i, r) => i in t ? _(t, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[i] = r, Q = (t, i) => _(t, "name", { value: i, configurable: !0 }), T = (t) => [, , , S(t?.[k("metadata")] ?? null)], z = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], f = (t) => t !== void 0 && typeof t != "function" ? x("Function expected") : t, C = (t, i, r, a, e) => ({ kind: z[t], name: i, metadata: a, addInitializer: (c) => r._ ? x("Already initialized") : e.push(f(c || null)) }), I = (t, i) => O(i, k("metadata"), t[3]), B = (t, i, r, a) => {
6
+ for (var e = 0, c = t[i >> 1], n = c && c.length; e < n; e++) c[e].call(r);
7
+ return a;
8
+ }, D = (t, i, r, a, e, c) => {
9
+ var n, o, u, l = i & 7, w = !1, P = 0, q = t[P] || (t[P] = []), d = l && (e = e.prototype, l < 5 && (l > 3 || !w) && F(e, r));
10
+ Q(e, r);
11
+ for (var v = a.length - 1; v >= 0; v--)
12
+ u = C(l, r, o = {}, t[3], q), n = (0, a[v])(e, u), o._ = 1, f(n) && (e = n);
13
+ return I(t, e), d && _(e, r, d), w ? l ^ 4 ? c : d : e;
14
+ }, g, h, b;
15
+ g = [y(["api", "wikiPage", "modal"])];
16
+ class p extends (b = E) {
17
+ constructor(i) {
18
+ super(i, {}, "quickPreview"), this.ctx = i;
19
+ }
20
+ start() {
21
+ this.ctx.set("quickPreview", this.quickPreview.bind(this)), this.ctx.on("quickEdit/wikiPage", this.injectQuickEdit.bind(this));
22
+ }
23
+ stop() {
24
+ this.ctx.off("quickEdit/wikiPage", this.injectQuickEdit.bind(this));
25
+ }
26
+ injectQuickEdit({ ctx: i, modal: r, wikiPage: a }) {
27
+ let e;
28
+ r.addButton(
29
+ {
30
+ label: "Preview",
31
+ side: "left",
32
+ className: "btn btn-secondary",
33
+ method: () => {
34
+ e = this.quickPreview(
35
+ r.get$content().querySelector('textarea[name="text"]')?.value || "",
36
+ void 0,
37
+ a,
38
+ e
39
+ );
40
+ }
41
+ },
42
+ 2
43
+ );
44
+ }
45
+ quickPreview(i, r, a, e) {
46
+ return a ||= this.ctx.wikiPage.newBlankPage({
47
+ title: "API"
48
+ }), (!e || e.isDestroyed) && (e = this.ctx.modal.createObject({
49
+ className: "in-page-edit ipe-quickPreview",
50
+ sizeClass: "large",
51
+ backdrop: !1,
52
+ draggable: !0
53
+ }).init()), e.show(), e.setTitle("Preview loading..."), e.setContent(/* @__PURE__ */ s(j, {})), e.bringToFront(), this.ctx.emit("quickPreview/showModal", {
54
+ ctx: this.ctx,
55
+ text: i,
56
+ modal: e,
57
+ wikiPage: a
58
+ }), a.preview(i, r).then((c) => {
59
+ const {
60
+ data: { parse: n }
61
+ } = c;
62
+ e.setTitle(`Preview - ${n.title}`);
63
+ let o = null;
64
+ e.setContent(
65
+ /* @__PURE__ */ s("section", { children: /* @__PURE__ */ s(
66
+ "div",
67
+ {
68
+ ref: (u) => o = u,
69
+ className: "mw-parser-output",
70
+ innerHTML: n.text
71
+ }
72
+ ) })
73
+ ), window.mw?.hook("wikipage.content").fire($(o)), this.ctx.emit("quickPreview/loaded", {
74
+ ctx: this.ctx,
75
+ modal: e,
76
+ wikiPage: a,
77
+ text: i,
78
+ parseData: n
79
+ });
80
+ }).catch((c) => {
81
+ e.setTitle("Preview failed"), e.setContent(
82
+ /* @__PURE__ */ s(m, { children: [
83
+ /* @__PURE__ */ s("p", { children: "Failed to preview" }),
84
+ /* @__PURE__ */ s("p", { children: c instanceof Error ? c.message : String(c) })
85
+ ] })
86
+ );
87
+ }), e;
88
+ }
89
+ }
90
+ h = T(b);
91
+ p = D(h, 0, "PluginQuickPreview", g, p);
92
+ B(h, 1, p);
93
+ export {
94
+ p as PluginQuickPreview
95
+ };
96
+ //# sourceMappingURL=index-Bo1hNwWJ.js.map