Skip to content

Commit 13cf340

Browse files
fix: mitosis update (#4310)
* chore(deps-dev): bump the builder-io group with 2 updates Bumps the builder-io group with 2 updates: [@builder.io/mitosis](https://github.com/BuilderIO/mitosis) and [@builder.io/mitosis-cli](https://github.com/BuilderIO/mitosis). Updates `@builder.io/mitosis` from 0.9.2 to 0.11.0 - [Release notes](https://github.com/BuilderIO/mitosis/releases) - [Commits](https://github.com/BuilderIO/mitosis/compare/@builder.io/[email protected][email protected]/[email protected]) Updates `@builder.io/mitosis-cli` from 0.9.2 to 0.11.0 - [Release notes](https://github.com/BuilderIO/mitosis/releases) - [Commits](https://github.com/BuilderIO/mitosis/compare/@builder.io/[email protected][email protected]/[email protected]) --- updated-dependencies: - dependency-name: "@builder.io/mitosis" dependency-version: 0.11.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: builder-io - dependency-name: "@builder.io/mitosis-cli" dependency-version: 0.11.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: builder-io ... Signed-off-by: dependabot[bot] <[email protected]> * fix: issues from mitosis update * chore: update mitosis --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 61ee85c commit 13cf340

File tree

17 files changed

+84
-75
lines changed

17 files changed

+84
-75
lines changed
Loading

package-lock.json

Lines changed: 19 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/configs/angular/index.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const onClickPlugin = require('../plugins/on-click.cjs');
66
module.exports = {
77
typescript: true,
88
attributePassing: {
9+
enabled: true,
910
customRef: '_ref'
1011
},
1112
api: 'signals',

packages/components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
},
4747
"devDependencies": {
4848
"@builder.io/eslint-plugin-mitosis": "0.0.17",
49-
"@builder.io/mitosis": "0.10.0",
50-
"@builder.io/mitosis-cli": "0.10.0",
49+
"@builder.io/mitosis": "0.12.1",
50+
"@builder.io/mitosis-cli": "0.12.1",
5151
"@typescript-eslint/eslint-plugin": "8.37.0",
5252
"cpr": "3.0.1",
5353
"cssnano": "7.1.0",

packages/components/scripts/post-build/angular.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { replaceInFileSync } from 'replace-in-file';
22

3-
import { readFileSync, writeFileSync } from 'node:fs';
3+
import { writeFileSync } from 'node:fs';
44

55
import components, { Overwrite } from './components.js';
66

@@ -21,7 +21,7 @@ const setControlValueAccessorReplacements = (
2121
replacements.push({
2222
from: '} from "@angular/core";',
2323
to:
24-
`Renderer2, model } from "@angular/core";\n` +
24+
`Renderer2 } from "@angular/core";\n` +
2525
`import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n`
2626
});
2727

@@ -58,7 +58,7 @@ const setControlValueAccessorReplacements = (
5858
// insert custom interface functions before ngOnInit
5959
// TODO update attribute by config if necessary (e.g. for checked attribute?)
6060
replacements.push({
61-
from: 'ngOnInit()',
61+
from: 'ngAfterViewInit()',
6262
to: `
6363
writeValue(value: any) {
6464
${valueAccessorRequired ? 'if(value){' : ''}
@@ -83,7 +83,7 @@ const setControlValueAccessorReplacements = (
8383
this.disabled.set(disabled);
8484
}
8585
86-
ngOnInit()`
86+
ngAfterViewInit()`
8787
});
8888
};
8989

@@ -169,29 +169,12 @@ export default (tmp?: boolean) => {
169169
});
170170

171171
const replacements: Overwrite[] = [
172-
// TODO: We don't need this after Angular drops support for v17 in may 2025
173172
{
174173
from: /allowSignalWrites: true,/g,
175174
to: ''
176175
}
177176
];
178177

179-
if (
180-
readFileSync(file)
181-
.toString()
182-
.includes('this.initialized.set(true);')
183-
) {
184-
// TODO: Solve this in mitosis by splitting onInit and onMount into ngOnInit and ngAfterViewInit
185-
replacements.push({
186-
from: 'this.initialized.set(true);',
187-
to: ''
188-
});
189-
replacements.push({
190-
from: 'ngAfterViewInit() {',
191-
to: 'ngAfterViewInit() {\nthis.initialized.set(true);\n'
192-
});
193-
}
194-
195178
if (component.config?.angular?.controlValueAccessor) {
196179
setControlValueAccessorReplacements(
197180
replacements,

packages/components/scripts/post-build/components.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,7 @@ export const getComponents = (): Component[] => [
7575
{
7676
from: 'attr.checked',
7777
to: 'checked'
78-
},
79-
// To remove whitespaces from label...
80-
{
81-
from: ` <label [attr.id]="_labelId()">
82-
{{label() ?? DEFAULT_LABEL}}
83-
<select`,
84-
to: `<label [attr.id]="_labelId()">{{label() ?? DEFAULT_LABEL}}<select`
85-
},
86-
// TODO: Move this to mitosis
87-
{ from: 'trackByOption0', to: 'trackByOption0(i,option)' },
88-
{ from: 'trackByOption1', to: 'trackByOption1(index,option)' },
89-
{ from: 'trackByOption2', to: 'trackByOption2(i,option)' }
78+
}
9079
],
9180
react: [
9281
{ from: 'key={uuid()}', to: 'key={getOptionLabel(option)}' }

packages/components/src/components/checkbox/checkbox.lite.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ import { DBCheckboxProps, DBCheckboxState } from './model';
3434

3535
useMetadata({
3636
angular: {
37-
nativeAttributes: ['disabled', 'required', 'checked', 'indeterminate']
37+
nativeAttributes: ['disabled', 'required', 'checked', 'indeterminate'],
38+
signals: {
39+
writeable: ['disabled', 'checked']
40+
}
3841
}
3942
});
4043

packages/components/src/components/custom-select-list-item/custom-select-list-item.lite.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import {
2121

2222
useMetadata({
2323
angular: {
24-
nativeAttributes: ['disabled', 'checked', 'value', 'name']
24+
nativeAttributes: ['disabled', 'checked', 'value', 'name'],
25+
signals: {
26+
writeable: ['disabled', 'checked']
27+
}
2528
}
2629
});
2730

packages/components/src/components/custom-select/custom-select.lite.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ import {
6767

6868
useMetadata({
6969
angular: {
70-
nativeAttributes: ['disabled']
70+
nativeAttributes: ['disabled', 'required', 'multiple'],
71+
signals: {
72+
writeable: ['disabled', 'values']
73+
}
7174
}
7275
});
7376

@@ -99,6 +102,7 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
99102
_placeholderId: undefined,
100103
_infoTextId: undefined,
101104
_validity: 'no-validation',
105+
_userInteraction: false,
102106
// Workaround for Vue output: TS for Vue would think that it could be a function, and by this we clarify that it's a string
103107
_descByIds: '',
104108
_selectedLabels: '',
@@ -142,7 +146,9 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
142146
state._voiceOverFallback = state._invalidMessage;
143147
delay(() => (state._voiceOverFallback = ''), 1000);
144148
}
145-
state._validity = props.validation ?? 'invalid';
149+
if (state._userInteraction) {
150+
state._validity = props.validation ?? 'invalid';
151+
}
146152
} else if (
147153
state.hasValidState() &&
148154
selectRef?.validity.valid &&
@@ -422,6 +428,7 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
422428
if (skip) return;
423429

424430
state._values = values;
431+
state._userInteraction = true;
425432
if (props.onOptionSelected) {
426433
props.onOptionSelected(values ?? []);
427434
}
@@ -688,8 +695,10 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
688695
}, [props.values]);
689696

690697
onUpdate(() => {
691-
state.handleValidation();
692-
}, [state._values]);
698+
if (selectRef) {
699+
state.handleValidation();
700+
}
701+
}, [state._values, selectRef]);
693702

694703
onUpdate(() => {
695704
state._validity = props.validation;

packages/components/src/components/custom-select/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export type DBCustomSelectDefaultState = {
261261
_internalChangeTimestamp: number;
262262
_documentClickListenerCallbackId?: string;
263263
_searchValue?: string;
264+
_userInteraction?: boolean;
264265
getNativeSelectValue: () => string;
265266
getOptionLabel: (option: CustomSelectOptionType) => string;
266267
getOptionChecked: (value?: string) => boolean;

0 commit comments

Comments
 (0)