Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f24fb4

Browse files
committed
Merge branch '2.x' into 3.x
* 2.x: [Toolkit][Shadcn] Fix initial "open" state for AlertDialog and Dialog Remove unused @vitest/browser Update Vitest to ^4.1.0 [TwigComponent] Fix profiler loaded in production due to unresolved %kernel.debug% default [LiveComponent] Add `debug:live-component` command Fix email input class binding for validation errors (Shadcn] Fix Tooltip's wrapper when re-rendered by LiveComponent Allow components use dynamically templates fix properly apply inline styles with important priority Migrate from tsup (deprecated) to tsdown Remove tsx dependency and rely on Node.js 22.18.0 native TypeScript runner Fix unit testing script Update JavaScript dependencies
2 parents 70bc83b + 650cb24 commit 0f24fb4

9 files changed

Lines changed: 114 additions & 126 deletions

assets/dist/components.d.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { FunctionComponent, ComponentClass } from 'react';
2-
1+
import { ComponentClass, FunctionComponent } from "react";
32
type Component = string | FunctionComponent<object> | ComponentClass<object, any>;
43
interface ComponentCollection {
5-
[key: string]: Component;
4+
[key: string]: Component;
65
}
76
declare const components: ComponentCollection;
8-
9-
export { type ComponentCollection, components };
7+
export { ComponentCollection, components };

assets/dist/components.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
const components = {};
2-
export {
3-
components
4-
};
2+
export { components };

assets/dist/loader.d.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { FunctionComponent, ComponentClass } from 'react';
2-
import { ComponentCollection } from './components.js';
3-
1+
import { ComponentCollection } from "./components.js";
2+
import { ComponentClass, FunctionComponent } from "react";
43
type Component = string | FunctionComponent<object> | ComponentClass<object, any>;
54
declare global {
6-
function resolveReactComponent(name: string): Component;
7-
interface Window {
8-
resolveReactComponent(name: string): Component;
9-
}
5+
function resolveReactComponent(name: string): Component;
6+
interface Window {
7+
resolveReactComponent(name: string): Component;
8+
}
109
}
1110
declare function registerReactControllerComponents(reactComponents?: ComponentCollection): void;
12-
13-
export { registerReactControllerComponents };
11+
export { registerReactControllerComponents };

assets/dist/loader.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { components } from "./components.js";
22
function registerReactControllerComponents(reactComponents = components) {
3-
window.resolveReactComponent = (name) => {
4-
const component = reactComponents[name];
5-
if (typeof component === "undefined") {
6-
const possibleValues = Object.keys(reactComponents).length > 0 ? Object.keys(reactComponents).join(", ") : "none";
7-
throw new Error(`React controller "${name}" does not exist. Possible values: ${possibleValues}`);
8-
}
9-
return component;
10-
};
3+
window.resolveReactComponent = (name) => {
4+
const component = reactComponents[name];
5+
if (typeof component === "undefined") {
6+
const possibleValues = Object.keys(reactComponents).length > 0 ? Object.keys(reactComponents).join(", ") : "none";
7+
throw new Error(`React controller "${name}" does not exist. Possible values: ${possibleValues}`);
8+
}
9+
return component;
10+
};
1111
}
12-
export {
13-
registerReactControllerComponents
14-
};
12+
export { registerReactControllerComponents };
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { FunctionComponent, ComponentClass } from 'react';
2-
1+
import { ComponentClass, FunctionComponent } from "react";
32
type Component = string | FunctionComponent<object> | ComponentClass<object, any>;
43
declare global {
5-
function resolveReactComponent(name: string): Component;
6-
interface Window {
7-
resolveReactComponent(name: string): Component;
8-
}
4+
function resolveReactComponent(name: string): Component;
5+
interface Window {
6+
resolveReactComponent(name: string): Component;
7+
}
98
}
109
declare function registerReactControllerComponents(context: __WebpackModuleApi.RequireContext): void;
11-
12-
export { registerReactControllerComponents };
10+
export { registerReactControllerComponents };

assets/dist/register_controller.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
function registerReactControllerComponents(context) {
2-
const reactControllers = {};
3-
const importAllReactComponents = (r) => {
4-
r.keys().forEach((key) => {
5-
reactControllers[key] = r(key).default;
6-
});
7-
};
8-
importAllReactComponents(context);
9-
window.resolveReactComponent = (name) => {
10-
const component = reactControllers[`./${name}.jsx`] || reactControllers[`./${name}.tsx`];
11-
if (typeof component === "undefined") {
12-
const possibleValues = Object.keys(reactControllers).map(
13-
(key) => key.replace("./", "").replace(".jsx", "").replace(".tsx", "")
14-
);
15-
if (possibleValues.includes(name)) {
16-
throw new Error(`
2+
const reactControllers = {};
3+
const importAllReactComponents = (r) => {
4+
r.keys().forEach((key) => {
5+
reactControllers[key] = r(key).default;
6+
});
7+
};
8+
importAllReactComponents(context);
9+
window.resolveReactComponent = (name) => {
10+
const component = reactControllers[`./${name}.jsx`] || reactControllers[`./${name}.tsx`];
11+
if (typeof component === "undefined") {
12+
const possibleValues = Object.keys(reactControllers).map((key) => key.replace("./", "").replace(".jsx", "").replace(".tsx", ""));
13+
if (possibleValues.includes(name)) throw new Error(`
1714
React controller "${name}" could not be resolved. Ensure the module exports the controller as a default export.`);
18-
}
19-
throw new Error(`React controller "${name}" does not exist. Possible values: ${possibleValues.join(", ")}`);
20-
}
21-
return component;
22-
};
15+
throw new Error(`React controller "${name}" does not exist. Possible values: ${possibleValues.join(", ")}`);
16+
}
17+
return component;
18+
};
2319
}
24-
export {
25-
registerReactControllerComponents
26-
};
20+
export { registerReactControllerComponents };

assets/dist/render_controller.d.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import { Controller } from '@hotwired/stimulus';
2-
import { ReactElement } from 'react';
3-
1+
import { Controller } from "@hotwired/stimulus";
2+
import { ReactElement } from "react";
43
declare class export_default extends Controller {
5-
readonly componentValue?: string;
6-
readonly propsValue?: object;
7-
readonly permanentValue: boolean;
8-
static values: {
9-
component: StringConstructor;
10-
props: ObjectConstructor;
11-
permanent: {
12-
type: BooleanConstructor;
13-
default: boolean;
14-
};
4+
readonly componentValue?: string;
5+
readonly propsValue?: object;
6+
readonly permanentValue: boolean;
7+
static values: {
8+
component: StringConstructor;
9+
props: ObjectConstructor;
10+
permanent: {
11+
type: BooleanConstructor;
12+
default: boolean;
1513
};
16-
connect(): void;
17-
disconnect(): void;
18-
_renderReactElement(reactElement: ReactElement): void;
19-
private dispatchEvent;
14+
};
15+
connect(): void;
16+
disconnect(): void;
17+
_renderReactElement(reactElement: ReactElement): void;
18+
private dispatchEvent;
2019
}
21-
22-
export { export_default as default };
20+
export { export_default as default };

assets/dist/render_controller.js

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
11
import { Controller } from "@hotwired/stimulus";
22
import React from "react";
33
import { createRoot } from "react-dom/client";
4-
class render_controller_default extends Controller {
5-
connect() {
6-
const props = this.propsValue ? this.propsValue : null;
7-
this.dispatchEvent("connect", { component: this.componentValue, props });
8-
if (!this.componentValue) {
9-
throw new Error("No component specified.");
10-
}
11-
const component = window.resolveReactComponent(this.componentValue);
12-
this._renderReactElement(React.createElement(component, props, null));
13-
this.dispatchEvent("mount", {
14-
componentName: this.componentValue,
15-
component,
16-
props
17-
});
18-
}
19-
disconnect() {
20-
if (this.permanentValue) {
21-
return;
22-
}
23-
this.element.root.unmount();
24-
this.dispatchEvent("unmount", {
25-
component: this.componentValue,
26-
props: this.propsValue ? this.propsValue : null
27-
});
28-
}
29-
_renderReactElement(reactElement) {
30-
const element = this.element;
31-
if (!element.root) {
32-
element.root = createRoot(this.element);
33-
}
34-
element.root.render(reactElement);
35-
}
36-
dispatchEvent(name, payload) {
37-
this.dispatch(name, { detail: payload, prefix: "react" });
38-
}
39-
}
40-
render_controller_default.values = {
41-
component: String,
42-
props: Object,
43-
permanent: { type: Boolean, default: false }
4+
var _Class = class extends Controller {
5+
connect() {
6+
const props = this.propsValue ? this.propsValue : null;
7+
this.dispatchEvent("connect", {
8+
component: this.componentValue,
9+
props
10+
});
11+
if (!this.componentValue) throw new Error("No component specified.");
12+
const component = window.resolveReactComponent(this.componentValue);
13+
this._renderReactElement(React.createElement(component, props, null));
14+
this.dispatchEvent("mount", {
15+
componentName: this.componentValue,
16+
component,
17+
props
18+
});
19+
}
20+
disconnect() {
21+
if (this.permanentValue) return;
22+
this.element.root.unmount();
23+
this.dispatchEvent("unmount", {
24+
component: this.componentValue,
25+
props: this.propsValue ? this.propsValue : null
26+
});
27+
}
28+
_renderReactElement(reactElement) {
29+
const element = this.element;
30+
if (!element.root) element.root = createRoot(this.element);
31+
element.root.render(reactElement);
32+
}
33+
dispatchEvent(name, payload) {
34+
this.dispatch(name, {
35+
detail: payload,
36+
prefix: "react"
37+
});
38+
}
4439
};
45-
export {
46-
render_controller_default as default
40+
_Class.values = {
41+
component: String,
42+
props: Object,
43+
permanent: {
44+
type: Boolean,
45+
default: false
46+
}
4747
};
48+
export { _Class as default };

assets/package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@
1717
"config": {
1818
"tests": {
1919
"peerDependencyVersions": [
20-
{ "react": "^18.0", "react-dom": "^18.0" },
21-
{ "react": "^19.0", "react-dom": "^19.0" }
20+
{
21+
"react": "^18.0",
22+
"react-dom": "^18.0"
23+
},
24+
{
25+
"react": "^19.0",
26+
"react-dom": "^19.0"
27+
}
2228
]
2329
}
2430
},
2531
"scripts": {
26-
"build": "tsx ../../../bin/build_package.ts .",
27-
"watch": "tsx ../../../bin/build_package.ts . --watch",
32+
"build": "node ../../../bin/build_package.ts .",
33+
"watch": "node ../../../bin/build_package.ts . --watch",
2834
"test": "pnpm run test:unit && pnpm run test:browser",
2935
"test:unit": "../../../bin/unit_test_package.sh .",
3036
"test:browser": "playwright test",
@@ -64,8 +70,7 @@
6470
"react": "^18.0",
6571
"react-dom": "^18.0",
6672
"tslib": "^2.8.1",
67-
"tsx": "^4.20.3",
6873
"typescript": "^5.8.3",
69-
"vitest": "^3.2.4"
74+
"vitest": "^4.1.0"
7075
}
7176
}

0 commit comments

Comments
 (0)