bareframe 0.1.2 → 0.1.3
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/README.md +18 -5
- package/dist/bareframe.min.js +33 -17
- package/dist/components/action-list.js +0 -3
- package/dist/components/anchor.js +0 -3
- package/dist/components/bottom-navigation.js +0 -3
- package/dist/components/breadcrumb.js +0 -4
- package/dist/components/button.js +2 -2
- package/dist/components/calendar.js +0 -3
- package/dist/components/canvas.js +0 -3
- package/dist/components/card.js +0 -3
- package/dist/components/carousel.js +0 -3
- package/dist/components/combobox.js +0 -3
- package/dist/components/command-palette.js +0 -3
- package/dist/components/countdown.js +0 -3
- package/dist/components/data-grid.js +0 -3
- package/dist/components/date-picker.js +0 -3
- package/dist/components/date-range-picker.js +0 -3
- package/dist/components/dialog.js +0 -3
- package/dist/components/drawer.js +0 -3
- package/dist/components/dropdown.js +0 -3
- package/dist/components/edge.js +0 -3
- package/dist/components/editor.css +111 -0
- package/dist/components/editor.js +173 -0
- package/dist/components/empty-state.js +0 -3
- package/dist/components/error-summary.js +0 -3
- package/dist/components/fab.js +0 -3
- package/dist/components/filter-bar.js +0 -3
- package/dist/components/form-field.js +0 -3
- package/dist/components/grid.js +0 -3
- package/dist/components/hero.js +0 -3
- package/dist/components/icon.js +0 -3
- package/dist/components/image.js +0 -3
- package/dist/components/key-value-list.js +0 -3
- package/dist/components/link.js +0 -3
- package/dist/components/list.js +0 -3
- package/dist/components/loading-indicator.js +0 -3
- package/dist/components/map.js +0 -3
- package/dist/components/menu.js +0 -3
- package/dist/components/message.js +0 -3
- package/dist/components/metric-card.js +0 -3
- package/dist/components/modal.js +0 -3
- package/dist/components/nav.js +0 -3
- package/dist/components/number-field.js +0 -3
- package/dist/components/otp-input.js +0 -3
- package/dist/components/pagination.js +0 -3
- package/dist/components/quick-actions.js +0 -3
- package/dist/components/search.js +0 -3
- package/dist/components/segmented-control.js +0 -3
- package/dist/components/split-button.js +0 -3
- package/dist/components/splitter.js +0 -3
- package/dist/components/stack.js +0 -3
- package/dist/components/tab.js +0 -3
- package/dist/components/table.js +0 -3
- package/dist/components/tag.js +0 -3
- package/dist/components/timeline.js +0 -3
- package/dist/components/toast.js +0 -3
- package/dist/components/toggle.js +0 -3
- package/dist/components/toolbar.js +0 -3
- package/dist/components/tree-view.js +0 -3
- package/dist/components/video-player.js +0 -3
- package/dist/components/virtual-list.js +0 -3
- package/dist/index.js +153 -225
- package/dist/manifest.json +3 -4
- package/package.json +5 -3
- package/dist/components/code-block.css +0 -30
- package/dist/components/code-block.js +0 -31
- package/dist/components/textarea.css +0 -30
- package/dist/components/textarea.js +0 -31
|
@@ -20,9 +20,6 @@ class BfBottomNavigation extends HTMLElement {
|
|
|
20
20
|
root.setAttribute('part', 'root');
|
|
21
21
|
root.innerHTML = '<slot></slot>';
|
|
22
22
|
|
|
23
|
-
if (!this.innerHTML.trim()) {
|
|
24
|
-
root.textContent = 'bottom navigation';
|
|
25
|
-
}
|
|
26
23
|
|
|
27
24
|
this.shadowRoot.replaceChildren(link, root);
|
|
28
25
|
}
|
|
@@ -123,10 +123,6 @@ class BfBreadcrumb extends HTMLElement {
|
|
|
123
123
|
|
|
124
124
|
this._list.replaceChildren();
|
|
125
125
|
if (!items.length) {
|
|
126
|
-
const fallback = document.createElement('li');
|
|
127
|
-
fallback.className = 'item';
|
|
128
|
-
fallback.textContent = 'breadcrumb';
|
|
129
|
-
this._list.append(fallback);
|
|
130
126
|
return;
|
|
131
127
|
}
|
|
132
128
|
|
|
@@ -13,7 +13,7 @@ class BfButton extends HTMLElement {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
this._initialized = true;
|
|
16
|
-
const label = this.getAttribute('label') || '
|
|
16
|
+
const label = this.getAttribute('label') || '';
|
|
17
17
|
const cssUrl = new URL('./button.css', import.meta.url);
|
|
18
18
|
|
|
19
19
|
this.shadowRoot.innerHTML = '';
|
|
@@ -52,7 +52,7 @@ class BfButton extends HTMLElement {
|
|
|
52
52
|
|
|
53
53
|
_onClick() {
|
|
54
54
|
this._applyGroupSelection();
|
|
55
|
-
const label = this.getAttribute('label') || '
|
|
55
|
+
const label = this.getAttribute('label') || '';
|
|
56
56
|
const variant = this.getAttribute('variant') || 'primary';
|
|
57
57
|
this.dispatchEvent(
|
|
58
58
|
new CustomEvent('bf-click', {
|
package/dist/components/card.js
CHANGED
|
@@ -20,9 +20,6 @@ class BfDateRangePicker extends HTMLElement {
|
|
|
20
20
|
root.setAttribute('part', 'root');
|
|
21
21
|
root.innerHTML = '<slot></slot>';
|
|
22
22
|
|
|
23
|
-
if (!this.innerHTML.trim()) {
|
|
24
|
-
root.textContent = 'date range picker';
|
|
25
|
-
}
|
|
26
23
|
|
|
27
24
|
this.shadowRoot.replaceChildren(link, root);
|
|
28
25
|
}
|
|
@@ -32,9 +32,6 @@ class BfDrawer extends HTMLElement {
|
|
|
32
32
|
this._backdrop = root.querySelector('.backdrop');
|
|
33
33
|
this._backdrop.addEventListener('click', this._onBackdropClick);
|
|
34
34
|
|
|
35
|
-
if (!this.textContent?.trim()) {
|
|
36
|
-
this.textContent = 'drawer';
|
|
37
|
-
}
|
|
38
35
|
|
|
39
36
|
this._sync();
|
|
40
37
|
}
|
package/dist/components/edge.js
CHANGED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--bf-editor-font: var(--bf-theme-font-family, inherit);
|
|
3
|
+
--bf-editor-radius: var(--bf-theme-radius-md, 8px);
|
|
4
|
+
--bf-editor-border-width: var(--bf-theme-border-width, 1px);
|
|
5
|
+
--bf-editor-border-style: var(--bf-theme-border-style, solid);
|
|
6
|
+
--bf-editor-border-color: var(--bf-theme-editor-border-color, var(--bf-theme-border-1, #cbd5e1));
|
|
7
|
+
--bf-editor-bg: var(--bf-theme-editor-bg, var(--bf-theme-surface-1, #ffffff));
|
|
8
|
+
--bf-editor-color: var(--bf-theme-editor-color, var(--bf-theme-text-1, #0f172a));
|
|
9
|
+
--bf-editor-muted: var(--bf-theme-text-2, #64748b);
|
|
10
|
+
--bf-editor-code-bg: color-mix(in srgb, var(--bf-editor-bg) 86%, #0f172a 14%);
|
|
11
|
+
--bf-editor-code-color: #e2e8f0;
|
|
12
|
+
|
|
13
|
+
display: block;
|
|
14
|
+
font: var(--bf-editor-font);
|
|
15
|
+
color: var(--bf-editor-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.root {
|
|
19
|
+
background: var(--bf-editor-bg);
|
|
20
|
+
color: var(--bf-editor-color);
|
|
21
|
+
border-width: var(--bf-editor-border-width);
|
|
22
|
+
border-style: var(--bf-editor-border-style);
|
|
23
|
+
border-color: var(--bf-editor-border-color);
|
|
24
|
+
border-radius: var(--bf-editor-radius);
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.toolbar {
|
|
29
|
+
display: none;
|
|
30
|
+
gap: 0.35rem;
|
|
31
|
+
padding: 0.5rem;
|
|
32
|
+
border-bottom: 1px solid var(--bf-editor-border-color);
|
|
33
|
+
background: color-mix(in srgb, var(--bf-editor-bg) 92%, var(--bf-editor-border-color));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.toolbar button {
|
|
37
|
+
border: 1px solid var(--bf-editor-border-color);
|
|
38
|
+
background: var(--bf-editor-bg);
|
|
39
|
+
color: var(--bf-editor-color);
|
|
40
|
+
border-radius: 6px;
|
|
41
|
+
padding: 0.22rem 0.45rem;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
font: inherit;
|
|
44
|
+
font-size: 0.85rem;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.code-wrap {
|
|
48
|
+
display: grid;
|
|
49
|
+
grid-template-columns: auto 1fr;
|
|
50
|
+
min-height: 220px;
|
|
51
|
+
background: var(--bf-editor-code-bg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.line-numbers {
|
|
55
|
+
padding: 0.8rem 0.55rem;
|
|
56
|
+
margin: 0;
|
|
57
|
+
white-space: pre;
|
|
58
|
+
line-height: 1.45;
|
|
59
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
60
|
+
font-size: 0.85rem;
|
|
61
|
+
color: color-mix(in srgb, var(--bf-editor-code-color) 55%, transparent);
|
|
62
|
+
border-right: 1px solid color-mix(in srgb, var(--bf-editor-border-color) 80%, transparent);
|
|
63
|
+
user-select: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.code {
|
|
67
|
+
width: 100%;
|
|
68
|
+
min-height: 220px;
|
|
69
|
+
resize: vertical;
|
|
70
|
+
padding: 0.8rem;
|
|
71
|
+
border: 0;
|
|
72
|
+
outline: 0;
|
|
73
|
+
background: transparent;
|
|
74
|
+
color: var(--bf-editor-code-color);
|
|
75
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
76
|
+
font-size: 0.9rem;
|
|
77
|
+
line-height: 1.45;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.rich {
|
|
81
|
+
display: none;
|
|
82
|
+
min-height: 220px;
|
|
83
|
+
padding: 0.8rem;
|
|
84
|
+
outline: none;
|
|
85
|
+
line-height: 1.5;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.rich:empty::before {
|
|
89
|
+
content: attr(data-placeholder);
|
|
90
|
+
color: var(--bf-editor-muted);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.root[data-variant='richtext'] .toolbar {
|
|
94
|
+
display: flex;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.root[data-variant='richtext'] .code-wrap {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.root[data-variant='richtext'] .rich {
|
|
102
|
+
display: block;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host([disabled]) {
|
|
106
|
+
opacity: 0.72;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
:host([disabled]) .toolbar button {
|
|
110
|
+
cursor: not-allowed;
|
|
111
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
class BfEditor extends HTMLElement {
|
|
2
|
+
static observedAttributes = ['variant', 'code', 'richtext', 'placeholder', 'value', 'disabled'];
|
|
3
|
+
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.attachShadow({ mode: 'open' });
|
|
7
|
+
this._onInput = this._onInput.bind(this);
|
|
8
|
+
this._onToolbarClick = this._onToolbarClick.bind(this);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
if (this._initialized) {
|
|
13
|
+
this._sync();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this._initialized = true;
|
|
17
|
+
|
|
18
|
+
const cssUrl = new URL('./editor.css', import.meta.url);
|
|
19
|
+
const link = document.createElement('link');
|
|
20
|
+
link.rel = 'stylesheet';
|
|
21
|
+
link.href = cssUrl.href;
|
|
22
|
+
|
|
23
|
+
const root = document.createElement('div');
|
|
24
|
+
root.className = 'root';
|
|
25
|
+
root.setAttribute('part', 'root');
|
|
26
|
+
root.innerHTML = `
|
|
27
|
+
<div class="toolbar" part="toolbar">
|
|
28
|
+
<button type="button" data-cmd="bold" title="Bold"><b>B</b></button>
|
|
29
|
+
<button type="button" data-cmd="italic" title="Italic"><i>I</i></button>
|
|
30
|
+
<button type="button" data-cmd="underline" title="Underline"><u>U</u></button>
|
|
31
|
+
<button type="button" data-cmd="insertUnorderedList" title="Bullet List">• List</button>
|
|
32
|
+
<button type="button" data-cmd="insertOrderedList" title="Numbered List">1. List</button>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="code-wrap" part="code-wrap">
|
|
35
|
+
<div class="line-numbers" part="line-numbers"></div>
|
|
36
|
+
<textarea class="code" part="code"></textarea>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="rich" part="rich" contenteditable="true"></div>
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
this.shadowRoot.replaceChildren(link, root);
|
|
43
|
+
this._root = root;
|
|
44
|
+
this._toolbar = root.querySelector('.toolbar');
|
|
45
|
+
this._codeWrap = root.querySelector('.code-wrap');
|
|
46
|
+
this._lineNumbers = root.querySelector('.line-numbers');
|
|
47
|
+
this._code = root.querySelector('.code');
|
|
48
|
+
this._rich = root.querySelector('.rich');
|
|
49
|
+
|
|
50
|
+
this._code.addEventListener('input', this._onInput);
|
|
51
|
+
this._rich.addEventListener('input', this._onInput);
|
|
52
|
+
this._toolbar.addEventListener('click', this._onToolbarClick);
|
|
53
|
+
|
|
54
|
+
this._sync();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
if (!this._code || !this._rich || !this._toolbar) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this._code.removeEventListener('input', this._onInput);
|
|
62
|
+
this._rich.removeEventListener('input', this._onInput);
|
|
63
|
+
this._toolbar.removeEventListener('click', this._onToolbarClick);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
attributeChangedCallback() {
|
|
67
|
+
this._sync();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_variant() {
|
|
71
|
+
const explicit = (this.getAttribute('variant') || '').toLowerCase();
|
|
72
|
+
if (explicit === 'richtext' || this.hasAttribute('richtext')) {
|
|
73
|
+
return 'richtext';
|
|
74
|
+
}
|
|
75
|
+
if (explicit === 'code' || this.hasAttribute('code')) {
|
|
76
|
+
return 'code';
|
|
77
|
+
}
|
|
78
|
+
return 'code';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_sync() {
|
|
82
|
+
if (!this._root || !this._code || !this._rich || !this._toolbar) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const variant = this._variant();
|
|
87
|
+
this._root.dataset.variant = variant;
|
|
88
|
+
|
|
89
|
+
const disabled = this.hasAttribute('disabled');
|
|
90
|
+
this._code.disabled = disabled;
|
|
91
|
+
this._rich.setAttribute('contenteditable', disabled ? 'false' : 'true');
|
|
92
|
+
|
|
93
|
+
const placeholder = this.getAttribute('placeholder') ||
|
|
94
|
+
(variant === 'richtext' ? 'Write rich content…' : 'Write code…');
|
|
95
|
+
this._code.placeholder = placeholder;
|
|
96
|
+
this._rich.dataset.placeholder = placeholder;
|
|
97
|
+
|
|
98
|
+
const value = this.getAttribute('value');
|
|
99
|
+
if (value != null && this._lastSyncedValue !== value) {
|
|
100
|
+
if (variant === 'richtext') {
|
|
101
|
+
this._rich.innerHTML = value;
|
|
102
|
+
} else {
|
|
103
|
+
this._code.value = value;
|
|
104
|
+
this._renderLineNumbers();
|
|
105
|
+
}
|
|
106
|
+
this._lastSyncedValue = value;
|
|
107
|
+
} else if (value == null && !this._hasUserInput) {
|
|
108
|
+
const initial = this.textContent.trim();
|
|
109
|
+
if (initial) {
|
|
110
|
+
if (variant === 'richtext') {
|
|
111
|
+
this._rich.innerHTML = initial;
|
|
112
|
+
} else {
|
|
113
|
+
this._code.value = initial;
|
|
114
|
+
this._renderLineNumbers();
|
|
115
|
+
}
|
|
116
|
+
this._hasUserInput = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (variant === 'code') {
|
|
121
|
+
this._renderLineNumbers();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_onInput() {
|
|
126
|
+
const variant = this._variant();
|
|
127
|
+
this._hasUserInput = true;
|
|
128
|
+
if (variant === 'code') {
|
|
129
|
+
this._renderLineNumbers();
|
|
130
|
+
this.setAttribute('value', this._code.value);
|
|
131
|
+
this._lastSyncedValue = this._code.value;
|
|
132
|
+
this._emitChange(this._code.value, 'code');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.setAttribute('value', this._rich.innerHTML);
|
|
136
|
+
this._lastSyncedValue = this._rich.innerHTML;
|
|
137
|
+
this._emitChange(this._rich.innerHTML, 'richtext');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_renderLineNumbers() {
|
|
141
|
+
const lineCount = Math.max(1, this._code.value.split('\n').length);
|
|
142
|
+
const text = Array.from({ length: lineCount }, (_, i) => String(i + 1)).join('\n');
|
|
143
|
+
this._lineNumbers.textContent = text;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_onToolbarClick(event) {
|
|
147
|
+
const button = event.target instanceof Element
|
|
148
|
+
? event.target.closest('button[data-cmd]')
|
|
149
|
+
: null;
|
|
150
|
+
if (!button || this._variant() !== 'richtext' || this.hasAttribute('disabled')) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const command = button.getAttribute('data-cmd');
|
|
154
|
+
if (!command) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this._rich.focus();
|
|
158
|
+
document.execCommand(command, false);
|
|
159
|
+
this._onInput();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_emitChange(value, mode) {
|
|
163
|
+
this.dispatchEvent(
|
|
164
|
+
new CustomEvent('bf-change', {
|
|
165
|
+
bubbles: true,
|
|
166
|
+
composed: true,
|
|
167
|
+
detail: { value, mode },
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
customElements.define('bf-editor', BfEditor);
|
package/dist/components/fab.js
CHANGED
package/dist/components/grid.js
CHANGED
package/dist/components/hero.js
CHANGED
package/dist/components/icon.js
CHANGED
package/dist/components/image.js
CHANGED
package/dist/components/link.js
CHANGED
package/dist/components/list.js
CHANGED
|
@@ -21,9 +21,6 @@ class BfList extends HTMLElement {
|
|
|
21
21
|
root.setAttribute('part', 'root');
|
|
22
22
|
root.innerHTML = '<slot></slot>';
|
|
23
23
|
|
|
24
|
-
if (!this.innerHTML.trim()) {
|
|
25
|
-
root.textContent = 'list';
|
|
26
|
-
}
|
|
27
24
|
|
|
28
25
|
this.shadowRoot.replaceChildren(link, root);
|
|
29
26
|
this._slot = root.querySelector('slot');
|
|
@@ -20,9 +20,6 @@ class BfLoadingIndicator extends HTMLElement {
|
|
|
20
20
|
root.setAttribute('part', 'root');
|
|
21
21
|
root.innerHTML = '<slot></slot>';
|
|
22
22
|
|
|
23
|
-
if (!this.innerHTML.trim()) {
|
|
24
|
-
root.textContent = 'loading indicator';
|
|
25
|
-
}
|
|
26
23
|
|
|
27
24
|
this.shadowRoot.replaceChildren(link, root);
|
|
28
25
|
}
|
package/dist/components/map.js
CHANGED
package/dist/components/menu.js
CHANGED