Skip to content

Commit

Permalink
chore: CRUD 调整方便外围覆盖
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Dec 18, 2024
1 parent 856539e commit 09caa0c
Show file tree
Hide file tree
Showing 10 changed files with 513 additions and 108 deletions.
381 changes: 373 additions & 8 deletions docs/zh-CN/components/crud.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/amis-core/src/RootRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ export class RootRenderer extends React.Component<RootRendererProps> {
);
});
} else if (action.actionType === 'toast') {
action.toast?.items?.forEach((item: any) => {
action.toast?.items?.forEach(({level, body, title, ...item}: any) => {
env.notify(
item.level || 'info',
item.body
? render('body', item.body, {
level || 'info',
body
? render('body', body, {
...this.props,
data: ctx,
context: store.context
Expand All @@ -247,8 +247,8 @@ export class RootRenderer extends React.Component<RootRendererProps> {
{
...action.toast,
...item,
title: item.title
? render('title', item.title, {
title: title
? render('title', title, {
...this.props,
data: ctx,
context: store.context
Expand Down
13 changes: 7 additions & 6 deletions packages/amis-ui/scss/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@
line-height: calc(
var(--Form-input-lineHeight) * var(--Form-input-fontSize) - #{px2rem(2px)}
);
display: inline-block;
display: inline-flex;
align-items: center;
font-size: var(--Pick-base-value-fontSize);
color: var(--Pick-base-value-color);
font-weight: var(--Pick-base-value-fontWeight);
Expand All @@ -682,9 +683,6 @@
var(--Pick-base-top-right-border-radius)
var(--Pick-base-bottom-right-border-radius)
var(--Pick-base-bottom-left-border-radius);
margin-right: var(--gap-xs);
margin-bottom: var(--gap-xs);
margin-top: var(--gap-xs);
max-width: px2rem(150px);
overflow: hidden;
text-overflow: ellipsis;
Expand All @@ -696,15 +694,18 @@

&.is-disabled {
pointer-events: none;
opacity: var(--Button-onDisabled-opacity);

.#{$ns}#{$component-prefix}-valueIcon {
opacity: var(--Button-onDisabled-opacity);
}
}
}

.#{$ns}#{$component-prefix}-valueIcon {
color: var(--Pick-base-value-icon-color);
cursor: pointer;
border-right: px2rem(1px) solid var(--Form-selectValue-borderColor);
padding: 1px 5px;
padding: 0 5px;

&:hover {
background: var(--Pick-base-value-hover-icon-color);
Expand Down
1 change: 1 addition & 0 deletions packages/amis-ui/scss/_properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ $Table-strip-bg: transparent;
--ButtonGroup-divider-width: #{px2rem(1px)};
--ButtonGroup-divider-color: #fff;
--ButtonGroup-borderWidth: var(--borders-width-2);
--Button-onDisabled-opacity: 0.3;

--Breadcrumb-item-fontSize: var(--fontSizeMd);
--Breadcrumb-item-default-color: var(--colors-neutral-text-5);
Expand Down
5 changes: 5 additions & 0 deletions packages/amis-ui/scss/components/_crud.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

&-selection {
margin-bottom: var(--gap-base);
display: flex;
flex-wrap: wrap;
gap: var(--gap-xs);
line-height: 1;

&-overflow {
&-wrapper {
Expand All @@ -25,6 +29,7 @@
(var(--Picker-tag-height) + var(--Picker-tag-marginBottom)) * 5
);

gap: var(--gap-xs);
@include tag-item(Crud);
}
}
Expand Down
25 changes: 14 additions & 11 deletions packages/amis-ui/scss/components/form/_picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
font-size: var(--Pick-base-placeholder-fontSize);
font-weight: var(--Pick-base-placeholder-fontWeight);
user-select: none;
position: absolute;
flex: 1;
min-width: 0;
// margin-top: 2 * var(--Form-input-borderWidth);
line-height: var(--Form-input-lineHeight);
padding: var(--Pick-base-paddingTop) var(--Pick-base-paddingRight)
Expand All @@ -95,15 +96,15 @@
var(--Pick-base-left-border-color);
}

.#{$ns}Picker-values {
display: inline;
// .#{$ns}Picker-values {
// display: inline;

.#{$ns}OverflowTpl {
.#{$ns}Picker-valueLabel {
pointer-events: auto;
}
}
}
// .#{$ns}OverflowTpl {
// .#{$ns}Picker-valueLabel {
// pointer-events: auto;
// }
// }
// }

&-valueWrap {
flex-grow: 1;
Expand All @@ -117,8 +118,9 @@
}

.#{$ns}Picker-valueWrap {
margin-bottom: calc(var(--gap-xs) * -1);
line-height: 1;
display: flex;
flex-wrap: wrap;
gap: var(--gap-xs);
}

/* tag 样式 */
Expand Down Expand Up @@ -176,6 +178,7 @@
(var(--Picker-tag-height) + var(--Picker-tag-marginBottom)) * 5
);

gap: var(--gap-xs);
@include tag-item(Picker);
}
}
Expand Down
8 changes: 5 additions & 3 deletions packages/amis/__tests__/renderers/Picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,15 @@ describe('5. Renderer:Picker with overflowConfig', () => {

await wait(500);

const tags = container.querySelector('.cxd-Picker-values');
const tags = container.querySelector('.cxd-Picker-valueWrap');

expect(tags).toBeInTheDocument();
/** tag 元素数量正确 */
expect(tags?.childElementCount).toEqual(3);
expect(tags?.childElementCount).toEqual(4); // 还有个 input
/** 收纳标签文案正确 */
expect(tags?.lastElementChild).toHaveTextContent('+ 1 ...');
expect(tags?.lastElementChild?.previousSibling).toHaveTextContent(
'+ 1 ...'
);
});

test('5-2. Renderer:Picker embeded', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ exports[`1. Renderer:Picker base 1`] = `
>
picker-placeholder
</div>
<div
class="cxd-Picker-valueWrap"
>
<div
class="cxd-Picker-values"
/>
<input
value=""
/>
</div>
<span
class="cxd-Picker-btn"
>
Expand Down Expand Up @@ -267,22 +257,18 @@ exports[`1. Renderer:Picker base 2`] = `
class="cxd-Picker-valueWrap"
>
<div
class="cxd-Picker-values"
class="cxd-OverflowTpl cxd-Picker-value"
>
<div
class="cxd-OverflowTpl cxd-Picker-value"
<span
class="cxd-Picker-valueIcon"
>
<span
class="cxd-Picker-valueIcon"
>
×
</span>
<span
class="cxd-Picker-valueLabel"
>
B
</span>
</div>
×
</span>
<span
class="cxd-Picker-valueLabel"
>
B
</span>
</div>
<input
value=""
Expand Down
Loading

0 comments on commit 09caa0c

Please sign in to comment.