Skip to content

Commit 1c79de2

Browse files
authored
Refactor the entire implementation of the ch-action-group-render components and ch-dropdown-render and rename the dropdown component to action-menu (#477)
* Backup dropdown refactoring * Partial refactor ch-dropdown-render's implementation - Added support for Shadow DOM. - Reduced the memory consumption. - Implemented event delegation. - Fixed performance issues. * Backup refactoring for ch-dropdown-render * Fix issue provoked by refactoring * Add support to close the dropdown on escape key * Disable action button with disable property * Update models.ts * Add support for keyboard actions * Use button-reset mixin * Add comments * Remove old styles * Remove WA as the ch-popover is no longer rendered if the item is not expanded * Add support to render slots and separator * Update showcase * Improve keyboard navigation * Add support for buttonClick and hyperlinkClick events * Update dropdown.showcase.tsx * Update models.ts * Rename values for the itemsOverflowBehavior prop * Backup refactoring * Backup refactoring * Add a Symbol for adding metadata to UI models * Simplify dropdown implementation by the Symbol * Backup action-group new implementation * Use utility function * Fix dropdown not working with undefined model * Improve action-group implementation * Update showcase * Add missing commit * Add support for getImagePathCallback and registerProperty * Add parts for the separator * Update showcase * Improve default styles * Split bundles * Rename "dropdown" to "action-menu" * Optimize bundles * Improve action-group responsiveness * Improve accessibility * Rename custom vars * Update showcase * Export React wrapper for the action-menu-render component * Update showcase-flexible-layout.css * Update readmes * Remove ch-action-group-item and ch-action-group components * Improve docs * Fix breaking changes * Remove unnecessary overflow: hidden * Update showcase-flexible-layout.css * Improve action-menu showcase * Improve default value * Add basic unit tests * Update readmes * Rename "part" member to "parts" * Remove commented code
1 parent 2ea532c commit 1c79de2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2945
-3067
lines changed

src/common/reserved-names.ts

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { ImageRender } from "./types";
22

3+
/**
4+
* This Symbol allow us to add metadata to UI models, without making it
5+
* available to the UI model host.
6+
*
7+
* Additionally, object entries that are Symbols are not serialize
8+
* (JSON.stringify), which is perfect for further hiding even more this
9+
* metadata that must be internal to each component's implementation.
10+
*/
11+
export const MODEL_METADATA = Symbol("metadata");
12+
313
const joinParts = (parts: { [key in string]: string }) =>
414
Object.values(parts).join(",");
515

@@ -115,6 +125,23 @@ export const ACCORDION_EXPORT_PARTS = joinParts(ACCORDION_PARTS_DICTIONARY);
115125
// - - - - - - - - - - - - - - - - - - - -
116126
// Action Group Parts
117127
// - - - - - - - - - - - - - - - - - - - -
128+
export const ACTION_GROUP_PARTS_DICTIONARY = {
129+
ACTIONS: "actions",
130+
MORE_ACTIONS: "more-actions",
131+
MORE_ACTIONS_BUTTON: "more-actions-button",
132+
MORE_ACTIONS_WINDOW: "more-actions-window",
133+
134+
// - - - - - - - - States - - - - - - - -
135+
VERTICAL: "vertical" // SEPARATOR (comes from dropdown dictionary)
136+
} as const;
137+
138+
export const ACTION_GROUP_EXPORT_PARTS = joinParts(
139+
ACTION_GROUP_PARTS_DICTIONARY
140+
);
141+
142+
// - - - - - - - - - - - - - - - - - - - -
143+
// Action List Parts
144+
// - - - - - - - - - - - - - - - - - - - -
118145
export const ACTION_LIST_ITEM_PARTS_DICTIONARY = {
119146
ACTION: "item__action",
120147
ADDITIONAL_ITEM: "item__additional-item",
@@ -216,18 +243,32 @@ export const ACTION_LIST_EXPORT_PARTS = joinParts(
216243
);
217244

218245
// - - - - - - - - - - - - - - - - - - - -
219-
// Action Group Parts
246+
// Action Menu Parts
220247
// - - - - - - - - - - - - - - - - - - - -
221-
export const ACTION_GROUP_PARTS_DICTIONARY = {
222-
ACTIONS: "actions",
223-
MORE_ACTIONS: "more-actions",
224-
MORE_ACTIONS_BUTTON: "more-actions-button",
225-
MORE_ACTIONS_WINDOW: "more-actions-window"
248+
export const ACTION_MENU_ITEM_PARTS_DICTIONARY = {
249+
CONTENT: "content",
250+
SHORTCUT: "shortcut",
251+
ACTION: "action",
252+
BUTTON: "button",
253+
LINK: "link",
254+
WINDOW: "window",
255+
SEPARATOR: "separator",
256+
257+
// - - - - - - - - States - - - - - - - -
258+
EXPANDABLE: "expandable", // ACTION
259+
EXPANDED: "expanded", // ACTION
260+
COLLAPSED: "collapsed", // ACTION
261+
DISABLED: "disabled" // ACTION
226262
} as const;
227263

228-
export const ACTION_GROUP_EXPORT_PARTS = joinParts(
229-
ACTION_GROUP_PARTS_DICTIONARY
264+
export const ACTION_MENU_PARTS_DICTIONARY = {
265+
EXPANDABLE_BUTTON: "expandable-button"
266+
};
267+
268+
export const ACTION_MENU_ITEM_EXPORT_PARTS = joinParts(
269+
ACTION_MENU_ITEM_PARTS_DICTIONARY
230270
);
271+
export const ACTION_MENU_EXPORT_PARTS = joinParts(ACTION_MENU_PARTS_DICTIONARY);
231272

232273
// - - - - - - - - - - - - - - - - - - - -
233274
// Combo Box Parts
@@ -266,22 +307,6 @@ export const EDIT_HOST_PARTS = {
266307
EMPTY_VALUE: "ch-edit--empty-value"
267308
} as const;
268309

269-
// - - - - - - - - - - - - - - - - - - - -
270-
// Dropdown Parts
271-
// - - - - - - - - - - - - - - - - - - - -
272-
export const DROPDOWN_PARTS_DICTIONARY = {
273-
CONTENT: "content",
274-
SHORTCUT: "shortcut",
275-
ACTION: "action",
276-
BUTTON: "button",
277-
LINK: "link",
278-
EXPANDABLE_BUTTON: "expandable-button",
279-
EXPANDABLE: "expandable",
280-
WINDOW: "window"
281-
} as const;
282-
283-
export const DROPDOWN_EXPORT_PARTS = joinParts(DROPDOWN_PARTS_DICTIONARY);
284-
285310
// - - - - - - - - - - - - - - - - - - - -
286311
// Flexible Layout Parts
287312
// - - - - - - - - - - - - - - - - - - - -

src/common/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export type GxImageMultiState = {
3636
disabled?: string;
3737
};
3838

39+
export type GxImageMultiStateByDirection<T extends "start" | "end"> =
40+
T extends "start" ? GxImageMultiStateStart : GxImageMultiStateEnd;
41+
3942
export type GxImageMultiStateStart = {
4043
classes: string;
4144
styles: GxImageMultiStateStartStyles;
@@ -149,6 +152,7 @@ export type ChameleonImagePathCallbackControlsTagName = Extract<
149152
ChameleonControlsTagName,
150153
| "ch-accordion-render"
151154
| "ch-action-list-render"
155+
| "ch-action-menu-render"
152156
| "ch-checkbox"
153157
| "ch-combo-box-render"
154158
| "ch-edit"
Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,43 @@
1-
ch-action-group-render {
2-
display: contents;
3-
}
1+
@import "../../common/_base";
2+
3+
@include box-sizing();
44

5-
.ch-dropdown-separator {
5+
:host {
66
display: grid;
7-
block-size: 1px;
8-
background-color: color-mix(in srgb, currentColor 25%, transparent);
9-
pointer-events: none;
7+
grid-auto-flow: column;
8+
grid-auto-columns: max-content;
9+
align-items: center;
10+
}
11+
12+
:host([items-overflow-behavior="add-scroll"]) {
13+
overflow-x: auto;
14+
}
15+
16+
:host([items-overflow-behavior="multiline"]) {
17+
display: flex;
18+
flex-wrap: wrap;
19+
}
20+
21+
:host([items-overflow-behavior="responsive-collapse"]) {
22+
contain: inline-size;
1023
}
1124

12-
.ch-action-group-separator--vertical {
25+
hr {
1326
display: grid;
27+
align-self: stretch;
1428
inline-size: 1px;
29+
margin: 0;
1530
background-color: color-mix(in srgb, currentColor 25%, transparent);
31+
border: unset;
1632
pointer-events: none;
1733
}
34+
35+
.marker {
36+
display: grid;
37+
align-items: center;
38+
align-self: stretch;
39+
40+
&--hidden {
41+
visibility: hidden;
42+
}
43+
}

0 commit comments

Comments
 (0)