jqtree 1.9.0 → 1.9.1

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/eslint.config.mjs DELETED
@@ -1,112 +0,0 @@
1
- import cspellESLintPluginRecommended from "@cspell/eslint-plugin/recommended";
2
- import eslint from "@eslint/js";
3
- import tseslint from "typescript-eslint";
4
- import importPlugin from "eslint-plugin-import-x";
5
- import jestDomPlugin from "eslint-plugin-jest-dom";
6
- import jestExtendedPlugin from "eslint-plugin-jest-extended";
7
- import perfectionistPlugin from "eslint-plugin-perfectionist";
8
- import playwrightPlugin from "eslint-plugin-playwright";
9
- import testingLibraryPlugin from "eslint-plugin-testing-library";
10
- import vitestPlugin from "@vitest/eslint-plugin";
11
-
12
- export default [
13
- eslint.configs.recommended,
14
- ...tseslint.configs.strictTypeChecked,
15
- ...tseslint.configs.stylisticTypeChecked,
16
- importPlugin.flatConfigs.recommended,
17
- importPlugin.flatConfigs.typescript,
18
- perfectionistPlugin.configs["recommended-natural"],
19
- cspellESLintPluginRecommended,
20
- {
21
- languageOptions: {
22
- parserOptions: {
23
- projectService: true,
24
- tsconfigRootDir: import.meta.dirname,
25
- },
26
- },
27
- rules: {
28
- "@typescript-eslint/consistent-type-imports": "error",
29
- "@typescript-eslint/explicit-function-return-type": "off",
30
- "@typescript-eslint/interface-name-prefix": "off",
31
- "@typescript-eslint/no-empty-object-type": "off",
32
- "@typescript-eslint/no-explicit-any": "off",
33
- "@typescript-eslint/no-use-before-define": "off",
34
- "@typescript-eslint/no-unused-vars": [
35
- "error",
36
- {
37
- argsIgnorePattern: "^_",
38
- varsIgnorePattern: "^_",
39
- },
40
- ],
41
- "@typescript-eslint/non-nullable-type-assertion-style": "off",
42
- "@typescript-eslint/prefer-includes": "off",
43
- "@typescript-eslint/triple-slash-reference": "off",
44
- "@typescript-eslint/prefer-string-starts-ends-with": "off",
45
- "@typescript-eslint/restrict-template-expressions": [
46
- "error",
47
- {
48
- allowNumber: true,
49
- allowBoolean: true,
50
- allowAny: false,
51
- allowNullish: false,
52
- },
53
- ],
54
- "@typescript-eslint/unified-signatures": "off",
55
- "@cspell/spellchecker": [
56
- "error",
57
- {
58
- configFile: "./config/cspell.json",
59
- },
60
- ],
61
- },
62
- },
63
- {
64
- files: ["test/**/*.ts"],
65
- ...vitestPlugin.configs.all,
66
- },
67
- {
68
- files: ["test/**/*.ts"],
69
- rules: {
70
- "import-x/no-named-as-default": "off",
71
- "import-x/no-named-as-default-member": "off",
72
- "vitest/no-duplicate-hooks": "off",
73
- "vitest/no-hooks": "off",
74
- "vitest/no-identical-title": "off",
75
- "vitest/prefer-called-times": "off",
76
- "vitest/prefer-describe-function-title": "off",
77
- "vitest/prefer-expect-assertions": "off",
78
- "vitest/prefer-importing-vitest-globals": "off",
79
- "vitest/prefer-lowercase-title": "off",
80
- "vitest/prefer-strict-boolean-matchers": "off",
81
- "vitest/require-hook": "off",
82
- "vitest/require-mock-type-parameters": "off",
83
- },
84
- },
85
- {
86
- files: ["test/**/*.ts"],
87
- ...testingLibraryPlugin.configs["flat/dom"],
88
- },
89
- {
90
- files: ["test/**/*.ts"],
91
- ...jestDomPlugin.configs["flat/recommended"],
92
- },
93
- {
94
- files: ["test/**/*.ts"],
95
- ...jestExtendedPlugin.configs["flat/all"],
96
- },
97
- {
98
- files: ["test/**/*.ts"],
99
- rules: {
100
- "perfectionist/sort-imports": [
101
- "error",
102
- {
103
- internalPattern: ["^app"],
104
- },
105
- ],
106
- },
107
- },
108
- {
109
- files: ["playwright/**/*.ts"],
110
- ...playwrightPlugin.configs["flat/recommended"],
111
- },
112
- ];
@@ -1,134 +0,0 @@
1
- const register = (widgetClass: unknown, widgetName: string): void => {
2
- const getDataKey = (): string => `simple_widget_${widgetName}`;
3
-
4
- const getWidgetData = (
5
- el: HTMLElement,
6
- dataKey: string,
7
- ): null | SimpleWidget<unknown> => {
8
- const widget = jQuery.data(el, dataKey) as unknown;
9
-
10
- if (widget && widget instanceof SimpleWidget) {
11
- return widget;
12
- } else {
13
- return null;
14
- }
15
- };
16
-
17
- const createWidget = ($el: JQuery, options: unknown): JQuery => {
18
- const dataKey = getDataKey();
19
-
20
- for (const el of $el.get()) {
21
- const existingWidget = getWidgetData(el, dataKey);
22
-
23
- if (!existingWidget) {
24
- const simpleWidgetClass = widgetClass as typeof SimpleWidget;
25
- const widget = new simpleWidgetClass(el, options);
26
-
27
- if (!jQuery.data(el, dataKey)) {
28
- jQuery.data(el, dataKey, widget);
29
- }
30
-
31
- // Call init after setting data, so we can call methods
32
- widget.init();
33
- }
34
- }
35
-
36
- return $el;
37
- };
38
-
39
- const destroyWidget = ($el: JQuery): void => {
40
- const dataKey = getDataKey();
41
-
42
- for (const el of $el.get()) {
43
- const widget = getWidgetData(el, dataKey);
44
-
45
- if (widget) {
46
- widget.destroy();
47
- }
48
-
49
- jQuery.removeData(el, dataKey);
50
- }
51
- };
52
-
53
- const callFunction = (
54
- $el: JQuery,
55
- functionName: string,
56
- args: unknown[],
57
- ): unknown => {
58
- let result = null;
59
-
60
- for (const el of $el.get()) {
61
- const widget = jQuery.data(el, getDataKey()) as unknown;
62
-
63
- if (widget && widget instanceof SimpleWidget) {
64
- const simpleWidget = widget as SimpleWidget<unknown>;
65
- const widgetFunction = simpleWidget[functionName];
66
-
67
- if (widgetFunction && typeof widgetFunction === "function") {
68
- result = widgetFunction.apply(widget, args) as unknown;
69
- }
70
- }
71
- }
72
-
73
- return result;
74
- };
75
-
76
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
77
- (jQuery.fn as any)[widgetName] = function (
78
- this: JQuery,
79
- argument1: unknown,
80
- ...args: unknown[]
81
- ) {
82
- if (!argument1) {
83
- return createWidget(this, null);
84
- } else if (typeof argument1 === "object") {
85
- const options = argument1 as unknown;
86
- return createWidget(this, options);
87
- } else if (typeof argument1 === "string" && argument1[0] !== "_") {
88
- const functionName = argument1;
89
-
90
- if (argument1 === "destroy") {
91
- destroyWidget(this);
92
- return undefined;
93
- } else {
94
- return callFunction(this, functionName, args);
95
- }
96
- } else {
97
- return undefined;
98
- }
99
- };
100
- };
101
-
102
- export default class SimpleWidget<WidgetOptions> {
103
- [key: string]: unknown;
104
-
105
- protected static defaults: unknown = {};
106
-
107
- public $el: JQuery;
108
-
109
- public options: WidgetOptions;
110
-
111
- constructor(el: HTMLElement, options: WidgetOptions) {
112
- this.$el = jQuery(el);
113
-
114
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
115
- const defaults = (this.constructor as any).defaults as WidgetOptions;
116
- this.options = { ...defaults, ...options };
117
- }
118
-
119
- public static register(widgetClass: unknown, widgetName: string): void {
120
- register(widgetClass, widgetName);
121
- }
122
-
123
- public deinit(): void {
124
- //
125
- }
126
-
127
- public destroy(): void {
128
- this.deinit();
129
- }
130
-
131
- public init(): void {
132
- //
133
- }
134
- }