bareframe 0.1.0 → 0.1.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/README.md +179 -0
- package/dist/bareframe.min.js +119 -0
- package/dist/components/accordion.js +66 -0
- package/dist/components/autocomplete.css +78 -15
- package/dist/components/autocomplete.js +220 -10
- package/dist/components/avatar.css +129 -17
- package/dist/components/avatar.js +47 -10
- package/dist/components/breadcrumb.css +63 -17
- package/dist/components/breadcrumb.js +140 -5
- package/dist/components/button.css +4 -0
- package/dist/components/button.js +95 -15
- package/dist/components/chart.css +163 -14
- package/dist/components/chart.js +59 -4
- package/dist/components/checkbox.css +43 -1
- package/dist/components/checkbox.js +98 -5
- package/dist/components/dialog.css +95 -0
- package/dist/components/dialog.js +172 -4
- package/dist/components/divider.css +18 -22
- package/dist/components/divider.js +31 -3
- package/dist/components/drawer.css +68 -18
- package/dist/components/drawer.js +84 -4
- package/dist/components/edge.css +54 -0
- package/dist/components/edge.js +55 -0
- package/dist/components/file-upload.css +72 -3
- package/dist/components/file-upload.js +186 -4
- package/dist/components/input.css +59 -0
- package/dist/components/input.js +369 -4
- package/dist/components/list.css +11 -0
- package/dist/components/list.js +45 -0
- package/dist/components/menu.css +20 -0
- package/dist/components/menu.js +144 -0
- package/dist/components/modal.css +30 -17
- package/dist/components/modal.js +68 -4
- package/dist/components/nav.css +39 -0
- package/dist/components/progress.css +196 -0
- package/dist/components/progress.js +304 -0
- package/dist/components/radio.css +35 -1
- package/dist/components/radio.js +86 -5
- package/dist/components/range.css +91 -0
- package/dist/components/range.js +250 -0
- package/dist/components/select.css +35 -1
- package/dist/components/select.js +255 -4
- package/dist/components/skeleton.css +108 -21
- package/dist/components/skeleton.js +57 -4
- package/dist/components/tab.css +9 -1
- package/dist/components/tab.js +66 -1
- package/dist/components/tag.css +36 -3
- package/dist/components/tag.js +32 -0
- package/dist/components/toast.css +113 -0
- package/dist/components/toast.js +265 -4
- package/dist/components/toggle.css +53 -0
- package/dist/components/toggle.js +73 -5
- package/dist/components/wizard.css +79 -14
- package/dist/components/wizard.js +141 -4
- package/dist/index.js +5147 -110
- package/dist/manifest.json +5 -42
- package/dist/themes/aurora.css +47 -0
- package/dist/themes/dark.css +12 -2
- package/dist/themes/desert.css +37 -0
- package/dist/themes/future.css +47 -0
- package/dist/themes/layout.css +191 -0
- package/dist/themes/light.css +12 -0
- package/dist/themes/matrix.css +37 -0
- package/dist/themes/modern.css +64 -0
- package/dist/themes/nature.css +47 -0
- package/dist/themes/nebula.css +37 -0
- package/dist/themes/noir.css +37 -0
- package/dist/themes/oceanic.css +37 -0
- package/dist/themes/retro.css +47 -0
- package/dist/themes/simple.css +47 -0
- package/dist/themes/sprint.css +12 -0
- package/dist/themes/sunrise.css +37 -0
- package/dist/themes/system.css +13 -0
- package/package.json +9 -2
- package/dist/components/alert.css +0 -30
- package/dist/components/alert.js +0 -31
- package/dist/components/badge.css +0 -30
- package/dist/components/badge.js +0 -31
- package/dist/components/banner.css +0 -30
- package/dist/components/banner.js +0 -31
- package/dist/components/bar-chart.css +0 -30
- package/dist/components/bar-chart.js +0 -31
- package/dist/components/bottom-sheet.css +0 -30
- package/dist/components/bottom-sheet.js +0 -31
- package/dist/components/button-group.css +0 -30
- package/dist/components/button-group.js +0 -31
- package/dist/components/chip.css +0 -30
- package/dist/components/chip.js +0 -31
- package/dist/components/color-picker.css +0 -30
- package/dist/components/color-picker.js +0 -31
- package/dist/components/context-menu.css +0 -30
- package/dist/components/context-menu.js +0 -31
- package/dist/components/donut-chart.css +0 -30
- package/dist/components/donut-chart.js +0 -31
- package/dist/components/expanded-panel.css +0 -30
- package/dist/components/expanded-panel.js +0 -31
- package/dist/components/footer.css +0 -30
- package/dist/components/footer.js +0 -31
- package/dist/components/gantt-chart.css +0 -30
- package/dist/components/gantt-chart.js +0 -31
- package/dist/components/gauge.css +0 -30
- package/dist/components/gauge.js +0 -31
- package/dist/components/graph.css +0 -30
- package/dist/components/graph.js +0 -31
- package/dist/components/header.css +0 -30
- package/dist/components/header.js +0 -31
- package/dist/components/heatmap.css +0 -30
- package/dist/components/heatmap.js +0 -31
- package/dist/components/line-chart.css +0 -30
- package/dist/components/line-chart.js +0 -31
- package/dist/components/list-item.css +0 -30
- package/dist/components/list-item.js +0 -31
- package/dist/components/menu-item.css +0 -30
- package/dist/components/menu-item.js +0 -31
- package/dist/components/multi-select.css +0 -30
- package/dist/components/multi-select.js +0 -31
- package/dist/components/notification.css +0 -30
- package/dist/components/notification.js +0 -31
- package/dist/components/pie-chart.css +0 -30
- package/dist/components/pie-chart.js +0 -31
- package/dist/components/popover.css +0 -30
- package/dist/components/popover.js +0 -31
- package/dist/components/progress-bar.css +0 -30
- package/dist/components/progress-bar.js +0 -31
- package/dist/components/progress-circle.css +0 -30
- package/dist/components/progress-circle.js +0 -31
- package/dist/components/radio-group.css +0 -30
- package/dist/components/radio-group.js +0 -31
- package/dist/components/range-slider.css +0 -30
- package/dist/components/range-slider.js +0 -31
- package/dist/components/rating.css +0 -30
- package/dist/components/rating.js +0 -31
- package/dist/components/sheet.css +0 -30
- package/dist/components/sheet.js +0 -31
- package/dist/components/slider.css +0 -30
- package/dist/components/slider.js +0 -31
- package/dist/components/snackbar.css +0 -30
- package/dist/components/snackbar.js +0 -31
- package/dist/components/sparkline.css +0 -30
- package/dist/components/sparkline.js +0 -31
- package/dist/components/stepper.css +0 -30
- package/dist/components/stepper.js +0 -31
- package/dist/components/switch.css +0 -30
- package/dist/components/switch.js +0 -31
- package/dist/components/tab-group.css +0 -30
- package/dist/components/tab-group.js +0 -31
- package/dist/components/textfield.css +0 -30
- package/dist/components/textfield.js +0 -31
- package/dist/components/tooltip.css +0 -30
- package/dist/components/tooltip.js +0 -31
- package/dist/components/treemap.css +0 -30
- package/dist/components/treemap.js +0 -31
- package/dist/components/upload-dropzone.css +0 -30
- package/dist/components/upload-dropzone.js +0 -31
|
@@ -13,12 +13,16 @@
|
|
|
13
13
|
var(--bf-theme-transition-color, color 120ms ease),
|
|
14
14
|
var(--bf-theme-transition-border, border-color 120ms ease);
|
|
15
15
|
|
|
16
|
-
display: block;
|
|
16
|
+
display: inline-block;
|
|
17
17
|
font: var(--bf-checkbox-font);
|
|
18
18
|
color: var(--bf-checkbox-color);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.root {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 0.5rem;
|
|
25
|
+
cursor: pointer;
|
|
22
26
|
background: var(--bf-checkbox-bg);
|
|
23
27
|
color: var(--bf-checkbox-color);
|
|
24
28
|
border-width: var(--bf-checkbox-border-width);
|
|
@@ -28,3 +32,41 @@
|
|
|
28
32
|
padding: var(--bf-checkbox-padding-y) var(--bf-checkbox-padding-x);
|
|
29
33
|
transition: var(--bf-checkbox-transition);
|
|
30
34
|
}
|
|
35
|
+
|
|
36
|
+
input {
|
|
37
|
+
position: absolute;
|
|
38
|
+
opacity: 0;
|
|
39
|
+
width: 0;
|
|
40
|
+
height: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.box {
|
|
44
|
+
width: 0.95rem;
|
|
45
|
+
height: 0.95rem;
|
|
46
|
+
border-radius: 0.25rem;
|
|
47
|
+
border: 2px solid var(--bf-checkbox-border-color);
|
|
48
|
+
display: inline-block;
|
|
49
|
+
position: relative;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.box::after {
|
|
53
|
+
content: '';
|
|
54
|
+
position: absolute;
|
|
55
|
+
left: 0.2rem;
|
|
56
|
+
top: 0.02rem;
|
|
57
|
+
width: 0.28rem;
|
|
58
|
+
height: 0.55rem;
|
|
59
|
+
border-right: 2px solid var(--bf-theme-button-primary-color, #fff);
|
|
60
|
+
border-bottom: 2px solid var(--bf-theme-button-primary-color, #fff);
|
|
61
|
+
transform: rotate(45deg) scale(0);
|
|
62
|
+
transition: transform 120ms ease;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
input:checked + .box {
|
|
66
|
+
background: var(--bf-theme-button-primary-bg, #2563eb);
|
|
67
|
+
border-color: var(--bf-theme-button-primary-bg, #2563eb);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
input:checked + .box::after {
|
|
71
|
+
transform: rotate(45deg) scale(1);
|
|
72
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
class BfCheckbox extends HTMLElement {
|
|
2
|
+
static observedAttributes = ['checked', 'disabled', 'label', 'value'];
|
|
3
|
+
|
|
2
4
|
constructor() {
|
|
3
5
|
super();
|
|
4
6
|
this.attachShadow({ mode: 'open' });
|
|
7
|
+
this._onInputChange = this._onInputChange.bind(this);
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
connectedCallback() {
|
|
8
11
|
if (this._initialized) {
|
|
12
|
+
this._syncState();
|
|
9
13
|
return;
|
|
10
14
|
}
|
|
11
15
|
this._initialized = true;
|
|
@@ -15,16 +19,105 @@ class BfCheckbox extends HTMLElement {
|
|
|
15
19
|
link.rel = 'stylesheet';
|
|
16
20
|
link.href = cssUrl.href;
|
|
17
21
|
|
|
18
|
-
const root = document.createElement('
|
|
22
|
+
const root = document.createElement('label');
|
|
19
23
|
root.className = 'root';
|
|
20
24
|
root.setAttribute('part', 'root');
|
|
21
|
-
root.innerHTML =
|
|
25
|
+
root.innerHTML = `
|
|
26
|
+
<input type="checkbox" part="input" />
|
|
27
|
+
<span class="box" part="box"></span>
|
|
28
|
+
<span class="text" part="text"><slot></slot></span>
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
this.shadowRoot.replaceChildren(link, root);
|
|
32
|
+
this._input = this.shadowRoot.querySelector('input');
|
|
33
|
+
this._input.addEventListener('change', this._onInputChange);
|
|
34
|
+
this._syncState();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
attributeChangedCallback() {
|
|
38
|
+
this._syncState();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get checked() {
|
|
42
|
+
return this.hasAttribute('checked');
|
|
43
|
+
}
|
|
22
44
|
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
set checked(value) {
|
|
46
|
+
if (value) {
|
|
47
|
+
this.setAttribute('checked', '');
|
|
48
|
+
return;
|
|
25
49
|
}
|
|
50
|
+
this.removeAttribute('checked');
|
|
51
|
+
}
|
|
26
52
|
|
|
27
|
-
|
|
53
|
+
get value() {
|
|
54
|
+
return this.getAttribute('value') || this.textContent?.trim() || '';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_onInputChange() {
|
|
58
|
+
const nextChecked = this._input.checked;
|
|
59
|
+
if (nextChecked && !this._canSelectMore()) {
|
|
60
|
+
this._input.checked = false;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.checked = nextChecked;
|
|
64
|
+
|
|
65
|
+
this.dispatchEvent(
|
|
66
|
+
new CustomEvent('bf-change', {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
detail: {
|
|
70
|
+
group: this._effectiveGroup(),
|
|
71
|
+
value: this.value,
|
|
72
|
+
checked: this.checked,
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_effectiveGroup() {
|
|
79
|
+
return this.getAttribute('group') || '';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_groupLimit() {
|
|
83
|
+
const multiple = this.getAttribute('multiple');
|
|
84
|
+
if (multiple === null) {
|
|
85
|
+
return Infinity;
|
|
86
|
+
}
|
|
87
|
+
if (multiple === '') {
|
|
88
|
+
return Infinity;
|
|
89
|
+
}
|
|
90
|
+
const parsed = Number.parseInt(multiple, 10);
|
|
91
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : Infinity;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
_canSelectMore() {
|
|
95
|
+
const group = this._effectiveGroup();
|
|
96
|
+
if (!group) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
const cap = this._groupLimit();
|
|
100
|
+
if (cap === Infinity) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
const selected = [
|
|
104
|
+
...document.querySelectorAll(
|
|
105
|
+
`bf-checkbox[group="${CSS.escape(group)}"][checked]`,
|
|
106
|
+
),
|
|
107
|
+
];
|
|
108
|
+
return selected.length < cap || selected.includes(this);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_syncState() {
|
|
112
|
+
if (!this._input) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this._input.checked = this.checked;
|
|
116
|
+
this._input.disabled = this.hasAttribute('disabled');
|
|
117
|
+
this._input.value = this.value;
|
|
118
|
+
if (this.getAttribute('label')) {
|
|
119
|
+
this.setAttribute('aria-label', this.getAttribute('label'));
|
|
120
|
+
}
|
|
28
121
|
}
|
|
29
122
|
}
|
|
30
123
|
|
|
@@ -13,12 +13,34 @@
|
|
|
13
13
|
var(--bf-theme-transition-color, color 120ms ease),
|
|
14
14
|
var(--bf-theme-transition-border, border-color 120ms ease);
|
|
15
15
|
|
|
16
|
+
--bf-dialog-backdrop: rgba(2, 6, 23, 0.45);
|
|
17
|
+
--bf-dialog-max-w: 36rem;
|
|
18
|
+
--bf-dialog-shadow: 0 18px 44px rgba(2, 6, 23, 0.28);
|
|
19
|
+
|
|
16
20
|
display: block;
|
|
17
21
|
font: var(--bf-dialog-font);
|
|
18
22
|
color: var(--bf-dialog-color);
|
|
23
|
+
z-index: 1100;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
.root {
|
|
27
|
+
position: fixed;
|
|
28
|
+
inset: 0;
|
|
29
|
+
display: grid;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-items: center;
|
|
32
|
+
padding: 1rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.backdrop {
|
|
36
|
+
position: absolute;
|
|
37
|
+
inset: 0;
|
|
38
|
+
background: var(--bf-dialog-backdrop);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.panel {
|
|
42
|
+
position: relative;
|
|
43
|
+
width: min(100%, var(--bf-dialog-max-w));
|
|
22
44
|
background: var(--bf-dialog-bg);
|
|
23
45
|
color: var(--bf-dialog-color);
|
|
24
46
|
border-width: var(--bf-dialog-border-width);
|
|
@@ -27,4 +49,77 @@
|
|
|
27
49
|
border-radius: var(--bf-dialog-radius);
|
|
28
50
|
padding: var(--bf-dialog-padding-y) var(--bf-dialog-padding-x);
|
|
29
51
|
transition: var(--bf-dialog-transition);
|
|
52
|
+
box-shadow: var(--bf-dialog-shadow);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.root[data-open='false'] {
|
|
56
|
+
display: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.root[data-variant='tooltip'] .backdrop,
|
|
60
|
+
.root[data-variant='popover'] .backdrop,
|
|
61
|
+
.root[data-variant='panel'] .backdrop,
|
|
62
|
+
.root[data-variant='sheet'] .backdrop,
|
|
63
|
+
.root[data-variant='bottom-sheet'] .backdrop {
|
|
64
|
+
background: transparent;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.root[data-variant='tooltip'] .panel {
|
|
68
|
+
width: auto;
|
|
69
|
+
max-width: 18rem;
|
|
70
|
+
padding: 0.35rem 0.55rem;
|
|
71
|
+
border-radius: 6px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.root[data-variant='popover'] .panel {
|
|
75
|
+
width: min(24rem, 100%);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.root[data-variant='sheet'] {
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.root[data-variant='bottom-sheet'] {
|
|
83
|
+
align-items: end;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.root[data-variant='bottom-sheet'] .panel {
|
|
87
|
+
width: min(100%, 42rem);
|
|
88
|
+
border-radius: 14px 14px 0 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.root[data-position='top'] {
|
|
92
|
+
align-items: start;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.root[data-position='bottom'] {
|
|
96
|
+
align-items: end;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.root[data-position='left'] {
|
|
100
|
+
justify-items: start;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.root[data-position='right'] {
|
|
104
|
+
justify-items: end;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.root[data-position='top-left'] {
|
|
108
|
+
align-items: start;
|
|
109
|
+
justify-items: start;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.root[data-position='top-right'] {
|
|
113
|
+
align-items: start;
|
|
114
|
+
justify-items: end;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.root[data-position='bottom-left'] {
|
|
118
|
+
align-items: end;
|
|
119
|
+
justify-items: start;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.root[data-position='bottom-right'] {
|
|
123
|
+
align-items: end;
|
|
124
|
+
justify-items: end;
|
|
30
125
|
}
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
class BfDialog extends HTMLElement {
|
|
2
|
+
static observedAttributes = [
|
|
3
|
+
'open',
|
|
4
|
+
'variant',
|
|
5
|
+
'position',
|
|
6
|
+
'modal',
|
|
7
|
+
'sheet',
|
|
8
|
+
'bottom-sheet',
|
|
9
|
+
'popover',
|
|
10
|
+
'tooltip',
|
|
11
|
+
'panel',
|
|
12
|
+
'top',
|
|
13
|
+
'bottom',
|
|
14
|
+
'left',
|
|
15
|
+
'right',
|
|
16
|
+
'center',
|
|
17
|
+
'label',
|
|
18
|
+
];
|
|
19
|
+
|
|
2
20
|
constructor() {
|
|
3
21
|
super();
|
|
4
22
|
this.attachShadow({ mode: 'open' });
|
|
23
|
+
this._onBackdropClick = this._onBackdropClick.bind(this);
|
|
5
24
|
}
|
|
6
25
|
|
|
7
26
|
connectedCallback() {
|
|
8
27
|
if (this._initialized) {
|
|
28
|
+
this._sync();
|
|
9
29
|
return;
|
|
10
30
|
}
|
|
11
31
|
this._initialized = true;
|
|
@@ -18,13 +38,161 @@ class BfDialog extends HTMLElement {
|
|
|
18
38
|
const root = document.createElement('div');
|
|
19
39
|
root.className = 'root';
|
|
20
40
|
root.setAttribute('part', 'root');
|
|
21
|
-
root.innerHTML =
|
|
41
|
+
root.innerHTML = `
|
|
42
|
+
<div class="backdrop" part="backdrop"></div>
|
|
43
|
+
<div class="panel" part="panel"><slot></slot></div>
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
this.shadowRoot.replaceChildren(link, root);
|
|
47
|
+
this._root = root;
|
|
48
|
+
this._backdrop = root.querySelector('.backdrop');
|
|
49
|
+
this._panel = root.querySelector('.panel');
|
|
50
|
+
this._backdrop.addEventListener('click', this._onBackdropClick);
|
|
22
51
|
|
|
23
|
-
if (!this.
|
|
24
|
-
|
|
52
|
+
if (!this.textContent?.trim()) {
|
|
53
|
+
this.textContent = 'dialog';
|
|
25
54
|
}
|
|
26
55
|
|
|
27
|
-
this.
|
|
56
|
+
this._sync();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
attributeChangedCallback() {
|
|
60
|
+
this._sync();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get openState() {
|
|
64
|
+
return this.hasAttribute('open');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
open() {
|
|
68
|
+
this.setAttribute('open', '');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
close() {
|
|
72
|
+
this.removeAttribute('open');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
toggle() {
|
|
76
|
+
if (this.hasAttribute('open')) {
|
|
77
|
+
this.close();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.open();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_onBackdropClick() {
|
|
84
|
+
const variant = this._variant();
|
|
85
|
+
if (variant === 'tooltip' || variant === 'popover') {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.hasAttribute('persistent')) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.close();
|
|
92
|
+
this.dispatchEvent(
|
|
93
|
+
new CustomEvent('bf-close', {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
composed: true,
|
|
96
|
+
detail: { id: this.id || '' },
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_variant() {
|
|
102
|
+
const explicit = (this.getAttribute('variant') || '').toLowerCase();
|
|
103
|
+
if (
|
|
104
|
+
[
|
|
105
|
+
'dialog',
|
|
106
|
+
'sheet',
|
|
107
|
+
'bottom-sheet',
|
|
108
|
+
'popover',
|
|
109
|
+
'tooltip',
|
|
110
|
+
'panel',
|
|
111
|
+
].includes(explicit)
|
|
112
|
+
) {
|
|
113
|
+
return explicit;
|
|
114
|
+
}
|
|
115
|
+
if (this.hasAttribute('sheet')) {
|
|
116
|
+
return 'sheet';
|
|
117
|
+
}
|
|
118
|
+
if (this.hasAttribute('bottom-sheet')) {
|
|
119
|
+
return 'bottom-sheet';
|
|
120
|
+
}
|
|
121
|
+
if (this.hasAttribute('popover')) {
|
|
122
|
+
return 'popover';
|
|
123
|
+
}
|
|
124
|
+
if (this.hasAttribute('tooltip')) {
|
|
125
|
+
return 'tooltip';
|
|
126
|
+
}
|
|
127
|
+
if (this.hasAttribute('panel')) {
|
|
128
|
+
return 'panel';
|
|
129
|
+
}
|
|
130
|
+
return 'dialog';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_position() {
|
|
134
|
+
const explicit = (this.getAttribute('position') || '').toLowerCase().replace(/\s+/g, '-');
|
|
135
|
+
if (
|
|
136
|
+
[
|
|
137
|
+
'center',
|
|
138
|
+
'left',
|
|
139
|
+
'right',
|
|
140
|
+
'top',
|
|
141
|
+
'bottom',
|
|
142
|
+
'top-left',
|
|
143
|
+
'top-right',
|
|
144
|
+
'bottom-left',
|
|
145
|
+
'bottom-right',
|
|
146
|
+
].includes(explicit)
|
|
147
|
+
) {
|
|
148
|
+
return explicit;
|
|
149
|
+
}
|
|
150
|
+
if (this.hasAttribute('left')) {
|
|
151
|
+
return 'left';
|
|
152
|
+
}
|
|
153
|
+
if (this.hasAttribute('right')) {
|
|
154
|
+
return 'right';
|
|
155
|
+
}
|
|
156
|
+
if (this.hasAttribute('top')) {
|
|
157
|
+
return 'top';
|
|
158
|
+
}
|
|
159
|
+
if (this.hasAttribute('bottom')) {
|
|
160
|
+
return 'bottom';
|
|
161
|
+
}
|
|
162
|
+
if (this.hasAttribute('center')) {
|
|
163
|
+
return 'center';
|
|
164
|
+
}
|
|
165
|
+
return 'center';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_shouldOpenByDefault() {
|
|
169
|
+
return !this.hasAttribute('id');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
_sync() {
|
|
173
|
+
if (!this._root || !this._panel) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!this.hasAttribute('open') && this._shouldOpenByDefault()) {
|
|
178
|
+
this.setAttribute('open', '');
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const isOpen = this.hasAttribute('open');
|
|
183
|
+
const variant = this._variant();
|
|
184
|
+
const position = this._position();
|
|
185
|
+
|
|
186
|
+
this._root.setAttribute('data-open', isOpen ? 'true' : 'false');
|
|
187
|
+
this._root.setAttribute('data-variant', variant);
|
|
188
|
+
this._root.setAttribute('data-position', position);
|
|
189
|
+
|
|
190
|
+
this.hidden = !isOpen;
|
|
191
|
+
this.setAttribute('aria-hidden', String(!isOpen));
|
|
192
|
+
this.setAttribute('role', variant === 'tooltip' ? 'tooltip' : 'dialog');
|
|
193
|
+
if (this.getAttribute('label')) {
|
|
194
|
+
this.setAttribute('aria-label', this.getAttribute('label'));
|
|
195
|
+
}
|
|
28
196
|
}
|
|
29
197
|
}
|
|
30
198
|
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
:host {
|
|
2
|
-
--bf-divider-font: var(--bf-theme-font-family, inherit);
|
|
3
|
-
--bf-divider-radius: var(--bf-theme-radius-md, 8px);
|
|
4
|
-
--bf-divider-border-width: var(--bf-theme-border-width, 1px);
|
|
5
|
-
--bf-divider-border-style: var(--bf-theme-border-style, solid);
|
|
6
2
|
--bf-divider-border-color: var(--bf-theme-divider-border-color, var(--bf-theme-border-1, #cbd5e1));
|
|
7
|
-
--bf-divider-
|
|
8
|
-
--bf-divider-
|
|
9
|
-
--bf-divider-padding-y: var(--bf-theme-space-2, 0.6rem);
|
|
10
|
-
--bf-divider-padding-x: var(--bf-theme-space-3, 0.9rem);
|
|
11
|
-
--bf-divider-transition:
|
|
12
|
-
var(--bf-theme-transition-bg, background-color 120ms ease),
|
|
13
|
-
var(--bf-theme-transition-color, color 120ms ease),
|
|
14
|
-
var(--bf-theme-transition-border, border-color 120ms ease);
|
|
3
|
+
--bf-divider-thickness: 1px;
|
|
4
|
+
--bf-divider-min-length: 2rem;
|
|
15
5
|
|
|
16
6
|
display: block;
|
|
17
|
-
font: var(--bf-divider-font);
|
|
18
|
-
color: var(--bf-divider-color);
|
|
19
7
|
}
|
|
20
8
|
|
|
21
9
|
.root {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
border-radius: 999px;
|
|
12
|
+
background: var(--bf-divider-border-color);
|
|
13
|
+
min-width: var(--bf-divider-min-length);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.root[data-orientation='horizontal'] {
|
|
17
|
+
height: var(--bf-divider-thickness);
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.root[data-orientation='vertical'] {
|
|
22
|
+
width: var(--bf-divider-thickness);
|
|
23
|
+
height: 100%;
|
|
24
|
+
min-height: var(--bf-divider-min-length);
|
|
25
|
+
min-width: 0;
|
|
30
26
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
class BfDivider extends HTMLElement {
|
|
2
|
+
static observedAttributes = ['vertical', 'thickness'];
|
|
3
|
+
|
|
2
4
|
constructor() {
|
|
3
5
|
super();
|
|
4
6
|
this.attachShadow({ mode: 'open' });
|
|
@@ -6,6 +8,7 @@ class BfDivider extends HTMLElement {
|
|
|
6
8
|
|
|
7
9
|
connectedCallback() {
|
|
8
10
|
if (this._initialized) {
|
|
11
|
+
this._sync();
|
|
9
12
|
return;
|
|
10
13
|
}
|
|
11
14
|
this._initialized = true;
|
|
@@ -20,11 +23,36 @@ class BfDivider extends HTMLElement {
|
|
|
20
23
|
root.setAttribute('part', 'root');
|
|
21
24
|
root.innerHTML = '<slot></slot>';
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
this.shadowRoot.replaceChildren(link, root);
|
|
27
|
+
this._root = root;
|
|
28
|
+
this._sync();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
attributeChangedCallback() {
|
|
32
|
+
this._sync();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_sync() {
|
|
36
|
+
if (!this._root) {
|
|
37
|
+
return;
|
|
25
38
|
}
|
|
26
39
|
|
|
27
|
-
this.
|
|
40
|
+
const isVertical = this.hasAttribute('vertical');
|
|
41
|
+
this._root.dataset.orientation = isVertical ? 'vertical' : 'horizontal';
|
|
42
|
+
|
|
43
|
+
const raw = this.getAttribute('thickness');
|
|
44
|
+
if (!raw) {
|
|
45
|
+
this.style.removeProperty('--bf-divider-thickness');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const parsed = Number.parseFloat(raw);
|
|
50
|
+
if (Number.isFinite(parsed)) {
|
|
51
|
+
this.style.setProperty('--bf-divider-thickness', `${parsed}px`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.style.setProperty('--bf-divider-thickness', raw);
|
|
28
56
|
}
|
|
29
57
|
}
|
|
30
58
|
|
|
@@ -1,30 +1,80 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
--bf-drawer-font: var(--bf-theme-font-family, inherit);
|
|
3
|
-
--bf-drawer-radius: var(--bf-theme-radius-md, 8px);
|
|
4
|
-
--bf-drawer-border-width: var(--bf-theme-border-width, 1px);
|
|
5
|
-
--bf-drawer-border-style: var(--bf-theme-border-style, solid);
|
|
6
|
-
--bf-drawer-border-color: var(--bf-theme-drawer-border-color, var(--bf-theme-border-1, #cbd5e1));
|
|
7
3
|
--bf-drawer-bg: var(--bf-theme-drawer-bg, var(--bf-theme-surface-1, #ffffff));
|
|
8
4
|
--bf-drawer-color: var(--bf-theme-drawer-color, var(--bf-theme-text-1, #0f172a));
|
|
9
|
-
--bf-drawer-
|
|
10
|
-
--bf-drawer-
|
|
11
|
-
--bf-drawer-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var(--bf-theme-transition-border, border-color 120ms ease);
|
|
15
|
-
|
|
5
|
+
--bf-drawer-border-color: var(--bf-theme-drawer-border-color, var(--bf-theme-border-1, #cbd5e1));
|
|
6
|
+
--bf-drawer-backdrop: rgba(2, 6, 23, 0.35);
|
|
7
|
+
--bf-drawer-width: min(90vw, 22rem);
|
|
8
|
+
--bf-drawer-height: min(75vh, 24rem);
|
|
9
|
+
--bf-drawer-shadow: 0 18px 44px rgba(2, 6, 23, 0.28);
|
|
16
10
|
display: block;
|
|
17
11
|
font: var(--bf-drawer-font);
|
|
18
|
-
|
|
12
|
+
z-index: 1190;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
.root {
|
|
16
|
+
position: fixed;
|
|
17
|
+
inset: 0;
|
|
18
|
+
display: grid;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.root[data-open='false'] {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.backdrop {
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: 0;
|
|
28
|
+
background: var(--bf-drawer-backdrop);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.panel {
|
|
32
|
+
position: relative;
|
|
22
33
|
background: var(--bf-drawer-bg);
|
|
23
34
|
color: var(--bf-drawer-color);
|
|
24
|
-
border
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
border: 1px solid var(--bf-drawer-border-color);
|
|
36
|
+
box-shadow: var(--bf-drawer-shadow);
|
|
37
|
+
padding: 1rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.root[data-side='right'] {
|
|
41
|
+
justify-items: end;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.root[data-side='right'] .panel {
|
|
45
|
+
width: var(--bf-drawer-width);
|
|
46
|
+
height: 100%;
|
|
47
|
+
border-radius: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.root[data-side='left'] {
|
|
51
|
+
justify-items: start;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.root[data-side='left'] .panel {
|
|
55
|
+
width: var(--bf-drawer-width);
|
|
56
|
+
height: 100%;
|
|
57
|
+
border-radius: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.root[data-side='top'] {
|
|
61
|
+
align-items: start;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.root[data-side='top'] .panel {
|
|
65
|
+
width: 100%;
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
height: var(--bf-drawer-height);
|
|
68
|
+
border-radius: 0 0 12px 12px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.root[data-side='bottom'] {
|
|
72
|
+
align-items: end;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.root[data-side='bottom'] .panel {
|
|
76
|
+
width: 100%;
|
|
77
|
+
max-width: 100%;
|
|
78
|
+
height: var(--bf-drawer-height);
|
|
79
|
+
border-radius: 12px 12px 0 0;
|
|
30
80
|
}
|