Skip to content

fix(DBLink): leading/trailing whitespace when using icons (by mitosis update) #4310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 19 additions & 9 deletions package-lock.json

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

1 change: 1 addition & 0 deletions packages/components/configs/angular/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const onClickPlugin = require('../plugins/on-click.cjs');
module.exports = {
typescript: true,
attributePassing: {
enabled: true,
customRef: '_ref'
},
api: 'signals',
Expand Down
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
},
"devDependencies": {
"@builder.io/eslint-plugin-mitosis": "0.0.17",
"@builder.io/mitosis": "0.10.0",
"@builder.io/mitosis-cli": "0.10.0",
"@builder.io/mitosis": "0.12.1",
"@builder.io/mitosis-cli": "0.12.1",
"@typescript-eslint/eslint-plugin": "8.37.0",
"cpr": "3.0.1",
"cssnano": "7.1.0",
Expand Down
25 changes: 4 additions & 21 deletions packages/components/scripts/post-build/angular.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { replaceInFileSync } from 'replace-in-file';

import { readFileSync, writeFileSync } from 'node:fs';
import { writeFileSync } from 'node:fs';

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

Expand All @@ -21,7 +21,7 @@ const setControlValueAccessorReplacements = (
replacements.push({
from: '} from "@angular/core";',
to:
`Renderer2, model } from "@angular/core";\n` +
`Renderer2 } from "@angular/core";\n` +
`import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n`
});

Expand Down Expand Up @@ -58,7 +58,7 @@ const setControlValueAccessorReplacements = (
// insert custom interface functions before ngOnInit
// TODO update attribute by config if necessary (e.g. for checked attribute?)
replacements.push({
from: 'ngOnInit()',
from: 'ngAfterViewInit()',
to: `
writeValue(value: any) {
${valueAccessorRequired ? 'if(value){' : ''}
Expand All @@ -83,7 +83,7 @@ const setControlValueAccessorReplacements = (
this.disabled.set(disabled);
}

ngOnInit()`
ngAfterViewInit()`
});
};

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

const replacements: Overwrite[] = [
// TODO: We don't need this after Angular drops support for v17 in may 2025
{
from: /allowSignalWrites: true,/g,
to: ''
}
];

if (
readFileSync(file)
.toString()
.includes('this.initialized.set(true);')
) {
// TODO: Solve this in mitosis by splitting onInit and onMount into ngOnInit and ngAfterViewInit
replacements.push({
from: 'this.initialized.set(true);',
to: ''
});
replacements.push({
from: 'ngAfterViewInit() {',
to: 'ngAfterViewInit() {\nthis.initialized.set(true);\n'
});
}

if (component.config?.angular?.controlValueAccessor) {
setControlValueAccessorReplacements(
replacements,
Expand Down
13 changes: 1 addition & 12 deletions packages/components/scripts/post-build/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,7 @@ export const getComponents = (): Component[] => [
{
from: 'attr.checked',
to: 'checked'
},
// To remove whitespaces from label...
{
from: ` <label [attr.id]="_labelId()">
{{label() ?? DEFAULT_LABEL}}
<select`,
to: `<label [attr.id]="_labelId()">{{label() ?? DEFAULT_LABEL}}<select`
},
// TODO: Move this to mitosis
{ from: 'trackByOption0', to: 'trackByOption0(i,option)' },
{ from: 'trackByOption1', to: 'trackByOption1(index,option)' },
{ from: 'trackByOption2', to: 'trackByOption2(i,option)' }
}
],
react: [
{ from: 'key={uuid()}', to: 'key={getOptionLabel(option)}' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import { DBCheckboxProps, DBCheckboxState } from './model';

useMetadata({
angular: {
nativeAttributes: ['disabled', 'required', 'checked', 'indeterminate']
nativeAttributes: ['disabled', 'required', 'checked', 'indeterminate'],
signals: {
writeable: ['disabled', 'checked']
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import {

useMetadata({
angular: {
nativeAttributes: ['disabled', 'checked', 'value', 'name']
nativeAttributes: ['disabled', 'checked', 'value', 'name'],
signals: {
writeable: ['disabled', 'checked']
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ import {

useMetadata({
angular: {
nativeAttributes: ['disabled']
nativeAttributes: ['disabled', 'required', 'multiple'],
signals: {
writeable: ['disabled', 'values']
}
}
});

Expand Down Expand Up @@ -99,6 +102,7 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
_placeholderId: undefined,
_infoTextId: undefined,
_validity: 'no-validation',
_userInteraction: false,
// 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
_descByIds: '',
_selectedLabels: '',
Expand Down Expand Up @@ -142,7 +146,9 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
state._voiceOverFallback = state._invalidMessage;
delay(() => (state._voiceOverFallback = ''), 1000);
}
state._validity = props.validation ?? 'invalid';
if (state._userInteraction) {
state._validity = props.validation ?? 'invalid';
}
} else if (
state.hasValidState() &&
selectRef?.validity.valid &&
Expand Down Expand Up @@ -422,6 +428,7 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
if (skip) return;

state._values = values;
state._userInteraction = true;
if (props.onOptionSelected) {
props.onOptionSelected(values ?? []);
}
Expand Down Expand Up @@ -688,8 +695,10 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
}, [props.values]);

onUpdate(() => {
state.handleValidation();
}, [state._values]);
if (selectRef) {
state.handleValidation();
}
}, [state._values, selectRef]);

onUpdate(() => {
state._validity = props.validation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export type DBCustomSelectDefaultState = {
_internalChangeTimestamp: number;
_documentClickListenerCallbackId?: string;
_searchValue?: string;
_userInteraction?: boolean;
getNativeSelectValue: () => string;
getOptionLabel: (option: CustomSelectOptionType) => string;
getOptionChecked: (value?: string) => boolean;
Expand Down
30 changes: 11 additions & 19 deletions packages/components/src/components/header/header.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useRef,
useStore
} from '@builder.io/mitosis';
import { DEFAULT_BURGER_MENU, DEFAULT_ID } from '../../shared/constants';
import { addAttributeToChildren, cls, getBoolean, uuid } from '../../utils';
import { DEFAULT_BURGER_MENU } from '../../shared/constants';
import { addAttributeToChildren, cls, getBoolean } from '../../utils';
import { isEventTargetNavigationItem } from '../../utils/navigation';
import DBButton from '../button/button.lite';
import DBDrawer from '../drawer/drawer.lite';
Expand All @@ -22,7 +22,6 @@ export default function DBHeader(props: DBHeaderProps) {
const _ref = useRef<HTMLDivElement | any>(null);
// jscpd:ignore-start
const state = useStore<DBHeaderState>({
_id: DEFAULT_ID,
initialized: false,
forcedToMobile: false,
handleToggle: (event?: any) => {
Expand All @@ -45,33 +44,27 @@ export default function DBHeader(props: DBHeaderProps) {

onMount(() => {
state.initialized = true;
state._id = props.id || 'header-' + uuid();
});

onUpdate(() => {
if (state.initialized && document && state._id && props.forceMobile) {
const headerElement = document.getElementById(
state._id ?? ''
) as HTMLElement;
if (headerElement) {
// Adds this attribute to the header to enable all styling which would have
// @media screen and (min-width: $db-screens-m) to show mobile navigation on a desktop device
addAttributeToChildren(headerElement, {
key: 'data-force-mobile',
value: 'true'
});
}
if (state.initialized && _ref && props.forceMobile) {
// Adds this attribute to the header to enable all styling which would have
// @media screen and (min-width: $db-screens-m) to show mobile navigation on a desktop device
addAttributeToChildren(_ref, {
key: 'data-force-mobile',
value: 'true'
});
state.forcedToMobile = true;
}
}, [state.initialized]);
}, [state.initialized, _ref]);

// jscpd:ignore-end

return (
<header
ref={_ref}
class={cls('db-header', props.className)}
id={state._id}
id={props.id}
data-width={props.width}
data-on-forcing-mobile={props.forceMobile && !state.forcedToMobile}>
<DBDrawer
Expand Down Expand Up @@ -113,7 +106,6 @@ export default function DBHeader(props: DBHeaderProps) {
<div class="db-header-action-container">
<div class="db-header-burger-menu-container">
<DBButton
id={state._id + '-burger-menu'}
icon="menu"
noText
variant="ghost"
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/components/input/input.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ import { DBInputProps, DBInputState } from './model';

useMetadata({
angular: {
nativeAttributes: ['disabled', 'required']
nativeAttributes: ['disabled', 'required'],
signals: {
writeable: ['disabled', 'value']
}
}
});

Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/components/radio/radio.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { DBRadioProps, DBRadioState } from './model';

useMetadata({
angular: {
nativeAttributes: ['disabled', 'required', 'checked', 'indeterminate']
nativeAttributes: ['disabled', 'required', 'checked', 'indeterminate'],
signals: {
writeable: ['disabled', 'value']
}
}
});
useDefaultProps<DBRadioProps>({});
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/components/select/select.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ import { DBSelectOptionType, DBSelectProps, DBSelectState } from './model';

useMetadata({
angular: {
nativeAttributes: ['disabled', 'required', 'value']
nativeAttributes: ['disabled', 'required', 'value'],
signals: {
writeable: ['disabled', 'value']
}
}
});
useDefaultProps<DBSelectProps>({});
Expand Down
Loading
Loading