Skip to content

Commit

Permalink
refactor: drop lit/react in favor of React built-in support
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Dec 24, 2024
1 parent 97a3f5e commit 91d8250
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 104 deletions.
2 changes: 1 addition & 1 deletion dev/kitchen-sink/Row1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Row1() {
<div>Accordion content 2</div>
</AccordionPanel>
</Accordion>
<AvatarGroup prefix="Users: " items={[{ name: 'Jane Roe', abbr: 'JD' }]}></AvatarGroup>
<AvatarGroup items={[{ name: 'Jane Roe', abbr: 'JD' }]}></AvatarGroup>
<Chart title="Chart" style={{ height: '300px' }}>
<ChartSeries title="Items" type="bar" values={[10, 20, 30]}></ChartSeries>
</Chart>
Expand Down
17 changes: 17 additions & 0 deletions dev/pages/Select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Select } from '../../packages/react-components/src/Select.js';

export default function () {
return (
<>
<Select
opened
items={[
{ value: '1', label: 'Option 1' },
{ value: '2', label: 'Option 2' },
{ value: '3', label: 'Option 3' },
]}
onValueChanged={(e) => console.log(e.detail)}
></Select>
</>
);
}
82 changes: 28 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@types/karma-chrome-launcher": "^3.1.4",
"@types/karma-mocha": "^1.3.4",
"@types/mocha": "^10.0.10",
"@types/react-dom": "^18.3.3",
"@types/react-dom": "^19",
"@types/sinon": "^17.0.3",
"@vitejs/plugin-react": "^4.3.4",
"chai-as-promised": "^8.0.1",
Expand Down
9 changes: 4 additions & 5 deletions packages/react-components-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"version": "tsx ../../scripts/package-json-version.ts"
},
"dependencies": {
"@lit/react": "^1.0.6",
"@vaadin/board": "24.7.0-alpha2",
"@vaadin/charts": "24.7.0-alpha2",
"@vaadin/cookie-consent": "24.7.0-alpha2",
Expand All @@ -39,10 +38,10 @@
"author": "Vaadin Ltd.",
"license": "SEE LICENSE IN LICENSE",
"peerDependencies": {
"@types/react": "^18.2.37 || ^19",
"@types/react-dom": "^18.2.15 || ^19",
"react": "^18.2.0 || ^19",
"react-dom": "^18.2.0 || ^19"
"@types/react": "^19",
"@types/react-dom": "^19",
"react": "^19",
"react-dom": "^19"
},
"peerDependenciesMeta": {
"@types/react": {
Expand Down
13 changes: 8 additions & 5 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"version": "tsx ../../scripts/package-json-version.ts"
},
"dependencies": {
"@lit/react": "^1.0.6",
"@vaadin/a11y-base": "24.7.0-alpha2",
"@vaadin/accordion": "24.7.0-alpha2",
"@vaadin/app-layout": "24.7.0-alpha2",
Expand Down Expand Up @@ -90,10 +89,10 @@
"author": "Vaadin Ltd.",
"license": "Apache-2.0",
"peerDependencies": {
"@types/react": "^18.2.37 || ^19",
"@types/react-dom": "^18.2.15 || ^19",
"react": "^18.2.0 || ^19",
"react-dom": "^18.2.0 || ^19"
"@types/react": "^19",
"@types/react-dom": "^19",
"react": "^19",
"react-dom": "^19"
},
"peerDependenciesMeta": {
"@types/react": {
Expand Down Expand Up @@ -501,6 +500,10 @@
"./utils/createComponentWithOrderedProps.d.ts.map": "./utils/createComponentWithOrderedProps.d.ts.map",
"./utils/createComponentWithOrderedProps.js": "./utils/createComponentWithOrderedProps.js",
"./utils/createComponentWithOrderedProps.js.map": "./utils/createComponentWithOrderedProps.js.map",
"./utils/flushInMicrotask.d.ts": "./utils/flushInMicrotask.d.ts",
"./utils/flushInMicrotask.d.ts.map": "./utils/flushInMicrotask.d.ts.map",
"./utils/flushInMicrotask.js": "./utils/flushInMicrotask.js",
"./utils/flushInMicrotask.js.map": "./utils/flushInMicrotask.js.map",
"./utils/flushMicrotask.d.ts": "./utils/flushMicrotask.d.ts",
"./utils/flushMicrotask.d.ts.map": "./utils/flushMicrotask.d.ts.map",
"./utils/flushMicrotask.js": "./utils/flushMicrotask.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-components/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
type ComponentType,
type ForwardedRef,
forwardRef,
type HTMLAttributes,
isValidElement,
type ReactElement,
type ReactNode,
Expand Down Expand Up @@ -31,7 +32,7 @@ function Select(props: SelectProps, ref: ForwardedRef<SelectElement>): ReactElem

// Components with slot attribute should stay in light DOM.
const slottedChildren = children.filter((child): child is ReactNode => {
return isValidElement(child) && child.props.slot;
return isValidElement<HTMLAttributes<unknown>>(child) && !!child.props.slot;
});

// Component without slot attribute should go to the overlay.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/src/renderers/useRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function useRenderer<P extends {}, W extends WebComponentRenderer>(
convert?: (props: Slice<Parameters<W>, 1>) => PropsWithChildren<P>,
config?: RendererConfig<W>,
): UseRendererResult<W> {
const [map, update] = useReducer<typeof rendererReducer<W>>(rendererReducer, initialState);
const [map, update] = useReducer(rendererReducer, initialState);
const renderer = useCallback(
((...args: Parameters<W>) => {
if (config?.renderMode === 'microtask') {
Expand Down
Loading

0 comments on commit 91d8250

Please sign in to comment.