kempo-ui 0.0.42 → 0.0.62
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/.github/copilot-instructions.md +11 -0
- package/.github/workflows/publish.yml +66 -0
- package/CONTRIBUTING.md +70 -0
- package/dist/components/Accordion.js +1 -1
- package/dist/components/ContentSlider.js +2 -2
- package/dist/components/Dialog.js +9 -8
- package/dist/components/HtmlEditor.js +91 -0
- package/dist/components/Icon.js +34 -2
- package/dist/components/Main.js +24 -0
- package/dist/components/PhotoViewer.js +2 -2
- package/dist/components/ShadowComponent.js +1 -1
- package/dist/components/ShowMore.js +8 -8
- package/dist/components/SideMenu.js +1 -1
- package/dist/components/SidePanel.js +235 -0
- package/dist/components/Table.js +1 -1
- package/dist/components/htmlEditorControls/AlignCenter.js +12 -0
- package/dist/components/htmlEditorControls/AlignJustify.js +12 -0
- package/dist/components/htmlEditorControls/AlignLeft.js +12 -0
- package/dist/components/htmlEditorControls/AlignRight.js +12 -0
- package/dist/components/htmlEditorControls/Bold.js +12 -0
- package/dist/components/htmlEditorControls/BulletList.js +12 -0
- package/dist/components/htmlEditorControls/CharacterCount.js +18 -0
- package/dist/components/htmlEditorControls/ClearFormatting.js +12 -0
- package/dist/components/htmlEditorControls/CodeBlock.js +12 -0
- package/dist/components/htmlEditorControls/ControlGroup.js +14 -0
- package/dist/components/htmlEditorControls/ControlSpacer.js +6 -0
- package/dist/components/htmlEditorControls/CreateLink.js +15 -0
- package/dist/components/htmlEditorControls/DropdownControl.js +57 -0
- package/dist/components/htmlEditorControls/FormatBlock.js +12 -0
- package/dist/components/htmlEditorControls/HtmlEditorControl.js +44 -0
- package/dist/components/htmlEditorControls/InlineCode.js +12 -0
- package/dist/components/htmlEditorControls/InsertTable.js +15 -0
- package/dist/components/htmlEditorControls/Italic.js +12 -0
- package/dist/components/htmlEditorControls/Mode.js +9 -0
- package/dist/components/htmlEditorControls/NumberList.js +12 -0
- package/dist/components/htmlEditorControls/Strikethrough.js +12 -0
- package/dist/components/htmlEditorControls/TextBackgroundColor.js +97 -0
- package/dist/components/htmlEditorControls/TextColor.js +97 -0
- package/dist/components/htmlEditorControls/Underline.js +12 -0
- package/dist/components/htmlEditorControls/WordCount.js +18 -0
- package/dist/components/tableControls/FirstPage.js +1 -1
- package/dist/components/tableControls/LastPage.js +1 -1
- package/dist/components/tableControls/NextPage.js +1 -1
- package/dist/components/tableControls/PrevPage.js +1 -1
- package/dist/utils/formatCode.js +1 -0
- package/dist/utils/theme.js +1 -1
- package/docs/components/dropdown.html +2 -2
- package/docs/components/html-editor.html +442 -0
- package/docs/components/icon.html +52 -12
- package/docs/components/photo-viewer.html +14 -14
- package/docs/components/side-menu.html +32 -0
- package/docs/components/side-panel-basic.html +44 -0
- package/docs/components/side-panel-dual.html +70 -0
- package/docs/components/side-panel-menu.html +50 -0
- package/docs/components/side-panel-scroll.html +176 -0
- package/docs/components/side-panel.html +226 -0
- package/docs/components/table.html +24 -24
- package/docs/dev.config.json +8 -0
- package/docs/icons/account-circle.svg +1 -0
- package/docs/icons/arrow-circle.svg +1 -0
- package/docs/icons/arrow-line.svg +1 -0
- package/docs/icons/arrow_drop_down.svg +1 -0
- package/docs/icons/chevron-double.svg +1 -0
- package/docs/icons/chevron-line.svg +1 -0
- package/docs/icons/circle.svg +1 -0
- package/docs/icons/code.svg +1 -0
- package/docs/icons/code_blocks.svg +1 -0
- package/docs/icons/copy.svg +1 -0
- package/docs/icons/dot.svg +1 -0
- package/docs/icons/format_align_center.svg +1 -0
- package/docs/icons/format_align_justify.svg +1 -0
- package/docs/icons/format_align_left.svg +1 -0
- package/docs/icons/format_align_right.svg +1 -0
- package/docs/icons/format_bold.svg +1 -0
- package/docs/icons/format_clear.svg +1 -0
- package/docs/icons/format_color_fill.svg +1 -0
- package/docs/icons/format_color_text.svg +1 -0
- package/docs/icons/format_h1.svg +1 -0
- package/docs/icons/format_h2.svg +1 -0
- package/docs/icons/format_h3.svg +1 -0
- package/docs/icons/format_h4.svg +1 -0
- package/docs/icons/format_h5.svg +1 -0
- package/docs/icons/format_h6.svg +1 -0
- package/docs/icons/format_italic.svg +1 -0
- package/docs/icons/format_list_bulleted.svg +1 -0
- package/docs/icons/format_list_numbered.svg +1 -0
- package/docs/icons/format_paragraph.svg +1 -0
- package/docs/icons/format_underlined.svg +1 -0
- package/docs/icons/help.svg +1 -0
- package/docs/icons/key.svg +1 -0
- package/docs/icons/link.svg +1 -0
- package/docs/icons/login.svg +1 -0
- package/docs/icons/logout.svg +1 -0
- package/docs/icons/more_vert.svg +1 -0
- package/docs/icons/strikethrough_s.svg +1 -0
- package/docs/icons/table.svg +1 -0
- package/docs/icons/wysiwyg.svg +1 -0
- package/docs/index.html +12 -0
- package/docs/nav-1.inc.html +2 -0
- package/docs/nav.inc.html +2 -0
- package/docs/prod.config.json +4 -0
- package/docs/src/components/Accordion.js +1 -1
- package/docs/src/components/ContentSlider.js +2 -2
- package/docs/src/components/Dialog.js +9 -8
- package/docs/src/components/HtmlEditor.js +91 -0
- package/docs/src/components/Icon.js +34 -2
- package/docs/src/components/Main.js +24 -0
- package/docs/src/components/PhotoViewer.js +2 -2
- package/docs/src/components/ShadowComponent.js +1 -1
- package/docs/src/components/ShowMore.js +8 -8
- package/docs/src/components/SideMenu.js +1 -1
- package/docs/src/components/SidePanel.js +235 -0
- package/docs/src/components/Table.js +1 -1
- package/docs/src/components/htmlEditorControls/AlignCenter.js +12 -0
- package/docs/src/components/htmlEditorControls/AlignJustify.js +12 -0
- package/docs/src/components/htmlEditorControls/AlignLeft.js +12 -0
- package/docs/src/components/htmlEditorControls/AlignRight.js +12 -0
- package/docs/src/components/htmlEditorControls/Bold.js +12 -0
- package/docs/src/components/htmlEditorControls/BulletList.js +12 -0
- package/docs/src/components/htmlEditorControls/CharacterCount.js +18 -0
- package/docs/src/components/htmlEditorControls/ClearFormatting.js +12 -0
- package/docs/src/components/htmlEditorControls/CodeBlock.js +12 -0
- package/docs/src/components/htmlEditorControls/ControlGroup.js +14 -0
- package/docs/src/components/htmlEditorControls/ControlSpacer.js +6 -0
- package/docs/src/components/htmlEditorControls/CreateLink.js +15 -0
- package/docs/src/components/htmlEditorControls/DropdownControl.js +57 -0
- package/docs/src/components/htmlEditorControls/FormatBlock.js +12 -0
- package/docs/src/components/htmlEditorControls/HtmlEditorControl.js +44 -0
- package/docs/src/components/htmlEditorControls/InlineCode.js +12 -0
- package/docs/src/components/htmlEditorControls/InsertTable.js +15 -0
- package/docs/src/components/htmlEditorControls/Italic.js +12 -0
- package/docs/src/components/htmlEditorControls/Mode.js +9 -0
- package/docs/src/components/htmlEditorControls/NumberList.js +12 -0
- package/docs/src/components/htmlEditorControls/Strikethrough.js +12 -0
- package/docs/src/components/htmlEditorControls/TextBackgroundColor.js +97 -0
- package/docs/src/components/htmlEditorControls/TextColor.js +97 -0
- package/docs/src/components/htmlEditorControls/Underline.js +12 -0
- package/docs/src/components/htmlEditorControls/WordCount.js +18 -0
- package/docs/src/components/tableControls/FirstPage.js +1 -1
- package/docs/src/components/tableControls/LastPage.js +1 -1
- package/docs/src/components/tableControls/NextPage.js +1 -1
- package/docs/src/components/tableControls/PrevPage.js +1 -1
- package/docs/src/utils/formatCode.js +1 -0
- package/docs/src/utils/theme.js +1 -1
- package/icons/account-circle.svg +1 -0
- package/icons/arrow-circle.svg +1 -0
- package/icons/arrow-line.svg +1 -0
- package/icons/arrow_drop_down.svg +1 -0
- package/icons/chevron-double.svg +1 -0
- package/icons/chevron-line.svg +1 -0
- package/icons/circle.svg +1 -0
- package/icons/code.svg +1 -0
- package/icons/code_blocks.svg +1 -0
- package/icons/copy.svg +1 -0
- package/icons/dot.svg +1 -0
- package/icons/format_align_center.svg +1 -0
- package/icons/format_align_justify.svg +1 -0
- package/icons/format_align_left.svg +1 -0
- package/icons/format_align_right.svg +1 -0
- package/icons/format_bold.svg +1 -0
- package/icons/format_clear.svg +1 -0
- package/icons/format_color_fill.svg +1 -0
- package/icons/format_color_text.svg +1 -0
- package/icons/format_h1.svg +1 -0
- package/icons/format_h2.svg +1 -0
- package/icons/format_h3.svg +1 -0
- package/icons/format_h4.svg +1 -0
- package/icons/format_h5.svg +1 -0
- package/icons/format_h6.svg +1 -0
- package/icons/format_italic.svg +1 -0
- package/icons/format_list_bulleted.svg +1 -0
- package/icons/format_list_numbered.svg +1 -0
- package/icons/format_paragraph.svg +1 -0
- package/icons/format_underlined.svg +1 -0
- package/icons/help.svg +1 -0
- package/icons/key.svg +1 -0
- package/icons/link.svg +1 -0
- package/icons/login.svg +1 -0
- package/icons/logout.svg +1 -0
- package/icons/more_vert.svg +1 -0
- package/icons/strikethrough_s.svg +1 -0
- package/icons/table.svg +1 -0
- package/icons/wysiwyg.svg +1 -0
- package/package.json +6 -5
- package/scripts/build.js +0 -7
- package/scripts/getIcon.js +52 -0
- package/src/components/Accordion.js +1 -1
- package/src/components/ContentSlider.js +2 -2
- package/src/components/Dialog.js +25 -10
- package/src/components/HtmlEditor.js +1548 -0
- package/src/components/Icon.js +64 -5
- package/src/components/Main.js +86 -0
- package/src/components/PhotoViewer.js +2 -2
- package/src/components/ShadowComponent.js +0 -1
- package/src/components/ShowMore.js +8 -8
- package/src/components/SideMenu.js +10 -0
- package/src/components/SidePanel.js +497 -0
- package/src/components/Table.js +1 -1
- package/src/components/htmlEditorControls/AlignCenter.js +65 -0
- package/src/components/htmlEditorControls/AlignJustify.js +65 -0
- package/src/components/htmlEditorControls/AlignLeft.js +65 -0
- package/src/components/htmlEditorControls/AlignRight.js +65 -0
- package/src/components/htmlEditorControls/Bold.js +65 -0
- package/src/components/htmlEditorControls/BulletList.js +65 -0
- package/src/components/htmlEditorControls/CharacterCount.js +75 -0
- package/src/components/htmlEditorControls/ClearFormatting.js +65 -0
- package/src/components/htmlEditorControls/CodeBlock.js +72 -0
- package/src/components/htmlEditorControls/ControlGroup.js +95 -0
- package/src/components/htmlEditorControls/ControlSpacer.js +23 -0
- package/src/components/htmlEditorControls/CreateLink.js +121 -0
- package/src/components/htmlEditorControls/DropdownControl.js +149 -0
- package/src/components/htmlEditorControls/FormatBlock.js +108 -0
- package/src/components/htmlEditorControls/HtmlEditorControl.js +126 -0
- package/src/components/htmlEditorControls/InlineCode.js +77 -0
- package/src/components/htmlEditorControls/InsertTable.js +171 -0
- package/src/components/htmlEditorControls/Italic.js +65 -0
- package/src/components/htmlEditorControls/Mode.js +66 -0
- package/src/components/htmlEditorControls/NumberList.js +65 -0
- package/src/components/htmlEditorControls/Strikethrough.js +65 -0
- package/src/components/htmlEditorControls/TextBackgroundColor.js +195 -0
- package/src/components/htmlEditorControls/TextColor.js +195 -0
- package/src/components/htmlEditorControls/Underline.js +65 -0
- package/src/components/htmlEditorControls/WordCount.js +76 -0
- package/src/components/tableControls/FirstPage.js +1 -1
- package/src/components/tableControls/LastPage.js +1 -1
- package/src/components/tableControls/NextPage.js +1 -1
- package/src/components/tableControls/PrevPage.js +1 -1
- package/src/utils/formatCode.js +87 -0
- package/src/utils/theme.js +22 -9
- package/tests/components/Icon.browser-test.js +205 -0
- package/tests/components/Main.browser-test.js +406 -0
- package/tests/components/SidePanel.browser-test.js +520 -0
- package/tests/components/tableControls/PaginationControls.browser-test.js +10 -10
- package/.github/workflows/publish-major.yml +0 -39
- package/.github/workflows/publish-minor.yml +0 -39
- package/.github/workflows/publish-patch.yml +0 -45
- package/dist/kempo-vars.css +0 -1
- package/docs/icons/arrow-back.svg +0 -1
- package/docs/icons/arrow-down-double.svg +0 -1
- package/docs/icons/arrow-down.svg +0 -1
- package/docs/icons/arrow-up-double.svg +0 -1
- package/docs/icons/arrow-up.svg +0 -1
- package/docs/icons/chevron-left.svg +0 -1
- package/docs/src/kempo-vars.css +0 -1
- package/icons/arrow-back.svg +0 -1
- package/icons/arrow-down-double.svg +0 -1
- package/icons/arrow-down.svg +0 -1
- package/icons/arrow-up-double.svg +0 -1
- package/icons/arrow-up.svg +0 -1
- package/icons/chevron-left.svg +0 -1
- package/src/kempo-vars.css +0 -1
- /package/docs/icons/{arrow-forward.svg → arrow.svg} +0 -0
- /package/docs/icons/{chevron-right.svg → chevron.svg} +0 -0
- /package/icons/{arrow-forward.svg → arrow.svg} +0 -0
- /package/icons/{chevron-right.svg → chevron.svg} +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import ShadowComponent from"./ShadowComponent.js";import{html,css,nothing}from"../lit-all.min.js";import"./Icon.js";class SidePanel extends ShadowComponent{static properties={collapsed:{type:Boolean,reflect:!0},side:{type:String,reflect:!0}};constructor(){super(),this.collapsed=!1,this.side="left"}toggleClick=()=>this.toggle();updated(e){if(super.updated(e),e.has("collapsed")){const e=this.collapsed?"collapse":"expand";this.dispatchEvent(new CustomEvent(e)),this.dispatchEvent(new CustomEvent("change",{detail:e})),window.dispatchEvent(new CustomEvent("side-panel-change",{detail:{collapsed:this.collapsed,width:this.collapsed?"3.5rem":"16rem",side:this.side}}))}}expand=()=>this.collapsed=!1;collapse=()=>this.collapsed=!0;toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("toggle"))}render(){return html`
|
|
2
|
+
<div id="header">
|
|
3
|
+
<slot name="logo"></slot>
|
|
4
|
+
<button id="toggle" @click=${this.toggleClick} aria-label="${this.collapsed?"Expand panel":"Collapse panel"}">
|
|
5
|
+
<k-icon name="arrow-line" direction="${this.collapsed?"right":"left"}"></k-icon>
|
|
6
|
+
</button>
|
|
7
|
+
</div>
|
|
8
|
+
<div id="content">
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</div>
|
|
11
|
+
`}static styles=css`
|
|
12
|
+
:host {
|
|
13
|
+
--bg: var(--c_bg);
|
|
14
|
+
--width-expanded: 16rem;
|
|
15
|
+
--transition-duration: var(--animation_ms, 256ms);
|
|
16
|
+
display: block;
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
height: 100vh;
|
|
21
|
+
width: var(--width-expanded);
|
|
22
|
+
transition: width var(--transition-duration);
|
|
23
|
+
background: var(--bg);
|
|
24
|
+
border-right: 1px solid var(--c_border);
|
|
25
|
+
z-index: 1000;
|
|
26
|
+
}
|
|
27
|
+
:host([collapsed]) {
|
|
28
|
+
width: auto;
|
|
29
|
+
}
|
|
30
|
+
:host([side="right"]) {
|
|
31
|
+
left: auto;
|
|
32
|
+
right: 0;
|
|
33
|
+
border-right: none;
|
|
34
|
+
border-left: 1px solid var(--c_border);
|
|
35
|
+
}
|
|
36
|
+
#header {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: flex-end;
|
|
40
|
+
gap: var(--spacer_h);
|
|
41
|
+
padding: var(--spacer_h);
|
|
42
|
+
border-bottom: 1px solid var(--c_border);
|
|
43
|
+
}
|
|
44
|
+
::slotted([slot="logo"]) {
|
|
45
|
+
margin-right: auto;
|
|
46
|
+
}
|
|
47
|
+
::slotted([slot="logo"]) {
|
|
48
|
+
flex: 1;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
opacity: 1;
|
|
51
|
+
transition: opacity var(--transition-duration);
|
|
52
|
+
}
|
|
53
|
+
:host([collapsed]) ::slotted([slot="logo"]) {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
#toggle {
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
width: 2rem;
|
|
59
|
+
height: 2rem;
|
|
60
|
+
border: none;
|
|
61
|
+
background: transparent;
|
|
62
|
+
color: var(--c_text);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
border-radius: var(--radius);
|
|
68
|
+
}
|
|
69
|
+
#toggle:hover {
|
|
70
|
+
background: var(--c_bg_hover);
|
|
71
|
+
}
|
|
72
|
+
#content {
|
|
73
|
+
height: calc(100% - 3rem);
|
|
74
|
+
overflow-y: auto;
|
|
75
|
+
overflow-x: hidden;
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
}
|
|
79
|
+
:host([collapsed]) #content {
|
|
80
|
+
align-items: flex-start;
|
|
81
|
+
}
|
|
82
|
+
:host(:not([collapsed])) #content {
|
|
83
|
+
/* scrollbar-gutter: stable; */
|
|
84
|
+
}
|
|
85
|
+
`}class SidePanelItem extends ShadowComponent{static properties={icon:{type:String},href:{type:String},active:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0},"no-expand":{type:Boolean,attribute:"no-expand"},"hide-when-collapsed":{type:Boolean,attribute:"hide-when-collapsed"}};constructor(){super(),this.icon="",this.href="#",this.active=!1,this.collapsed=!1,this["no-expand"]=!1,this["hide-when-collapsed"]=!1}connectedCallback(){super.connectedCallback(),this.panel=this.closest("k-side-panel"),this.panel&&(this.collapsed=this.panel.collapsed,this.panel.addEventListener("collapse",this.handleCollapse),this.panel.addEventListener("expand",this.handleExpand))}disconnectedCallback(){super.disconnectedCallback(),this.panel&&(this.panel.removeEventListener("collapse",this.handleCollapse),this.panel.removeEventListener("expand",this.handleExpand))}handleCollapse=()=>{this.collapsed=!0,this.requestUpdate()};handleExpand=()=>{this.collapsed=!1,this.requestUpdate()};handleClick=e=>{this.collapsed&&!this["no-expand"]&&this.panel&&(e.preventDefault(),this.panel.expand())};render(){return html`
|
|
86
|
+
<a href="${this.href}" class="item ${this.active?"active bg-primary":""}" @click=${this.handleClick}>
|
|
87
|
+
${this.icon?html`<k-icon name="${this.icon}"></k-icon>`:this.collapsed?html`<k-icon name="dot"></k-icon>`:nothing}
|
|
88
|
+
${this.collapsed?nothing:html`<span class="label"><slot></slot></span>`}
|
|
89
|
+
</a>
|
|
90
|
+
`}static styles=css`
|
|
91
|
+
:host {
|
|
92
|
+
display: block;
|
|
93
|
+
}
|
|
94
|
+
:host([collapsed][hide-when-collapsed]) {
|
|
95
|
+
display: none;
|
|
96
|
+
}
|
|
97
|
+
.item {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: var(--spacer_h);
|
|
101
|
+
padding: var(--spacer_h);
|
|
102
|
+
color: var(--c_text);
|
|
103
|
+
text-decoration: none;
|
|
104
|
+
border-radius: var(--radius);
|
|
105
|
+
margin: 0 var(--spacer_h);
|
|
106
|
+
transition: background var(--animation_ms), color var(--animation_ms);
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
}
|
|
109
|
+
:host([collapsed]) .item {
|
|
110
|
+
}
|
|
111
|
+
.item:hover {
|
|
112
|
+
background: var(--c_bg_hover);
|
|
113
|
+
}
|
|
114
|
+
.item.active {
|
|
115
|
+
color: var(--tc_on_primary);
|
|
116
|
+
}
|
|
117
|
+
.item.active:hover {
|
|
118
|
+
background: var(--c_primary);
|
|
119
|
+
filter: brightness(1.1);
|
|
120
|
+
}
|
|
121
|
+
k-icon {
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
}
|
|
124
|
+
.label {
|
|
125
|
+
min-width: 0;
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
text-overflow: ellipsis;
|
|
128
|
+
}
|
|
129
|
+
`}class SidePanelLabel extends ShadowComponent{static properties={collapsed:{type:Boolean,reflect:!0}};constructor(){super(),this.collapsed=!1}connectedCallback(){super.connectedCallback(),this.panel=this.closest("k-side-panel"),this.panel&&(this.collapsed=this.panel.collapsed,this.panel.addEventListener("collapse",this.handleCollapse),this.panel.addEventListener("expand",this.handleExpand))}disconnectedCallback(){super.disconnectedCallback(),this.panel&&(this.panel.removeEventListener("collapse",this.handleCollapse),this.panel.removeEventListener("expand",this.handleExpand))}handleCollapse=()=>{this.collapsed=!0,this.requestUpdate()};handleExpand=()=>{this.collapsed=!1,this.requestUpdate()};render(){return this.collapsed?html`<hr>`:html`<div class="label"><slot></slot></div>`}static styles=css`
|
|
130
|
+
:host {
|
|
131
|
+
display: block;
|
|
132
|
+
margin: var(--spacer_h) 0;
|
|
133
|
+
}
|
|
134
|
+
:host([collapsed]) {
|
|
135
|
+
margin: 0 var(--spacer_h);
|
|
136
|
+
align-self: stretch;
|
|
137
|
+
}
|
|
138
|
+
.label {
|
|
139
|
+
padding: 0 var(--spacer);
|
|
140
|
+
font-size: 0.75rem;
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
text-transform: uppercase;
|
|
143
|
+
color: var(--c_text_muted);
|
|
144
|
+
letter-spacing: 0.05em;
|
|
145
|
+
}
|
|
146
|
+
hr {
|
|
147
|
+
border: none;
|
|
148
|
+
border-top: 1px solid var(--c_border);
|
|
149
|
+
margin: var(--spacer_h) var(--spacer);
|
|
150
|
+
}
|
|
151
|
+
:host([collapsed]) hr {
|
|
152
|
+
margin: var(--spacer_h) 0;
|
|
153
|
+
}
|
|
154
|
+
`}class SidePanelMenu extends ShadowComponent{static properties={icon:{type:String},label:{type:String},open:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0},"no-expand":{type:Boolean,attribute:"no-expand"},"hide-when-collapsed":{type:Boolean,attribute:"hide-when-collapsed"}};constructor(){super(),this.icon="",this.label="",this.open=!1,this.collapsed=!1,this["no-expand"]=!1,this["hide-when-collapsed"]=!1}connectedCallback(){super.connectedCallback(),this.panel=this.closest("k-side-panel"),this.panel&&(this.collapsed=this.panel.collapsed,this.panel.addEventListener("collapse",this.handleCollapse),this.panel.addEventListener("expand",this.handleExpand))}disconnectedCallback(){super.disconnectedCallback(),this.panel&&(this.panel.removeEventListener("collapse",this.handleCollapse),this.panel.removeEventListener("expand",this.handleExpand))}handleCollapse=()=>{this.collapsed=!0,this.open=!1,this.requestUpdate()};handleExpand=()=>{this.collapsed=!1,this.requestUpdate()};toggleMenu=()=>{this.collapsed&&!this["no-expand"]&&this.panel?this.panel.expand():this.collapsed||(this.open=!this.open)};render(){return html`
|
|
155
|
+
<div class="menu-container">
|
|
156
|
+
<button class="no-btn menu-header ${this.open?"open":""}" @click=${this.toggleMenu}>
|
|
157
|
+
${this.icon?html`<k-icon name="${this.icon}"></k-icon>`:this.collapsed?html`<k-icon name="dot"></k-icon>`:nothing}
|
|
158
|
+
${this.collapsed?nothing:html`<span class="label">${this.label}</span>`}
|
|
159
|
+
${this.collapsed?nothing:html`<k-icon class="chevron" name="chevron" direction="${this.open?"down":"right"}"></k-icon>`}
|
|
160
|
+
</button>
|
|
161
|
+
<div class="menu-content ${this.open&&!this.collapsed?"open":""}">
|
|
162
|
+
<slot></slot>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
`}static styles=css`
|
|
166
|
+
:host {
|
|
167
|
+
display: block;
|
|
168
|
+
}
|
|
169
|
+
:host([collapsed][hide-when-collapsed]) {
|
|
170
|
+
display: none;
|
|
171
|
+
}
|
|
172
|
+
.menu-container {
|
|
173
|
+
margin: 0;
|
|
174
|
+
}
|
|
175
|
+
.menu-header {
|
|
176
|
+
display: flex !important;
|
|
177
|
+
align-items: center;
|
|
178
|
+
gap: var(--spacer_h);
|
|
179
|
+
padding-top: var(--spacer_h) !important;
|
|
180
|
+
padding-bottom: var(--spacer_h) !important;
|
|
181
|
+
padding-left: var(--spacer_h) !important;
|
|
182
|
+
padding-right: var(--spacer_h) !important;
|
|
183
|
+
color: var(--c_text);
|
|
184
|
+
background: transparent;
|
|
185
|
+
border: none;
|
|
186
|
+
border-radius: var(--radius);
|
|
187
|
+
margin: 0 var(--spacer_h);
|
|
188
|
+
width: calc(100% - var(--spacer));
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
text-align: left;
|
|
191
|
+
white-space: nowrap;
|
|
192
|
+
transition: background var(--animation_ms);
|
|
193
|
+
}
|
|
194
|
+
:host([collapsed]) .menu-header {
|
|
195
|
+
width: auto;
|
|
196
|
+
}
|
|
197
|
+
.menu-header:hover {
|
|
198
|
+
background: var(--c_bg_hover);
|
|
199
|
+
}
|
|
200
|
+
k-icon {
|
|
201
|
+
flex-shrink: 0;
|
|
202
|
+
}
|
|
203
|
+
.label {
|
|
204
|
+
flex: 1;
|
|
205
|
+
min-width: 0;
|
|
206
|
+
overflow: hidden;
|
|
207
|
+
text-overflow: ellipsis;
|
|
208
|
+
}
|
|
209
|
+
.chevron {
|
|
210
|
+
transition: transform var(--animation_ms);
|
|
211
|
+
}
|
|
212
|
+
.menu-content {
|
|
213
|
+
max-height: 0;
|
|
214
|
+
overflow: hidden;
|
|
215
|
+
transition: max-height var(--animation_ms);
|
|
216
|
+
padding-left: calc(var(--spacer_h) * 2);
|
|
217
|
+
}
|
|
218
|
+
:host([collapsed]) .menu-content {
|
|
219
|
+
padding-left: 0;
|
|
220
|
+
}
|
|
221
|
+
.menu-content.open {
|
|
222
|
+
max-height: 500px;
|
|
223
|
+
}
|
|
224
|
+
::slotted(*) {
|
|
225
|
+
margin: 0.25rem 0;
|
|
226
|
+
}
|
|
227
|
+
`}class SidePanelSpacer extends ShadowComponent{render(){return html`<div class="spacer"></div>`}static styles=css`
|
|
228
|
+
:host {
|
|
229
|
+
display: block;
|
|
230
|
+
flex: 1;
|
|
231
|
+
}
|
|
232
|
+
.spacer {
|
|
233
|
+
height: 100%;
|
|
234
|
+
}
|
|
235
|
+
`}customElements.define("k-side-panel",SidePanel),customElements.define("k-side-panel-item",SidePanelItem),customElements.define("k-side-panel-label",SidePanelLabel),customElements.define("k-side-panel-menu",SidePanelMenu),customElements.define("k-side-panel-spacer",SidePanelSpacer);export default SidePanel;
|
package/dist/components/Table.js
CHANGED
|
@@ -15,7 +15,7 @@ import{html,css,unsafeStatic,literal}from"../lit-all.min.js";import ShadowCompon
|
|
|
15
15
|
@click=${this.enableSorting?()=>this.handleFieldClick(t):null}
|
|
16
16
|
>
|
|
17
17
|
${s}
|
|
18
|
-
${o?html`<k-icon name="${r.asc?"
|
|
18
|
+
${o?html`<k-icon name="arrow" direction="${r.asc?"down":"up"}" class="icon-sort"></k-icon>`:""}
|
|
19
19
|
</div>
|
|
20
20
|
`)}),this.hasAfterControls()&&e.push(html`
|
|
21
21
|
<div class="field cell field-after-controls" style="width: ${this.columnSizes.afterControls}px"></div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class AlignCenter extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.alignCenter()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_align_center"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-align-center",AlignCenter);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class AlignJustify extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.alignJustify()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_align_justify"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-align-justify",AlignJustify);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class AlignLeft extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.alignLeft()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_align_left"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-align-left",AlignLeft);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class AlignRight extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.alignRight()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_align_right"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-align-right",AlignRight);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Bold extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.bold()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_bold"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-bold",Bold);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class BulletList extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.unorderedList()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_list_bulleted"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-bullet-list",BulletList);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";export default class CharacterCount extends HtmlEditorControl{static properties={count:{type:Number,state:!0}};constructor(){super(),this.count=0}connectedCallback(){super.connectedCallback(),this.editor&&(this.editor.addEventListener("ready",()=>{this.updateCount()}),this.editor.addEventListener("change",()=>{this.updateCount()}),setTimeout(()=>this.updateCount(),0))}updateCount=()=>{if(!this.editor)return;const t=(new DOMParser).parseFromString(this.editor.getValue(),"text/html").body.innerText||"";this.count=t.length};render(){return html`
|
|
2
|
+
<span class="character-count">
|
|
3
|
+
<slot name="label">Characters:</slot> ${this.count}
|
|
4
|
+
</span>
|
|
5
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: 0 0.5rem;
|
|
10
|
+
font-size: 0.875rem;
|
|
11
|
+
color: var(--text-color-secondary, #666);
|
|
12
|
+
}
|
|
13
|
+
.character-count {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 0.25rem;
|
|
17
|
+
}
|
|
18
|
+
`]}customElements.define("k-hec-character-count",CharacterCount);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class ClearFormatting extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.removeFormat()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_clear"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-clear-formatting",ClearFormatting);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class CodeBlock extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleMouseDown=t=>{const o=window.getSelection()?.toString();t.preventDefault(),t.stopPropagation(),this.editor&&(o?this.editor.wrapSelection("<pre>","</pre>",o):this.editor.formatBlock("pre"))};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @mousedown="${this.handleMouseDown}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="code_blocks"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-code-block",CodeBlock);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ShadowComponent from"../ShadowComponent.js";import{html,css}from"../../lit-all.min.js";export default class ControlGroup extends ShadowComponent{static properties={editorMode:{type:String,state:!0},hidden:{type:Boolean,reflect:!0}};constructor(){super()}connectedCallback(){super.connectedCallback(),this.hasAttribute("class")||this.setAttribute("class","b r mq"),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}get editor(){return this.closest("k-html-editor")}updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode,this.requestUpdate())}hasVisibleChildren(){return Array.from(this.children).filter(t=>t.tagName.startsWith("K-HEC-")&&"K-HEC-SPACER"!==t.tagName).some(t=>{if(!1===t.hidden||void 0===t.hidden){return"none"!==window.getComputedStyle(t).display}return!1})}static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host([hidden]) {
|
|
7
|
+
display: none !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
::slotted(*) {
|
|
11
|
+
margin-top: -1px;
|
|
12
|
+
margin-bottom: -1px;
|
|
13
|
+
}
|
|
14
|
+
`;render(){return html`<slot></slot>`}updated(){super.updated(),requestAnimationFrame(()=>{this.hidden=!this.hasVisibleChildren()})}}customElements.define("k-hec-group",ControlGroup);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ShadowComponent from"../ShadowComponent.js";import{html,css}from"../../lit-all.min.js";export default class ControlSpacer extends ShadowComponent{static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex: 1;
|
|
5
|
+
}
|
|
6
|
+
`;render(){return html``}}customElements.define("k-hec-spacer",ControlSpacer);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";import Dialog from"../Dialog.js";export default class CreateLink extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};constructor(){super()}connectedCallback(){super.connectedCallback(),this.editor&&(this.editorMode=this.editor.mode,this.editor?.addEventListener("mode-changed",()=>{this.editor&&(this.editorMode=this.editor.mode)}))}handleMouseDown=t=>{if(!this.editor)return;t.preventDefault(),t.stopPropagation();const e=this.editor.selection?.text||"",o=document.createElement("input");o.type="text",o.placeholder="https://example.com",o.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const i=document.createElement("input");i.type="text",i.placeholder="Enter link text",i.value=e,i.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const n=document.createElement("div");n.className="p",n.style.cssText="display: flex; flex-direction: column; gap: 1rem;",n.innerHTML='\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">URL</label>\n\t\t\t</div>\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">Link Text</label>\n\t\t\t</div>\n\t\t',n.children[0].appendChild(o),n.children[1].appendChild(i),Dialog.create(n,{title:"Create Link",cancelText:"Cancel",confirmText:"Insert Link",confirmClasses:"success ml",confirmAction:t=>{const e=o.value.trim(),n=i.value.trim();if(!e)return void(t.keepDialogOpen=!0);const l=document.createElement("a");l.href=e,l.textContent=n||e,this.editor.selection?this.editor.replaceSelectionWithElement(l,!0):this.editor.insertElementAtCursor(l,!0)}})};render(){return this.hidden="code"===this.editorMode,html`
|
|
2
|
+
<button
|
|
3
|
+
class="${this.buttonClasses}"
|
|
4
|
+
@mousedown="${this.handleMouseDown}"
|
|
5
|
+
>
|
|
6
|
+
<slot name="icon">
|
|
7
|
+
<k-icon name="link"></k-icon>
|
|
8
|
+
</slot>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</button>
|
|
11
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
`]}customElements.define("k-hec-create-link",CreateLink);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Dropdown.js";import"../Icon.js";export default class DropdownControl extends HtmlEditorControl{static properties={opened:{type:Boolean,reflect:!0},editorMode:{type:String,state:!0}};constructor(){super(),this.opened=!1}connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}updated(t){super.updated(t),t.has("editorMode")&&requestAnimationFrame(()=>{this.hidden="code"===this.editorMode&&!this.hasVisibleChildren()})}updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}hasVisibleChildren(){return Array.from(this.children).filter(t=>!t.hasAttribute("slot")).some(t=>{if(!1===t.hidden||void 0===t.hidden){return"none"!==window.getComputedStyle(t).display}return!1})}static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
k-dropdown {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Override fixed sizing for dropdown trigger */
|
|
11
|
+
button[slot="trigger"] {
|
|
12
|
+
width: auto !important;
|
|
13
|
+
height: auto !important;
|
|
14
|
+
min-width: 40px;
|
|
15
|
+
min-height: 40px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Style slotted items (not icon or label) */
|
|
19
|
+
::slotted(:not([slot="icon"]):not([slot="label"])) {
|
|
20
|
+
display: block !important;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
::slotted(:not([slot="icon"]):not([slot="label"])) .icon-btn,
|
|
24
|
+
::slotted(:not([slot="icon"]):not([slot="label"])) button {
|
|
25
|
+
display: flex !important;
|
|
26
|
+
width: 100% !important;
|
|
27
|
+
height: auto !important;
|
|
28
|
+
justify-content: flex-start !important;
|
|
29
|
+
padding: 0.5rem 0.75rem !important;
|
|
30
|
+
margin: 0 !important;
|
|
31
|
+
border: none !important;
|
|
32
|
+
border-radius: 0 !important;
|
|
33
|
+
border-bottom: 1px solid var(--c_border) !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::slotted(:not([slot="icon"]):not([slot="label"]):last-of-type) .icon-btn,
|
|
37
|
+
::slotted(:not([slot="icon"]):not([slot="label"]):last-of-type) button {
|
|
38
|
+
border-bottom: none !important;
|
|
39
|
+
}
|
|
40
|
+
`];handleToggle=()=>{this.opened=!this.opened};handleOpened=()=>{this.opened=!0};handleClosed=()=>{this.opened=!1};render(){return html`
|
|
41
|
+
<k-dropdown
|
|
42
|
+
?opened=${this.opened}
|
|
43
|
+
@opened=${this.handleOpened}
|
|
44
|
+
@closed=${this.handleClosed}
|
|
45
|
+
>
|
|
46
|
+
<button
|
|
47
|
+
slot="trigger"
|
|
48
|
+
class="${this.buttonClasses}"
|
|
49
|
+
>
|
|
50
|
+
<slot name="icon">
|
|
51
|
+
<k-icon name="arrow_drop_down"></k-icon>
|
|
52
|
+
</slot>
|
|
53
|
+
<slot name="label"></slot>
|
|
54
|
+
</button>
|
|
55
|
+
<slot></slot>
|
|
56
|
+
</k-dropdown>
|
|
57
|
+
`}}customElements.define("k-hec-dropdown",DropdownControl);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class FormatBlock extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0},tag:{type:String},label:{type:String}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];constructor(){super(),this.tag="p",this.label=""}connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.formatBlock(this.tag)};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){this.hidden="code"===this.editorMode;this.label||this.getDefaultLabel();const t=this.getDefaultIcon();return html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="${t}"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}getDefaultLabel(){return{h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",p:"Paragraph"}[this.tag]||this.tag.toUpperCase()}getDefaultIcon(){return{h1:"format_h1",h2:"format_h2",h3:"format_h3",h4:"format_h4",h5:"format_h5",h6:"format_h6",p:"format_paragraph"}[this.tag]||"format_paragraph"}}customElements.define("k-hec-format-block",FormatBlock);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ShadowComponent from"../ShadowComponent.js";import{html,css}from"../../lit-all.min.js";export default class HtmlEditorControl extends ShadowComponent{static properties={btnClass:{type:String,attribute:"btn-class"},groupBtnClass:{type:String,attribute:"group-btn-class"},groupLastBtnClass:{type:String,attribute:"group-last-btn-class"},hidden:{type:Boolean,reflect:!0}};constructor(){super(),this.btnClass="b r mq ph",this.groupBtnClass="br ph",this.groupLastBtnClass="ph"}get editor(){let t=this.getRootNode();for(;t instanceof ShadowRoot;){const o=t.host,n=o.closest("k-html-editor");if(n)return n;t=o.getRootNode()}return this.closest("k-html-editor")}get isInGroup(){const t=this.parentElement;return t&&"K-HEC-GROUP"===t.tagName}get isInDropdown(){const t=this.parentElement;return t&&"K-HEC-DROPDOWN"===t.tagName}get isLastInGroup(){if(!this.isInGroup)return!1;const t=this.parentElement,o=Array.from(t.children).filter(t=>t.tagName.startsWith("K-HEC-")&&"K-HEC-SPACER"!==t.tagName);return o[o.length-1]===this}get buttonClasses(){let t;return t=this.isInDropdown?"dropdown-item":this.isInGroup?this.isLastInGroup?this.groupLastBtnClass:this.groupBtnClass:this.btnClass,`no-btn icon-btn ${t}`.trim()}static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host([hidden]) {
|
|
7
|
+
display: none !important;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.icon-btn {
|
|
11
|
+
display: inline-flex !important;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
width: 40px;
|
|
15
|
+
height: 40px;
|
|
16
|
+
gap: 0.5rem;
|
|
17
|
+
}
|
|
18
|
+
.icon-btn:disabled {
|
|
19
|
+
opacity: 0.6;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.icon-btn:has(slot:not([name])) {
|
|
23
|
+
width: auto;
|
|
24
|
+
padding-left: 0.75rem;
|
|
25
|
+
padding-right: 0.75rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Styles for controls in dropdown */
|
|
29
|
+
.icon-btn.dropdown-item {
|
|
30
|
+
display: flex !important;
|
|
31
|
+
width: 100% !important;
|
|
32
|
+
height: auto !important;
|
|
33
|
+
justify-content: flex-start !important;
|
|
34
|
+
padding: 0.5rem 0.75rem !important;
|
|
35
|
+
margin: 0 !important;
|
|
36
|
+
border: none !important;
|
|
37
|
+
border-radius: 0 !important;
|
|
38
|
+
border-bottom: 1px solid var(--c_border) !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host(:last-child) .icon-btn.dropdown-item {
|
|
42
|
+
border-bottom: none !important;
|
|
43
|
+
}
|
|
44
|
+
`}customElements.define("k-html-editor-control",HtmlEditorControl);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class InlineCode extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleMouseDown=t=>{if(!this.editor)return;t.preventDefault(),t.stopPropagation();const e=document.createElement("code"),o=this.editor.getValueWithSelectionMarkers();o.hasSelection?(e.textContent=o.selectedText,this.editor.replaceSelectionWithElement(e,!0)):(e.textContent="",this.editor.insertElementAtCursor(e,!0))};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @mousedown="${this.handleMouseDown}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="code_blocks"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-inline-code",InlineCode);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";import Dialog from"../Dialog.js";export default class InsertTable extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};constructor(){super()}connectedCallback(){super.connectedCallback(),this.editor&&(this.editorMode=this.editor.mode,this.editor?.addEventListener("mode-changed",()=>{this.editor&&(this.editorMode=this.editor.mode)}))}handleMouseDown=e=>{if(!this.editor)return;e.preventDefault(),e.stopPropagation();const t=this.editor.shadowRoot.getSelection()||window.getSelection();let o=null,l=null;if(t.rangeCount){let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement),o=e.closest("table")}const n=!!o;let r=3,s=3,i=!0;if(n){const e=o.querySelector("thead"),t=o.querySelector("tbody"),n=!!e;if(l=[],n){const t=e.querySelector("tr"),o=Array.from(t.cells).map(e=>e.innerHTML);l.push(o),s=o.length}const d=t.querySelectorAll("tr");d.forEach(e=>{const t=Array.from(e.cells).map(e=>e.innerHTML);l.push(t),t.length>s&&(s=t.length)}),r=d.length,i=n,o.remove()}const d=document.createElement("input");d.type="number",d.min="1",d.max="20",d.value=r.toString(),d.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const c=document.createElement("input");c.type="number",c.min="1",c.max="10",c.value=s.toString(),c.style.cssText="padding: 0.5rem; border: 1px solid var(--border-color, #ccc); border-radius: 4px; font-size: 1rem;";const a=document.createElement("input");a.type="checkbox",a.checked=i,a.id="table-headers-checkbox";const m=document.createElement("div");m.className="p",m.style.cssText="display: flex; flex-direction: column; gap: 1rem;",m.innerHTML='\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">Rows</label>\n\t\t\t</div>\n\t\t\t<div style="display: flex; flex-direction: column; gap: 0.5rem;">\n\t\t\t\t<label style="font-weight: bold;">Columns</label>\n\t\t\t</div>\n\t\t\t<div style="display: flex; align-items: center; gap: 0.5rem;">\n\t\t\t\t<label for="table-headers-checkbox" style="font-weight: bold;">Include Headers</label>\n\t\t\t</div>\n\t\t',m.children[0].appendChild(d),m.children[1].appendChild(c),m.children[2].insertBefore(a,m.children[2].firstChild),Dialog.create(m,{title:n?"Edit Table":"Insert Table",cancelText:"Cancel",confirmText:n?"Update Table":"Insert Table",confirmClasses:"success",confirmAction:()=>{const e=parseInt(d.value)||3,t=parseInt(c.value)||3,o=a.checked;this.editor.insertTable(e,t,o,l)}})};render(){return this.hidden="code"===this.editorMode,html`
|
|
2
|
+
<button
|
|
3
|
+
class="${this.buttonClasses}"
|
|
4
|
+
@mousedown="${this.handleMouseDown}"
|
|
5
|
+
>
|
|
6
|
+
<slot name="icon">
|
|
7
|
+
<k-icon name="table"></k-icon>
|
|
8
|
+
</slot>
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</button>
|
|
11
|
+
`}static styles=[HtmlEditorControl.styles,css`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
`]}customElements.define("k-hec-insert-table",InsertTable);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Italic extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.italic()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_italic"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-italic",Italic);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Mode extends HtmlEditorControl{static properties={mode:{type:String,reflect:!0}};connectedCallback(){super.connectedCallback(),this.updateMode(),this.editor?.addEventListener("mode-changed",()=>this.updateMode())}handleClick=()=>{this.editor&&(this.editor.mode="visual"===this.editor.mode?"code":"visual")};updateMode(){this.editor&&(this.mode=this.editor.mode)}static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];render(){const t="code"===this.mode?`${this.buttonClasses} bg-primary`:this.buttonClasses;return html`
|
|
6
|
+
<button class="${t}" @click="${this.handleClick}">
|
|
7
|
+
<k-icon name="code"></k-icon>
|
|
8
|
+
</button>
|
|
9
|
+
`}}customElements.define("k-hec-mode",Mode);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class NumberList extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.orderedList()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="format_list_numbered"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-number-list",NumberList);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HtmlEditorControl from"./HtmlEditorControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Strikethrough extends HtmlEditorControl{static properties={editorMode:{type:String,state:!0}};static styles=[HtmlEditorControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
`];connectedCallback(){super.connectedCallback(),this.updateEditorMode(),this.editor?.addEventListener("mode-changed",()=>this.updateEditorMode())}handleClick=()=>{this.editor&&this.editor.strikethrough()};updateEditorMode(){this.editor&&(this.editorMode=this.editor.mode)}render(){return this.hidden="code"===this.editorMode,html`
|
|
6
|
+
<button class="${this.buttonClasses}" @click="${this.handleClick}">
|
|
7
|
+
<slot name="icon">
|
|
8
|
+
<k-icon name="strikethrough_s"></k-icon>
|
|
9
|
+
</slot>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</button>
|
|
12
|
+
`}}customElements.define("k-hec-strikethrough",Strikethrough);
|