@redvars/peacock 3.5.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseButton-DuASuVth.js +219 -0
- package/dist/BaseButton-DuASuVth.js.map +1 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js +65 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +1 -0
- package/dist/assets/components.css +1 -1
- package/dist/assets/components.css.map +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/banner.js +12 -27
- package/dist/banner.js.map +1 -1
- package/dist/{button-DMN1dPAg.js → button-DouvOfEU.js} +77 -251
- package/dist/button-DouvOfEU.js.map +1 -0
- package/dist/{button-group-CX9CUUXk.js → button-group-CEdMwvJJ.js} +71 -42
- package/dist/button-group-CEdMwvJJ.js.map +1 -0
- package/dist/button-group.js +5 -5
- package/dist/button.js +3 -3
- package/dist/card.js +18 -73
- package/dist/card.js.map +1 -1
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js +2 -2
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js +2 -2
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/code-highlighter.js +2 -1
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +3105 -1494
- package/dist/custom-elements.json +9244 -7829
- package/dist/fab.js +421 -9
- package/dist/fab.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/{select-4pl4XBj7.js → navigation-rail-Lxetd5-Z.js} +2214 -1090
- package/dist/navigation-rail-Lxetd5-Z.js.map +1 -0
- package/dist/notification.js +3 -2
- package/dist/notification.js.map +1 -1
- package/dist/peacock-loader.js +22 -10
- package/dist/peacock-loader.js.map +1 -1
- package/dist/search.js +4 -0
- package/dist/search.js.map +1 -1
- package/dist/src/__mixins/BaseButtonMixin.d.ts +20 -0
- package/dist/src/__mixins/BaseHyperlinkMixin.d.ts +18 -0
- package/dist/src/__mixins/MixinConstructor.d.ts +1 -0
- package/dist/src/banner/banner.d.ts +0 -4
- package/dist/src/button/BaseButton.d.ts +4 -47
- package/dist/src/button/button/button.d.ts +32 -3
- package/dist/src/button/button-group/button-group.d.ts +2 -2
- package/dist/src/button/icon-button/icon-button.d.ts +33 -8
- package/dist/src/card/card.d.ts +4 -15
- package/dist/src/fab/fab.d.ts +4 -35
- package/dist/src/focus-ring/focus-ring.d.ts +11 -5
- package/dist/src/index.d.ts +3 -1
- package/dist/src/link/link.d.ts +1 -1
- package/dist/src/navigation-rail/index.d.ts +2 -0
- package/dist/src/navigation-rail/navigation-rail-item.d.ts +55 -0
- package/dist/src/navigation-rail/navigation-rail.d.ts +71 -0
- package/dist/src/sidebar-menu/index.d.ts +3 -0
- package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +58 -0
- package/dist/src/sidebar-menu/sidebar-menu.d.ts +38 -0
- package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +35 -0
- package/dist/src/toolbar/toolbar.d.ts +10 -10
- package/dist/src/tooltip/tooltip.d.ts +3 -0
- package/dist/src/url-field/index.d.ts +1 -0
- package/dist/src/url-field/url-field.d.ts +48 -0
- package/dist/test/sidebar-menu.test.d.ts +1 -0
- package/dist/toolbar.js +10 -10
- package/dist/toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +73 -65
- package/scss/mixin.scss +16 -0
- package/src/__mixins/BaseButtonMixin.ts +83 -0
- package/src/__mixins/BaseHyperlinkMixin.ts +68 -0
- package/src/__mixins/MixinConstructor.ts +1 -0
- package/src/{__base_element → __mixins}/README.md +2 -2
- package/src/banner/banner.scss +18 -22
- package/src/banner/banner.ts +1 -7
- package/src/button/BaseButton.ts +11 -100
- package/src/button/button/button-sizes.scss +4 -2
- package/src/button/button/button.ts +76 -23
- package/src/button/button-group/button-group.ts +2 -2
- package/src/button/icon-button/icon-button.ts +75 -33
- package/src/card/card.ts +11 -71
- package/src/chart-bar/chart-bar.ts +9 -14
- package/src/chart-bar/chart-stacked-bar.ts +12 -18
- package/src/chart-doughnut/chart-doughnut.ts +23 -27
- package/src/chart-pie/chart-pie.ts +19 -23
- package/src/checkbox/checkbox.scss +17 -34
- package/src/checkbox/checkbox.ts +3 -1
- package/src/code-highlighter/code-highlighter.scss +1 -0
- package/src/code-highlighter/code-highlighter.ts +1 -1
- package/src/date-picker/date-picker.ts +1 -1
- package/src/elevation/elevation.scss +5 -5
- package/src/fab/fab.ts +29 -100
- package/src/focus-ring/focus-ring.ts +47 -40
- package/src/index.ts +3 -1
- package/src/input/input.ts +3 -1
- package/src/link/link.ts +2 -2
- package/src/menu/menu-item/menu-item.ts +3 -1
- package/src/navigation-rail/index.ts +2 -0
- package/src/navigation-rail/navigation-rail-item.scss +216 -0
- package/src/navigation-rail/navigation-rail-item.ts +223 -0
- package/src/navigation-rail/navigation-rail.scss +72 -0
- package/src/navigation-rail/navigation-rail.ts +149 -0
- package/src/notification/notification.ts +3 -2
- package/src/number-field/number-field.ts +6 -4
- package/src/pagination/pagination.ts +6 -4
- package/src/peacock-loader.ts +22 -5
- package/src/search/search.ts +4 -0
- package/src/sidebar-menu/demo/index.html +68 -0
- package/src/sidebar-menu/index.ts +3 -0
- package/src/sidebar-menu/sidebar-menu-item.scss +102 -0
- package/src/sidebar-menu/sidebar-menu-item.ts +151 -0
- package/src/{tree-view/tree-view.scss → sidebar-menu/sidebar-menu.scss} +1 -1
- package/src/sidebar-menu/sidebar-menu.ts +182 -0
- package/src/sidebar-menu/sidebar-sub-menu.scss +130 -0
- package/src/sidebar-menu/sidebar-sub-menu.ts +160 -0
- package/src/skeleton/skeleton.scss +18 -24
- package/src/snackbar/snackbar.ts +1 -1
- package/src/tabs/tab.ts +4 -3
- package/src/text/text.css-component.scss +7 -1
- package/src/time-picker/time-picker.ts +1 -1
- package/src/toolbar/toolbar.ts +10 -10
- package/src/tooltip/tooltip.ts +24 -0
- package/src/url-field/index.ts +1 -0
- package/src/url-field/url-field.scss +50 -0
- package/src/url-field/url-field.ts +239 -0
- package/dist/button-DMN1dPAg.js.map +0 -1
- package/dist/button-group-CX9CUUXk.js.map +0 -1
- package/dist/fab-C5Nzxk0E.js +0 -497
- package/dist/fab-C5Nzxk0E.js.map +0 -1
- package/dist/select-4pl4XBj7.js.map +0 -1
- package/dist/spread-B5cgadZl.js +0 -32
- package/dist/spread-B5cgadZl.js.map +0 -1
- package/dist/src/__base_element/BaseHyperlink.d.ts +0 -20
- package/dist/src/tree-view/index.d.ts +0 -2
- package/dist/src/tree-view/tree-node.d.ts +0 -69
- package/dist/src/tree-view/tree-view.d.ts +0 -40
- package/dist/src/tree-view/wc-tree-view.d.ts +0 -6
- package/dist/test/tree-view.test.d.ts +0 -1
- package/dist/throttle-C7ZAPqtu.js +0 -24
- package/dist/throttle-C7ZAPqtu.js.map +0 -1
- package/src/__base_element/BaseHyperlink.ts +0 -42
- package/src/tree-view/demo/index.html +0 -57
- package/src/tree-view/index.ts +0 -2
- package/src/tree-view/tree-node.scss +0 -101
- package/src/tree-view/tree-node.ts +0 -268
- package/src/tree-view/tree-view.ts +0 -182
- package/src/tree-view/wc-tree-view.ts +0 -9
package/dist/spread-B5cgadZl.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { e, i, t } from './directive-ZPhl09Yt.js';
|
|
2
|
-
|
|
3
|
-
class SpreadDirective extends i {
|
|
4
|
-
constructor(partInfo) {
|
|
5
|
-
super(partInfo);
|
|
6
|
-
if (partInfo.type !== t.ELEMENT) {
|
|
7
|
-
throw new Error('spread() can only be used on elements');
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
-
render(_props) {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
update(part, [props]) {
|
|
15
|
-
if (!props)
|
|
16
|
-
return;
|
|
17
|
-
// eslint-disable-next-line guard-for-in,no-restricted-syntax
|
|
18
|
-
for (const key in props) {
|
|
19
|
-
const value = props[key];
|
|
20
|
-
if (value === undefined || value === null) {
|
|
21
|
-
part.element.removeAttribute(key);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
part.element.setAttribute(key, value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const spread = e(SpreadDirective);
|
|
30
|
-
|
|
31
|
-
export { spread as s };
|
|
32
|
-
//# sourceMappingURL=spread-B5cgadZl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spread-B5cgadZl.js","sources":["../../src/__directive/spread.ts"],"sourcesContent":["import {\n directive,\n Directive,\n ElementPart,\n PartInfo,\n PartType,\n} from 'lit/directive.js';\n\nclass SpreadDirective extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.ELEMENT) {\n throw new Error('spread() can only be used on elements');\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render(_props: { [key: string]: any } | undefined) {\n return '';\n }\n\n update(part: ElementPart, [props]: [{ [key: string]: any } | undefined]) {\n if (!props) return;\n // eslint-disable-next-line guard-for-in,no-restricted-syntax\n for (const key in props) {\n const value = props[key];\n if (value === undefined || value === null) {\n part.element.removeAttribute(key);\n } else {\n part.element.setAttribute(key, value);\n }\n }\n }\n}\n\nexport const spread = directive(SpreadDirective);\n"],"names":["Directive","PartType","directive"],"mappings":";;AAQA,MAAM,eAAgB,SAAQA,CAAS,CAAA;AACrC,IAAA,WAAA,CAAY,QAAkB,EAAA;QAC5B,KAAK,CAAC,QAAQ,CAAC;QACf,IAAI,QAAQ,CAAC,IAAI,KAAKC,CAAQ,CAAC,OAAO,EAAE;AACtC,YAAA,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC;QAC1D;IACF;;AAGA,IAAA,MAAM,CAAC,MAA0C,EAAA;AAC/C,QAAA,OAAO,EAAE;IACX;AAEA,IAAA,MAAM,CAAC,IAAiB,EAAE,CAAC,KAAK,CAAuC,EAAA;AACrE,QAAA,IAAI,CAAC,KAAK;YAAE;;AAEZ,QAAA,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;AACvB,YAAA,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;YACxB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;AACzC,gBAAA,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC;YACnC;iBAAO;gBACL,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC;YACvC;QACF;IACF;AACD;MAEY,MAAM,GAAGC,CAAS,CAAC,eAAe;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
3
|
-
/**
|
|
4
|
-
* 1. Define an interface for the members the mixin adds.
|
|
5
|
-
* This makes the type annotation much cleaner.
|
|
6
|
-
*/
|
|
7
|
-
export interface BaseHyperlinkInterface {
|
|
8
|
-
href?: string;
|
|
9
|
-
target: '_self' | '_parent' | '_blank' | '_top' | string;
|
|
10
|
-
__isLink(): boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 2. Define the Mixin type separately for readability.
|
|
14
|
-
*/
|
|
15
|
-
type BaseHyperlinkMixinType = <T extends Constructor<LitElement>>(superclass: T) => T & Constructor<BaseHyperlinkInterface>;
|
|
16
|
-
/**
|
|
17
|
-
* 3. Apply the type annotation to the variable.
|
|
18
|
-
*/
|
|
19
|
-
declare const BaseHyperlink: BaseHyperlinkMixinType;
|
|
20
|
-
export default BaseHyperlink;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
/**
|
|
3
|
-
* @label Tree Node
|
|
4
|
-
* @tag wc-tree-node
|
|
5
|
-
* @rawTag tree-node
|
|
6
|
-
* @parentRawTag tree-view
|
|
7
|
-
* @summary A tree node represents a single item in a hierarchical tree structure. It supports nesting, icons, links, and keyboard navigation.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```html
|
|
11
|
-
* <wc-tree-view>
|
|
12
|
-
* <wc-tree-node label="Parent">
|
|
13
|
-
* <wc-tree-node label="Child"></wc-tree-node>
|
|
14
|
-
* </wc-tree-node>
|
|
15
|
-
* </wc-tree-view>
|
|
16
|
-
* ```
|
|
17
|
-
* @tags navigation
|
|
18
|
-
*/
|
|
19
|
-
export declare class TreeNode extends LitElement {
|
|
20
|
-
static styles: import("lit").CSSResultGroup[];
|
|
21
|
-
/**
|
|
22
|
-
* The value used to identify this node when selected.
|
|
23
|
-
*/
|
|
24
|
-
value: string;
|
|
25
|
-
/**
|
|
26
|
-
* The display label for this node.
|
|
27
|
-
*/
|
|
28
|
-
label: string;
|
|
29
|
-
/**
|
|
30
|
-
* Optional icon name to display before the label.
|
|
31
|
-
*/
|
|
32
|
-
icon: string;
|
|
33
|
-
/**
|
|
34
|
-
* Optional hyperlink to navigate to on click.
|
|
35
|
-
*/
|
|
36
|
-
href: string;
|
|
37
|
-
/**
|
|
38
|
-
* Sets or retrieves the window or frame at which to target content.
|
|
39
|
-
*/
|
|
40
|
-
target: string;
|
|
41
|
-
/**
|
|
42
|
-
* If true, the user cannot interact with the node.
|
|
43
|
-
*/
|
|
44
|
-
disabled: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Whether the node is currently selected.
|
|
47
|
-
*/
|
|
48
|
-
selected: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Whether child nodes are visible.
|
|
51
|
-
*/
|
|
52
|
-
expanded: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* The nesting depth level (set automatically by the parent tree-view).
|
|
55
|
-
*/
|
|
56
|
-
level: number;
|
|
57
|
-
private readonly _nativeElement;
|
|
58
|
-
focus(): void;
|
|
59
|
-
blur(): void;
|
|
60
|
-
private _getChildNodes;
|
|
61
|
-
connectedCallback(): void;
|
|
62
|
-
private _syncHostAria;
|
|
63
|
-
private _updateChildLevels;
|
|
64
|
-
private _handleClick;
|
|
65
|
-
private _handleKeyDown;
|
|
66
|
-
updated(changedProps: Map<string, unknown>): void;
|
|
67
|
-
private _renderContent;
|
|
68
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
69
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import { TreeNode } from './tree-node.js';
|
|
3
|
-
/**
|
|
4
|
-
* @label Tree View
|
|
5
|
-
* @tag wc-tree-view
|
|
6
|
-
* @rawTag tree-view
|
|
7
|
-
* @summary A tree view is a hierarchical structure that provides nested levels of navigation. It supports keyboard navigation, single/multi select, and expandable nodes.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```html
|
|
11
|
-
* <wc-tree-view>
|
|
12
|
-
* <wc-tree-node label="Parent" expanded>
|
|
13
|
-
* <wc-tree-node label="Child 1"></wc-tree-node>
|
|
14
|
-
* <wc-tree-node label="Child 2"></wc-tree-node>
|
|
15
|
-
* </wc-tree-node>
|
|
16
|
-
* </wc-tree-view>
|
|
17
|
-
* ```
|
|
18
|
-
* @tags navigation
|
|
19
|
-
*/
|
|
20
|
-
export declare class TreeView extends LitElement {
|
|
21
|
-
static styles: import("lit").CSSResultGroup[];
|
|
22
|
-
/**
|
|
23
|
-
* The value of the currently selected node.
|
|
24
|
-
*/
|
|
25
|
-
selectedNode: string;
|
|
26
|
-
connectedCallback(): void;
|
|
27
|
-
updated(changedProps: Map<string, unknown>): void;
|
|
28
|
-
disconnectedCallback(): void;
|
|
29
|
-
private _getTopLevelNodes;
|
|
30
|
-
private _getAllVisibleNodes;
|
|
31
|
-
private _onNodeClick;
|
|
32
|
-
private _updateSelectedState;
|
|
33
|
-
private _clearSelectedState;
|
|
34
|
-
private _syncSelectedStateFromProperty;
|
|
35
|
-
private _onSlotChange;
|
|
36
|
-
private _collectAllNodes;
|
|
37
|
-
private _onKeyDown;
|
|
38
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
39
|
-
static Node: typeof TreeNode;
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../src/tree-view/wc-tree-view.js';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
function throttle(func, delay, options = { leading: true, trailing: true }) {
|
|
2
|
-
let timerId;
|
|
3
|
-
let lastExec = 0;
|
|
4
|
-
return function (...args) {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const context = this;
|
|
7
|
-
const now = Date.now();
|
|
8
|
-
const shouldCallNow = options.leading && now - lastExec >= delay;
|
|
9
|
-
if (shouldCallNow) {
|
|
10
|
-
func.apply(context, args);
|
|
11
|
-
lastExec = now;
|
|
12
|
-
}
|
|
13
|
-
else if (options.trailing && !timerId) {
|
|
14
|
-
timerId = setTimeout(() => {
|
|
15
|
-
func.apply(context, args);
|
|
16
|
-
lastExec = Date.now();
|
|
17
|
-
timerId = null;
|
|
18
|
-
}, delay);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { throttle as t };
|
|
24
|
-
//# sourceMappingURL=throttle-C7ZAPqtu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttle-C7ZAPqtu.js","sources":["../../src/__utils/throttle.ts"],"sourcesContent":["export function throttle(\n func: Function,\n delay: number,\n options = { leading: true, trailing: true },\n) {\n let timerId: any;\n let lastExec = 0;\n\n return function (...args: any[]) {\n // @ts-ignore\n const context = this;\n const now = Date.now();\n\n const shouldCallNow = options.leading && now - lastExec >= delay;\n\n if (shouldCallNow) {\n func.apply(context, args);\n lastExec = now;\n } else if (options.trailing && !timerId) {\n timerId = setTimeout(() => {\n func.apply(context, args);\n lastExec = Date.now();\n timerId = null;\n }, delay);\n }\n };\n}"],"names":[],"mappings":"SAAgB,QAAQ,CACtB,IAAc,EACd,KAAa,EACb,OAAO,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAA;AAE3C,IAAA,IAAI,OAAY;IAChB,IAAI,QAAQ,GAAG,CAAC;IAEhB,OAAO,UAAU,GAAG,IAAW,EAAA;;QAE7B,MAAM,OAAO,GAAG,IAAI;AACpB,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;QAEtB,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,GAAG,QAAQ,IAAI,KAAK;QAEhE,IAAI,aAAa,EAAE;AACjB,YAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;YACzB,QAAQ,GAAG,GAAG;QAChB;AAAO,aAAA,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,EAAE;AACvC,YAAA,OAAO,GAAG,UAAU,CAAC,MAAK;AACxB,gBAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;AACzB,gBAAA,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE;gBACrB,OAAO,GAAG,IAAI;YAChB,CAAC,EAAE,KAAK,CAAC;QACX;AACF,IAAA,CAAC;AACH;;;;"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
|
|
4
|
-
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 1. Define an interface for the members the mixin adds.
|
|
8
|
-
* This makes the type annotation much cleaner.
|
|
9
|
-
*/
|
|
10
|
-
export interface BaseHyperlinkInterface {
|
|
11
|
-
href?: string;
|
|
12
|
-
target: '_self' | '_parent' | '_blank' | '_top' | string;
|
|
13
|
-
__isLink(): boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 2. Define the Mixin type separately for readability.
|
|
18
|
-
*/
|
|
19
|
-
type BaseHyperlinkMixinType = <T extends Constructor<LitElement>>(superclass: T) => T & Constructor<BaseHyperlinkInterface>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 3. Apply the type annotation to the variable.
|
|
23
|
-
*/
|
|
24
|
-
const BaseHyperlink: BaseHyperlinkMixinType = <T extends Constructor<LitElement>>(superclass: T) => {
|
|
25
|
-
// Naming the class (BaseHyperlinkElement) instead of using 'Mixin' or anonymous
|
|
26
|
-
// prevents the "__childPart" visibility error.
|
|
27
|
-
class BaseHyperlinkElement extends superclass implements BaseHyperlinkInterface {
|
|
28
|
-
@property({ reflect: true })
|
|
29
|
-
href?: string;
|
|
30
|
-
|
|
31
|
-
@property()
|
|
32
|
-
target: '_self' | '_parent' | '_blank' | '_top' | string = '_self';
|
|
33
|
-
|
|
34
|
-
__isLink(): boolean {
|
|
35
|
-
return !!this.href;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return BaseHyperlinkElement as T & Constructor<BaseHyperlinkInterface>;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default BaseHyperlink;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang='en-GB'>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset='utf-8'>
|
|
5
|
-
<meta name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover' />
|
|
6
|
-
<link rel='stylesheet' href='/dist/assets/styles/tokens.css' />
|
|
7
|
-
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
|
8
|
-
|
|
9
|
-
<style>
|
|
10
|
-
body {
|
|
11
|
-
background: #fafafa;
|
|
12
|
-
padding: 2rem;
|
|
13
|
-
font-family: 'Noto Sans', sans-serif;
|
|
14
|
-
}
|
|
15
|
-
h2 {
|
|
16
|
-
margin-top: 2rem;
|
|
17
|
-
margin-bottom: 0.5rem;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
|
|
23
|
-
<h2>Basic Tree View</h2>
|
|
24
|
-
<wc-tree-view>
|
|
25
|
-
<wc-tree-node label="Documents" icon="folder" expanded>
|
|
26
|
-
<wc-tree-node label="Work" icon="folder" expanded>
|
|
27
|
-
<wc-tree-node label="Project A" icon="description"></wc-tree-node>
|
|
28
|
-
<wc-tree-node label="Project B" icon="description"></wc-tree-node>
|
|
29
|
-
</wc-tree-node>
|
|
30
|
-
<wc-tree-node label="Personal" icon="folder">
|
|
31
|
-
<wc-tree-node label="Resume.pdf" icon="picture_as_pdf"></wc-tree-node>
|
|
32
|
-
</wc-tree-node>
|
|
33
|
-
</wc-tree-node>
|
|
34
|
-
<wc-tree-node label="Pictures" icon="photo_library">
|
|
35
|
-
<wc-tree-node label="Vacation.jpg" icon="image"></wc-tree-node>
|
|
36
|
-
<wc-tree-node label="Family.jpg" icon="image"></wc-tree-node>
|
|
37
|
-
</wc-tree-node>
|
|
38
|
-
<wc-tree-node label="Disabled Node" icon="block" disabled></wc-tree-node>
|
|
39
|
-
</wc-tree-view>
|
|
40
|
-
|
|
41
|
-
<h2>Tree View without Icons</h2>
|
|
42
|
-
<wc-tree-view>
|
|
43
|
-
<wc-tree-node label="Category 1" expanded>
|
|
44
|
-
<wc-tree-node label="Item 1.1"></wc-tree-node>
|
|
45
|
-
<wc-tree-node label="Item 1.2">
|
|
46
|
-
<wc-tree-node label="Item 1.2.1"></wc-tree-node>
|
|
47
|
-
<wc-tree-node label="Item 1.2.2"></wc-tree-node>
|
|
48
|
-
</wc-tree-node>
|
|
49
|
-
</wc-tree-node>
|
|
50
|
-
<wc-tree-node label="Category 2">
|
|
51
|
-
<wc-tree-node label="Item 2.1"></wc-tree-node>
|
|
52
|
-
</wc-tree-node>
|
|
53
|
-
</wc-tree-view>
|
|
54
|
-
|
|
55
|
-
<script type='module' src='/dist/peacock-loader.js'></script>
|
|
56
|
-
</body>
|
|
57
|
-
</html>
|
package/src/tree-view/index.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
@use '../../scss/mixin';
|
|
2
|
-
|
|
3
|
-
@include mixin.base-styles;
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
display: block;
|
|
7
|
-
|
|
8
|
-
// M3 tree node sizing
|
|
9
|
-
--tree-node-height: 2.5rem;
|
|
10
|
-
--tree-node-icon-size: 1.25rem;
|
|
11
|
-
--tree-node-border-radius: var(--global-shape-corner-full, 9999px);
|
|
12
|
-
|
|
13
|
-
// M3 color tokens
|
|
14
|
-
--tree-node-label-color: var(--color-on-surface);
|
|
15
|
-
--tree-node-icon-color: var(--color-on-surface-variant);
|
|
16
|
-
--tree-node-selected-background: var(--color-secondary-container);
|
|
17
|
-
--tree-node-selected-color: var(--color-on-secondary-container);
|
|
18
|
-
--tree-node-hover-background: var(--color-inverse-primary);
|
|
19
|
-
--tree-node-focus-ring-color: var(--color-primary);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.tree-node {
|
|
23
|
-
display: block;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.tree-node-content {
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
gap: 0.25rem;
|
|
30
|
-
height: var(--tree-node-height);
|
|
31
|
-
border-radius: var(--tree-node-border-radius);
|
|
32
|
-
color: var(--tree-node-label-color);
|
|
33
|
-
cursor: pointer;
|
|
34
|
-
user-select: none;
|
|
35
|
-
text-decoration: none;
|
|
36
|
-
outline: none;
|
|
37
|
-
|
|
38
|
-
@include mixin.get-typography(body-medium);
|
|
39
|
-
|
|
40
|
-
&:not(.disabled):hover {
|
|
41
|
-
background-color: var(--tree-node-hover-background);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&:focus-visible {
|
|
45
|
-
@include mixin.focus-ring(var(--tree-node-focus-ring-color));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&.selected {
|
|
49
|
-
background-color: var(--tree-node-selected-background);
|
|
50
|
-
color: var(--tree-node-selected-color);
|
|
51
|
-
|
|
52
|
-
.node-icon {
|
|
53
|
-
--icon-color: var(--tree-node-selected-color);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.disabled {
|
|
58
|
-
cursor: not-allowed;
|
|
59
|
-
opacity: 0.38;
|
|
60
|
-
pointer-events: none;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.expand-icon {
|
|
65
|
-
--icon-size: var(--tree-node-icon-size);
|
|
66
|
-
--icon-color: var(--tree-node-icon-color);
|
|
67
|
-
flex-shrink: 0;
|
|
68
|
-
transition: transform var(--duration-short2, 200ms) var(--easing-standard, ease);
|
|
69
|
-
|
|
70
|
-
&.expanded {
|
|
71
|
-
transform: rotate(90deg);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.icon-space {
|
|
76
|
-
display: inline-block;
|
|
77
|
-
width: var(--tree-node-icon-size);
|
|
78
|
-
height: var(--tree-node-icon-size);
|
|
79
|
-
flex-shrink: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.node-icon {
|
|
83
|
-
--icon-size: var(--tree-node-icon-size);
|
|
84
|
-
--icon-color: var(--tree-node-icon-color);
|
|
85
|
-
flex-shrink: 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.tree-node-label {
|
|
89
|
-
flex: 1;
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
text-overflow: ellipsis;
|
|
92
|
-
white-space: nowrap;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.node-children {
|
|
96
|
-
display: none;
|
|
97
|
-
|
|
98
|
-
&.expanded {
|
|
99
|
-
display: block;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { html, LitElement } from 'lit';
|
|
2
|
-
import { property, query } from 'lit/decorators.js';
|
|
3
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
-
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
|
-
import styles from './tree-node.scss';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @label Tree Node
|
|
9
|
-
* @tag wc-tree-node
|
|
10
|
-
* @rawTag tree-node
|
|
11
|
-
* @parentRawTag tree-view
|
|
12
|
-
* @summary A tree node represents a single item in a hierarchical tree structure. It supports nesting, icons, links, and keyboard navigation.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```html
|
|
16
|
-
* <wc-tree-view>
|
|
17
|
-
* <wc-tree-node label="Parent">
|
|
18
|
-
* <wc-tree-node label="Child"></wc-tree-node>
|
|
19
|
-
* </wc-tree-node>
|
|
20
|
-
* </wc-tree-view>
|
|
21
|
-
* ```
|
|
22
|
-
* @tags navigation
|
|
23
|
-
*/
|
|
24
|
-
export class TreeNode extends LitElement {
|
|
25
|
-
static styles = [styles];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The value used to identify this node when selected.
|
|
29
|
-
*/
|
|
30
|
-
@property({ type: String, reflect: true })
|
|
31
|
-
value: string = '';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The display label for this node.
|
|
35
|
-
*/
|
|
36
|
-
@property({ type: String, reflect: true })
|
|
37
|
-
label: string = '';
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Optional icon name to display before the label.
|
|
41
|
-
*/
|
|
42
|
-
@property({ type: String, reflect: true })
|
|
43
|
-
icon: string = '';
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Optional hyperlink to navigate to on click.
|
|
47
|
-
*/
|
|
48
|
-
@property({ type: String, reflect: true })
|
|
49
|
-
href: string = '';
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Sets or retrieves the window or frame at which to target content.
|
|
53
|
-
*/
|
|
54
|
-
@property({ type: String, reflect: true })
|
|
55
|
-
target: string = '_self';
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* If true, the user cannot interact with the node.
|
|
59
|
-
*/
|
|
60
|
-
@property({ type: Boolean, reflect: true })
|
|
61
|
-
disabled: boolean = false;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Whether the node is currently selected.
|
|
65
|
-
*/
|
|
66
|
-
@property({ type: Boolean, reflect: true })
|
|
67
|
-
selected: boolean = false;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Whether child nodes are visible.
|
|
71
|
-
*/
|
|
72
|
-
@property({ type: Boolean, reflect: true })
|
|
73
|
-
expanded: boolean = false;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* The nesting depth level (set automatically by the parent tree-view).
|
|
77
|
-
*/
|
|
78
|
-
@property({ type: Number, reflect: true })
|
|
79
|
-
level: number = 0;
|
|
80
|
-
|
|
81
|
-
@query('.tree-node-content')
|
|
82
|
-
private readonly _nativeElement!: HTMLElement | null;
|
|
83
|
-
|
|
84
|
-
override focus() {
|
|
85
|
-
this._nativeElement?.focus();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
override blur() {
|
|
89
|
-
this._nativeElement?.blur();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private _getChildNodes(): TreeNode[] {
|
|
93
|
-
return Array.from(this.children).filter(
|
|
94
|
-
el => el.tagName.toLowerCase() === 'wc-tree-node',
|
|
95
|
-
) as TreeNode[];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
connectedCallback() {
|
|
99
|
-
super.connectedCallback();
|
|
100
|
-
this._updateChildLevels();
|
|
101
|
-
this.setAttribute('role', 'treeitem');
|
|
102
|
-
this._syncHostAria();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private _syncHostAria() {
|
|
106
|
-
const hasChildren = this._getChildNodes().length > 0;
|
|
107
|
-
if (hasChildren) {
|
|
108
|
-
this.setAttribute('aria-expanded', String(this.expanded));
|
|
109
|
-
} else {
|
|
110
|
-
this.removeAttribute('aria-expanded');
|
|
111
|
-
}
|
|
112
|
-
this.setAttribute('aria-selected', String(this.selected));
|
|
113
|
-
this.setAttribute('aria-disabled', String(this.disabled));
|
|
114
|
-
this.setAttribute('aria-level', String(this.level + 1));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private _updateChildLevels() {
|
|
118
|
-
const children = this._getChildNodes();
|
|
119
|
-
children.forEach(child => {
|
|
120
|
-
// eslint-disable-next-line no-param-reassign
|
|
121
|
-
child.level = this.level + 1;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private _handleClick(event: Event) {
|
|
126
|
-
if (this.disabled) {
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
event.stopPropagation();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const hasChildren = this._getChildNodes().length > 0;
|
|
133
|
-
if (hasChildren) {
|
|
134
|
-
this.expanded = !this.expanded;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
this.dispatchEvent(
|
|
138
|
-
new CustomEvent('tree-node:click', {
|
|
139
|
-
bubbles: true,
|
|
140
|
-
composed: true,
|
|
141
|
-
detail: {
|
|
142
|
-
value: this.value || this.label,
|
|
143
|
-
label: this.label,
|
|
144
|
-
expanded: this.expanded,
|
|
145
|
-
},
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private _handleKeyDown(event: KeyboardEvent) {
|
|
151
|
-
if (this.disabled) return;
|
|
152
|
-
|
|
153
|
-
const hasChildren = this._getChildNodes().length > 0;
|
|
154
|
-
|
|
155
|
-
switch (event.key) {
|
|
156
|
-
case ' ':
|
|
157
|
-
case 'Enter':
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
if (hasChildren) {
|
|
160
|
-
this.expanded = !this.expanded;
|
|
161
|
-
}
|
|
162
|
-
this.dispatchEvent(
|
|
163
|
-
new CustomEvent('tree-node:click', {
|
|
164
|
-
bubbles: true,
|
|
165
|
-
composed: true,
|
|
166
|
-
detail: {
|
|
167
|
-
value: this.value || this.label,
|
|
168
|
-
label: this.label,
|
|
169
|
-
expanded: this.expanded,
|
|
170
|
-
},
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
173
|
-
if (this.href) {
|
|
174
|
-
window.open(this.href, this.target);
|
|
175
|
-
}
|
|
176
|
-
break;
|
|
177
|
-
case 'ArrowLeft':
|
|
178
|
-
event.preventDefault();
|
|
179
|
-
if (this.expanded && hasChildren) {
|
|
180
|
-
this.expanded = false;
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
|
-
case 'ArrowRight':
|
|
184
|
-
event.preventDefault();
|
|
185
|
-
if (hasChildren) {
|
|
186
|
-
if (!this.expanded) {
|
|
187
|
-
this.expanded = true;
|
|
188
|
-
} else {
|
|
189
|
-
const firstChild = this._getChildNodes()[0];
|
|
190
|
-
firstChild?.focus();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
default:
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
updated(changedProps: Map<string, unknown>) {
|
|
200
|
-
super.updated(changedProps);
|
|
201
|
-
if (changedProps.has('level')) {
|
|
202
|
-
this._updateChildLevels();
|
|
203
|
-
}
|
|
204
|
-
this._syncHostAria();
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private _renderContent(hasChildren: boolean) {
|
|
208
|
-
// 0.125rem offset aligns text visually with the expand/icon space
|
|
209
|
-
const indentStyle = styleMap({
|
|
210
|
-
paddingInlineStart: `calc(${this.level + 1}rem - 0.125rem)`,
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
const contentClasses = classMap({
|
|
214
|
-
'tree-node-content': true,
|
|
215
|
-
selected: this.selected,
|
|
216
|
-
disabled: this.disabled,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
const innerContent = html`
|
|
220
|
-
${hasChildren
|
|
221
|
-
? html`<wc-icon
|
|
222
|
-
class=${classMap({ 'expand-icon': true, expanded: this.expanded })}
|
|
223
|
-
name="arrow_right"
|
|
224
|
-
></wc-icon>`
|
|
225
|
-
: html`<span class="icon-space"></span>`}
|
|
226
|
-
${this.icon
|
|
227
|
-
? html`<wc-icon class="node-icon" name=${this.icon}></wc-icon>`
|
|
228
|
-
: ''}
|
|
229
|
-
<span class="tree-node-label">${this.label}<slot name="label"></slot></span>
|
|
230
|
-
`;
|
|
231
|
-
|
|
232
|
-
if (this.href) {
|
|
233
|
-
return html`<a
|
|
234
|
-
class=${contentClasses}
|
|
235
|
-
style=${indentStyle}
|
|
236
|
-
href=${this.href}
|
|
237
|
-
target=${this.target}
|
|
238
|
-
tabindex=${this.disabled ? '-1' : '0'}
|
|
239
|
-
@click=${this._handleClick}
|
|
240
|
-
@keydown=${this._handleKeyDown}
|
|
241
|
-
>${innerContent}</a>`;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return html`<div
|
|
245
|
-
class=${contentClasses}
|
|
246
|
-
style=${indentStyle}
|
|
247
|
-
tabindex=${this.disabled ? '-1' : '0'}
|
|
248
|
-
@click=${this._handleClick}
|
|
249
|
-
@keydown=${this._handleKeyDown}
|
|
250
|
-
>${innerContent}</div>`;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
render() {
|
|
254
|
-
const hasChildren = this._getChildNodes().length > 0;
|
|
255
|
-
|
|
256
|
-
const nodeSlotClasses = classMap({
|
|
257
|
-
'node-children': true,
|
|
258
|
-
expanded: this.expanded,
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
return html`<div class="tree-node">
|
|
262
|
-
${this._renderContent(hasChildren)}
|
|
263
|
-
<div class=${nodeSlotClasses}>
|
|
264
|
-
<slot></slot>
|
|
265
|
-
</div>
|
|
266
|
-
</div>`;
|
|
267
|
-
}
|
|
268
|
-
}
|