bitwrench 2.0.18 → 2.0.19
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 +86 -81
- package/dist/bitwrench-bccl.cjs.js +221 -48
- package/dist/bitwrench-bccl.cjs.min.js +3 -3
- package/dist/bitwrench-bccl.esm.js +221 -48
- package/dist/bitwrench-bccl.esm.min.js +3 -3
- package/dist/bitwrench-bccl.umd.js +221 -48
- package/dist/bitwrench-bccl.umd.min.js +3 -3
- package/dist/bitwrench-code-edit.cjs.js +7 -9
- package/dist/bitwrench-code-edit.cjs.min.js +5 -7
- package/dist/bitwrench-code-edit.es5.js +6 -8
- package/dist/bitwrench-code-edit.es5.min.js +5 -7
- package/dist/bitwrench-code-edit.esm.js +7 -9
- package/dist/bitwrench-code-edit.esm.min.js +5 -7
- package/dist/bitwrench-code-edit.umd.js +7 -9
- package/dist/bitwrench-code-edit.umd.min.js +5 -7
- package/dist/bitwrench-debug.js +268 -0
- package/dist/bitwrench-debug.min.js +3 -0
- package/dist/bitwrench-lean.cjs.js +250 -1574
- package/dist/bitwrench-lean.cjs.min.js +6 -6
- package/dist/bitwrench-lean.es5.js +344 -1661
- package/dist/bitwrench-lean.es5.min.js +4 -4
- package/dist/bitwrench-lean.esm.js +250 -1574
- package/dist/bitwrench-lean.esm.min.js +6 -6
- package/dist/bitwrench-lean.umd.js +250 -1574
- package/dist/bitwrench-lean.umd.min.js +6 -6
- package/dist/bitwrench-util-css.cjs.js +1 -1
- package/dist/bitwrench-util-css.cjs.min.js +1 -1
- package/dist/bitwrench-util-css.es5.js +1 -1
- package/dist/bitwrench-util-css.es5.min.js +1 -1
- package/dist/bitwrench-util-css.esm.js +1 -1
- package/dist/bitwrench-util-css.esm.min.js +1 -1
- package/dist/bitwrench-util-css.umd.js +1 -1
- package/dist/bitwrench-util-css.umd.min.js +1 -1
- package/dist/bitwrench.cjs.js +510 -1660
- package/dist/bitwrench.cjs.min.js +7 -7
- package/dist/bitwrench.css +80 -33
- package/dist/bitwrench.es5.js +569 -1694
- package/dist/bitwrench.es5.min.js +5 -5
- package/dist/bitwrench.esm.js +510 -1660
- package/dist/bitwrench.esm.min.js +7 -7
- package/dist/bitwrench.min.css +1 -1
- package/dist/bitwrench.umd.js +510 -1660
- package/dist/bitwrench.umd.min.js +7 -7
- package/dist/builds.json +133 -111
- package/dist/bwserve.cjs.js +2 -2
- package/dist/bwserve.esm.js +2 -2
- package/dist/sri.json +46 -44
- package/package.json +5 -3
- package/readme.html +86 -75
- package/src/bitwrench-bccl-entry.js +3 -4
- package/src/bitwrench-bccl.js +217 -43
- package/src/bitwrench-code-edit.js +6 -8
- package/src/bitwrench-debug.js +245 -0
- package/src/bitwrench-styles.js +35 -8
- package/src/bitwrench.js +212 -1563
- package/src/cli/attach.js +53 -21
- package/src/cli/serve.js +179 -3
- package/src/version.js +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! bitwrench-bccl v2.0.
|
|
1
|
+
/*! bitwrench-bccl v2.0.19 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -179,7 +179,12 @@
|
|
|
179
179
|
},
|
|
180
180
|
o: {
|
|
181
181
|
type: 'card',
|
|
182
|
-
state: props.state || {}
|
|
182
|
+
state: props.state || {},
|
|
183
|
+
slots: {
|
|
184
|
+
title: '.bw_card_title',
|
|
185
|
+
content: '.bw_card_body',
|
|
186
|
+
footer: '.bw_card_footer'
|
|
187
|
+
}
|
|
183
188
|
}
|
|
184
189
|
};
|
|
185
190
|
}
|
|
@@ -190,7 +195,12 @@
|
|
|
190
195
|
c: cardContent,
|
|
191
196
|
o: {
|
|
192
197
|
type: 'card',
|
|
193
|
-
state: props.state || {}
|
|
198
|
+
state: props.state || {},
|
|
199
|
+
slots: {
|
|
200
|
+
title: '.bw_card_title',
|
|
201
|
+
content: '.bw_card_body',
|
|
202
|
+
footer: '.bw_card_footer'
|
|
203
|
+
}
|
|
194
204
|
}
|
|
195
205
|
};
|
|
196
206
|
}
|
|
@@ -508,6 +518,24 @@
|
|
|
508
518
|
}
|
|
509
519
|
});
|
|
510
520
|
|
|
521
|
+
// Shared tab switching logic
|
|
522
|
+
function switchTab(el, index) {
|
|
523
|
+
var allTabs = el.querySelectorAll('.bw_nav_link');
|
|
524
|
+
var allPanes = el.querySelectorAll('.bw_tab_pane');
|
|
525
|
+
if (index < 0 || index >= allTabs.length) return;
|
|
526
|
+
allTabs.forEach(function(t) {
|
|
527
|
+
t.classList.remove('active');
|
|
528
|
+
t.setAttribute('aria-selected', 'false');
|
|
529
|
+
t.setAttribute('tabindex', '-1');
|
|
530
|
+
});
|
|
531
|
+
allPanes.forEach(function(p) { p.classList.remove('active'); });
|
|
532
|
+
allTabs[index].classList.add('active');
|
|
533
|
+
allTabs[index].setAttribute('aria-selected', 'true');
|
|
534
|
+
allTabs[index].setAttribute('tabindex', '0');
|
|
535
|
+
allPanes[index].classList.add('active');
|
|
536
|
+
if (el._bw_state) el._bw_state.activeIndex = index;
|
|
537
|
+
}
|
|
538
|
+
|
|
511
539
|
return {
|
|
512
540
|
t: 'div',
|
|
513
541
|
a: { class: 'bw_tabs' },
|
|
@@ -526,24 +554,8 @@
|
|
|
526
554
|
role: 'tab',
|
|
527
555
|
tabindex: index === actualActiveIndex ? '0' : '-1',
|
|
528
556
|
'aria-selected': index === actualActiveIndex ? 'true' : 'false',
|
|
529
|
-
'data-tab-index': index,
|
|
530
557
|
onclick: (e) => {
|
|
531
|
-
|
|
532
|
-
const allTabs = tabsContainer.querySelectorAll('.bw_nav_link');
|
|
533
|
-
const allPanes = tabsContainer.querySelectorAll('.bw_tab_pane');
|
|
534
|
-
|
|
535
|
-
allTabs.forEach(t => {
|
|
536
|
-
t.classList.remove('active');
|
|
537
|
-
t.setAttribute('aria-selected', 'false');
|
|
538
|
-
t.setAttribute('tabindex', '-1');
|
|
539
|
-
});
|
|
540
|
-
allPanes.forEach(p => p.classList.remove('active'));
|
|
541
|
-
|
|
542
|
-
e.target.classList.add('active');
|
|
543
|
-
e.target.setAttribute('aria-selected', 'true');
|
|
544
|
-
e.target.setAttribute('tabindex', '0');
|
|
545
|
-
const targetIndex = parseInt(e.target.getAttribute('data-tab-index'));
|
|
546
|
-
allPanes[targetIndex].classList.add('active');
|
|
558
|
+
switchTab(e.target.closest('.bw_tabs'), index);
|
|
547
559
|
}
|
|
548
560
|
},
|
|
549
561
|
c: tab.label
|
|
@@ -566,6 +578,10 @@
|
|
|
566
578
|
o: {
|
|
567
579
|
type: 'tabs',
|
|
568
580
|
state: { activeIndex: actualActiveIndex },
|
|
581
|
+
handle: {
|
|
582
|
+
setActiveTab: switchTab,
|
|
583
|
+
getActiveTab: function(el) { return (el._bw_state && el._bw_state.activeIndex) || 0; }
|
|
584
|
+
},
|
|
569
585
|
mounted: function(el) {
|
|
570
586
|
var tablist = el.querySelector('[role="tablist"]');
|
|
571
587
|
if (!tablist) return;
|
|
@@ -651,7 +667,13 @@
|
|
|
651
667
|
},
|
|
652
668
|
c: '×'
|
|
653
669
|
}
|
|
654
|
-
].filter(Boolean)
|
|
670
|
+
].filter(Boolean),
|
|
671
|
+
o: {
|
|
672
|
+
type: 'alert',
|
|
673
|
+
handle: {
|
|
674
|
+
dismiss: function(el) { if (el && el.parentNode) el.parentNode.removeChild(el); }
|
|
675
|
+
}
|
|
676
|
+
}
|
|
655
677
|
};
|
|
656
678
|
}
|
|
657
679
|
|
|
@@ -749,6 +771,24 @@
|
|
|
749
771
|
'aria-valuemax': max
|
|
750
772
|
},
|
|
751
773
|
c: label || `${percentage}%`
|
|
774
|
+
},
|
|
775
|
+
o: {
|
|
776
|
+
type: 'progress',
|
|
777
|
+
handle: {
|
|
778
|
+
setValue: function(el, n) {
|
|
779
|
+
var bar = el.querySelector('.bw_progress_bar');
|
|
780
|
+
if (!bar) return;
|
|
781
|
+
var maxVal = parseInt(bar.getAttribute('aria-valuemax')) || 100;
|
|
782
|
+
var pct = Math.round((n / maxVal) * 100);
|
|
783
|
+
bar.style.width = pct + '%';
|
|
784
|
+
bar.setAttribute('aria-valuenow', n);
|
|
785
|
+
bar.textContent = pct + '%';
|
|
786
|
+
},
|
|
787
|
+
getValue: function(el) {
|
|
788
|
+
var bar = el.querySelector('.bw_progress_bar');
|
|
789
|
+
return bar ? parseInt(bar.getAttribute('aria-valuenow')) || 0 : 0;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
752
792
|
}
|
|
753
793
|
};
|
|
754
794
|
}
|
|
@@ -1758,6 +1798,26 @@
|
|
|
1758
1798
|
class: `bw_pagination ${size ? 'bw_pagination_' + size : ''} ${className}`.trim()
|
|
1759
1799
|
},
|
|
1760
1800
|
c: items
|
|
1801
|
+
},
|
|
1802
|
+
o: {
|
|
1803
|
+
type: 'pagination',
|
|
1804
|
+
state: { currentPage: currentPage, pages: pages },
|
|
1805
|
+
handle: {
|
|
1806
|
+
setPage: function(el, n) {
|
|
1807
|
+
if (n < 1 || n > pages) return;
|
|
1808
|
+
var allItems = el.querySelectorAll('.bw_page_item');
|
|
1809
|
+
for (var i = 0; i < allItems.length; i++) {
|
|
1810
|
+
allItems[i].classList.remove('bw_active');
|
|
1811
|
+
}
|
|
1812
|
+
// +1 offset: first item is prev arrow
|
|
1813
|
+
if (allItems[n]) allItems[n].classList.add('bw_active');
|
|
1814
|
+
if (el._bw_state) el._bw_state.currentPage = n;
|
|
1815
|
+
if (onPageChange) onPageChange(n);
|
|
1816
|
+
},
|
|
1817
|
+
getPage: function(el) {
|
|
1818
|
+
return (el._bw_state && el._bw_state.currentPage) || 1;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1761
1821
|
}
|
|
1762
1822
|
};
|
|
1763
1823
|
}
|
|
@@ -1906,7 +1966,6 @@
|
|
|
1906
1966
|
class: `bw_accordion_button ${item.open ? '' : 'bw_collapsed'}`.trim(),
|
|
1907
1967
|
type: 'button',
|
|
1908
1968
|
'aria-expanded': item.open ? 'true' : 'false',
|
|
1909
|
-
'data-accordion-index': index,
|
|
1910
1969
|
onclick: function(e) {
|
|
1911
1970
|
var btn = e.target.closest('.bw_accordion_button');
|
|
1912
1971
|
var accordionEl = btn.closest('.bw_accordion');
|
|
@@ -1981,7 +2040,43 @@
|
|
|
1981
2040
|
}),
|
|
1982
2041
|
o: {
|
|
1983
2042
|
type: 'accordion',
|
|
1984
|
-
state: { multiOpen: multiOpen }
|
|
2043
|
+
state: { multiOpen: multiOpen },
|
|
2044
|
+
handle: {
|
|
2045
|
+
toggle: function(el, index) {
|
|
2046
|
+
var items = el.querySelectorAll('.bw_accordion_item');
|
|
2047
|
+
if (index < 0 || index >= items.length) return;
|
|
2048
|
+
var btn = items[index].querySelector('.bw_accordion_button');
|
|
2049
|
+
if (btn) btn.click();
|
|
2050
|
+
},
|
|
2051
|
+
openAll: function(el) {
|
|
2052
|
+
var items = el.querySelectorAll('.bw_accordion_item');
|
|
2053
|
+
for (var i = 0; i < items.length; i++) {
|
|
2054
|
+
var collapse = items[i].querySelector('.bw_accordion_collapse');
|
|
2055
|
+
var btn = items[i].querySelector('.bw_accordion_button');
|
|
2056
|
+
if (!collapse.classList.contains('bw_collapse_show')) {
|
|
2057
|
+
collapse.classList.add('bw_collapse_show');
|
|
2058
|
+
collapse.style.maxHeight = 'none';
|
|
2059
|
+
btn.classList.remove('bw_collapsed');
|
|
2060
|
+
btn.setAttribute('aria-expanded', 'true');
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
},
|
|
2064
|
+
closeAll: function(el) {
|
|
2065
|
+
var items = el.querySelectorAll('.bw_accordion_item');
|
|
2066
|
+
for (var i = 0; i < items.length; i++) {
|
|
2067
|
+
var collapse = items[i].querySelector('.bw_accordion_collapse');
|
|
2068
|
+
var btn = items[i].querySelector('.bw_accordion_button');
|
|
2069
|
+
if (collapse.classList.contains('bw_collapse_show')) {
|
|
2070
|
+
collapse.style.maxHeight = collapse.scrollHeight + 'px';
|
|
2071
|
+
collapse.offsetHeight;
|
|
2072
|
+
collapse.style.maxHeight = '0px';
|
|
2073
|
+
collapse.classList.remove('bw_collapse_show');
|
|
2074
|
+
btn.classList.add('bw_collapsed');
|
|
2075
|
+
btn.setAttribute('aria-expanded', 'false');
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
1985
2080
|
}
|
|
1986
2081
|
};
|
|
1987
2082
|
}
|
|
@@ -2071,6 +2166,14 @@
|
|
|
2071
2166
|
},
|
|
2072
2167
|
o: {
|
|
2073
2168
|
type: 'modal',
|
|
2169
|
+
handle: {
|
|
2170
|
+
open: function(el) {
|
|
2171
|
+
el.classList.add('bw_modal_show');
|
|
2172
|
+
el.style.display = 'flex';
|
|
2173
|
+
document.body.style.overflow = 'hidden';
|
|
2174
|
+
},
|
|
2175
|
+
close: function(el) { closeModal(el); }
|
|
2176
|
+
},
|
|
2074
2177
|
mounted: function(el) {
|
|
2075
2178
|
// Click backdrop to close
|
|
2076
2179
|
el.addEventListener('click', function(e) {
|
|
@@ -2129,9 +2232,8 @@
|
|
|
2129
2232
|
return {
|
|
2130
2233
|
t: 'div',
|
|
2131
2234
|
a: {
|
|
2132
|
-
class: `bw_toast ${variantClass(variant)} ${className}`.trim(),
|
|
2133
|
-
role: 'alert'
|
|
2134
|
-
'data-position': position
|
|
2235
|
+
class: `bw_toast ${variantClass(variant)} bw_toast_${position.replace(/-/g, '_')} ${className}`.trim(),
|
|
2236
|
+
role: 'alert'
|
|
2135
2237
|
},
|
|
2136
2238
|
c: [
|
|
2137
2239
|
(title) && {
|
|
@@ -2165,6 +2267,12 @@
|
|
|
2165
2267
|
].filter(Boolean),
|
|
2166
2268
|
o: {
|
|
2167
2269
|
type: 'toast',
|
|
2270
|
+
handle: {
|
|
2271
|
+
dismiss: function(el) {
|
|
2272
|
+
el.classList.add('bw_toast_hiding');
|
|
2273
|
+
setTimeout(function() { if (el.parentNode) el.parentNode.removeChild(el); }, 300);
|
|
2274
|
+
}
|
|
2275
|
+
},
|
|
2168
2276
|
mounted: function(el) {
|
|
2169
2277
|
// Trigger show animation
|
|
2170
2278
|
requestAnimationFrame(function() {
|
|
@@ -2522,7 +2630,7 @@
|
|
|
2522
2630
|
var total = carouselEl.querySelectorAll('.bw_carousel_slide').length;
|
|
2523
2631
|
if (index < 0) index = total - 1;
|
|
2524
2632
|
if (index >= total) index = 0;
|
|
2525
|
-
carouselEl.
|
|
2633
|
+
carouselEl._bw_carouselIndex = index;
|
|
2526
2634
|
var track = carouselEl.querySelector('.bw_carousel_track');
|
|
2527
2635
|
track.style.transform = 'translateX(-' + (index * 100) + '%)';
|
|
2528
2636
|
// Update indicators
|
|
@@ -2579,7 +2687,7 @@
|
|
|
2579
2687
|
'aria-label': 'Previous slide',
|
|
2580
2688
|
onclick: function(e) {
|
|
2581
2689
|
var carousel = e.target.closest('.bw_carousel');
|
|
2582
|
-
var idx =
|
|
2690
|
+
var idx = carousel._bw_carouselIndex || 0;
|
|
2583
2691
|
goToSlide(carousel, idx - 1);
|
|
2584
2692
|
}
|
|
2585
2693
|
},
|
|
@@ -2593,7 +2701,7 @@
|
|
|
2593
2701
|
'aria-label': 'Next slide',
|
|
2594
2702
|
onclick: function(e) {
|
|
2595
2703
|
var carousel = e.target.closest('.bw_carousel');
|
|
2596
|
-
var idx =
|
|
2704
|
+
var idx = carousel._bw_carouselIndex || 0;
|
|
2597
2705
|
goToSlide(carousel, idx + 1);
|
|
2598
2706
|
}
|
|
2599
2707
|
},
|
|
@@ -2613,11 +2721,9 @@
|
|
|
2613
2721
|
class: 'bw_carousel_indicator' + (i === startIndex ? ' active' : ''),
|
|
2614
2722
|
type: 'button',
|
|
2615
2723
|
'aria-label': 'Go to slide ' + (i + 1),
|
|
2616
|
-
'data-slide-index': i,
|
|
2617
2724
|
onclick: function(e) {
|
|
2618
2725
|
var carousel = e.target.closest('.bw_carousel');
|
|
2619
|
-
|
|
2620
|
-
goToSlide(carousel, idx);
|
|
2726
|
+
goToSlide(carousel, i);
|
|
2621
2727
|
}
|
|
2622
2728
|
}
|
|
2623
2729
|
};
|
|
@@ -2631,17 +2737,37 @@
|
|
|
2631
2737
|
class: ('bw_carousel ' + className).trim(),
|
|
2632
2738
|
style: 'height: ' + height,
|
|
2633
2739
|
tabindex: '0',
|
|
2634
|
-
'aria-roledescription': 'carousel'
|
|
2635
|
-
'data-carousel-index': startIndex
|
|
2740
|
+
'aria-roledescription': 'carousel'
|
|
2636
2741
|
},
|
|
2637
2742
|
c: children,
|
|
2638
2743
|
o: {
|
|
2639
2744
|
type: 'carousel',
|
|
2640
2745
|
state: { activeIndex: startIndex, autoPlay: autoPlay, interval: interval },
|
|
2746
|
+
handle: {
|
|
2747
|
+
goToSlide: function(el, index) { goToSlide(el, index); },
|
|
2748
|
+
next: function(el) { goToSlide(el, (el._bw_carouselIndex || 0) + 1); },
|
|
2749
|
+
prev: function(el) { goToSlide(el, (el._bw_carouselIndex || 0) - 1); },
|
|
2750
|
+
getActiveIndex: function(el) { return el._bw_carouselIndex || 0; },
|
|
2751
|
+
pause: function(el) {
|
|
2752
|
+
if (el._bw_carouselInterval) {
|
|
2753
|
+
clearInterval(el._bw_carouselInterval);
|
|
2754
|
+
el._bw_carouselInterval = null;
|
|
2755
|
+
}
|
|
2756
|
+
},
|
|
2757
|
+
play: function(el) {
|
|
2758
|
+
if (!el._bw_carouselInterval && el._bw_state) {
|
|
2759
|
+
var ms = el._bw_state.interval || 5000;
|
|
2760
|
+
el._bw_carouselInterval = setInterval(function() {
|
|
2761
|
+
goToSlide(el, (el._bw_carouselIndex || 0) + 1);
|
|
2762
|
+
}, ms);
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
},
|
|
2641
2766
|
mounted: function(el) {
|
|
2767
|
+
el._bw_carouselIndex = startIndex;
|
|
2642
2768
|
// Keyboard navigation
|
|
2643
2769
|
el.addEventListener('keydown', function(e) {
|
|
2644
|
-
var idx =
|
|
2770
|
+
var idx = el._bw_carouselIndex || 0;
|
|
2645
2771
|
if (e.key === 'ArrowLeft') {
|
|
2646
2772
|
e.preventDefault();
|
|
2647
2773
|
goToSlide(el, idx - 1);
|
|
@@ -2653,7 +2779,7 @@
|
|
|
2653
2779
|
// Auto-play
|
|
2654
2780
|
if (autoPlay) {
|
|
2655
2781
|
var intervalId = setInterval(function() {
|
|
2656
|
-
var idx =
|
|
2782
|
+
var idx = el._bw_carouselIndex || 0;
|
|
2657
2783
|
goToSlide(el, idx + 1);
|
|
2658
2784
|
}, interval);
|
|
2659
2785
|
el._bw_carouselInterval = intervalId;
|
|
@@ -2663,7 +2789,7 @@
|
|
|
2663
2789
|
});
|
|
2664
2790
|
el.addEventListener('mouseleave', function() {
|
|
2665
2791
|
el._bw_carouselInterval = setInterval(function() {
|
|
2666
|
-
var idx =
|
|
2792
|
+
var idx = el._bw_carouselIndex || 0;
|
|
2667
2793
|
goToSlide(el, idx + 1);
|
|
2668
2794
|
}, interval);
|
|
2669
2795
|
});
|
|
@@ -2779,7 +2905,13 @@
|
|
|
2779
2905
|
t: 'div',
|
|
2780
2906
|
a: { class: classes, style: style },
|
|
2781
2907
|
c: children,
|
|
2782
|
-
o: {
|
|
2908
|
+
o: {
|
|
2909
|
+
type: 'stat-card',
|
|
2910
|
+
slots: {
|
|
2911
|
+
value: '.bw_stat_value',
|
|
2912
|
+
label: '.bw_stat_label'
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2783
2915
|
};
|
|
2784
2916
|
}
|
|
2785
2917
|
|
|
@@ -3458,7 +3590,7 @@
|
|
|
3458
3590
|
function makeChipEl(text) {
|
|
3459
3591
|
return {
|
|
3460
3592
|
t: 'span',
|
|
3461
|
-
a: { class: 'bw_chip'
|
|
3593
|
+
a: { class: 'bw_chip' },
|
|
3462
3594
|
c: [
|
|
3463
3595
|
text,
|
|
3464
3596
|
{
|
|
@@ -3469,9 +3601,8 @@
|
|
|
3469
3601
|
'aria-label': 'Remove ' + text,
|
|
3470
3602
|
onclick: function(e) {
|
|
3471
3603
|
var chip = e.target.closest('.bw_chip');
|
|
3472
|
-
var val = chip.getAttribute('data-chip-value');
|
|
3473
3604
|
chip.parentNode.removeChild(chip);
|
|
3474
|
-
if (onRemove) onRemove(
|
|
3605
|
+
if (onRemove) onRemove(text);
|
|
3475
3606
|
}
|
|
3476
3607
|
},
|
|
3477
3608
|
c: '\u00D7'
|
|
@@ -3499,7 +3630,7 @@
|
|
|
3499
3630
|
// Insert chip before the input
|
|
3500
3631
|
var chipEl = document.createElement('span');
|
|
3501
3632
|
chipEl.className = 'bw_chip';
|
|
3502
|
-
chipEl.
|
|
3633
|
+
chipEl._bw_chipValue = val;
|
|
3503
3634
|
chipEl.innerHTML = '';
|
|
3504
3635
|
chipEl.textContent = val;
|
|
3505
3636
|
var removeBtn = document.createElement('button');
|
|
@@ -3522,7 +3653,7 @@
|
|
|
3522
3653
|
var chipEls = wrapper.querySelectorAll('.bw_chip');
|
|
3523
3654
|
if (chipEls.length) {
|
|
3524
3655
|
var last = chipEls[chipEls.length - 1];
|
|
3525
|
-
var removedVal = last.
|
|
3656
|
+
var removedVal = last._bw_chipValue || last.firstChild.textContent;
|
|
3526
3657
|
last.parentNode.removeChild(last);
|
|
3527
3658
|
if (onRemove) onRemove(removedVal);
|
|
3528
3659
|
}
|
|
@@ -3531,7 +3662,50 @@
|
|
|
3531
3662
|
}
|
|
3532
3663
|
}
|
|
3533
3664
|
],
|
|
3534
|
-
o: {
|
|
3665
|
+
o: {
|
|
3666
|
+
type: 'chip-input',
|
|
3667
|
+
handle: {
|
|
3668
|
+
addChip: function(el, text) {
|
|
3669
|
+
if (!text) return;
|
|
3670
|
+
var input = el.querySelector('.bw_chip_field');
|
|
3671
|
+
var chipEl = document.createElement('span');
|
|
3672
|
+
chipEl.className = 'bw_chip';
|
|
3673
|
+
chipEl._bw_chipValue = text;
|
|
3674
|
+
chipEl.textContent = text;
|
|
3675
|
+
var removeBtn = document.createElement('button');
|
|
3676
|
+
removeBtn.type = 'button';
|
|
3677
|
+
removeBtn.className = 'bw_chip_remove';
|
|
3678
|
+
removeBtn.setAttribute('aria-label', 'Remove ' + text);
|
|
3679
|
+
removeBtn.textContent = '\u00D7';
|
|
3680
|
+
removeBtn.onclick = function() { chipEl.parentNode.removeChild(chipEl); };
|
|
3681
|
+
chipEl.appendChild(removeBtn);
|
|
3682
|
+
el.insertBefore(chipEl, input);
|
|
3683
|
+
},
|
|
3684
|
+
removeChip: function(el, text) {
|
|
3685
|
+
var chips = el.querySelectorAll('.bw_chip');
|
|
3686
|
+
for (var i = 0; i < chips.length; i++) {
|
|
3687
|
+
if ((chips[i]._bw_chipValue || chips[i].firstChild.textContent) === text) {
|
|
3688
|
+
chips[i].parentNode.removeChild(chips[i]);
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
},
|
|
3693
|
+
getChips: function(el) {
|
|
3694
|
+
var chips = el.querySelectorAll('.bw_chip');
|
|
3695
|
+
var values = [];
|
|
3696
|
+
for (var i = 0; i < chips.length; i++) {
|
|
3697
|
+
values.push(chips[i]._bw_chipValue || chips[i].firstChild.textContent);
|
|
3698
|
+
}
|
|
3699
|
+
return values;
|
|
3700
|
+
},
|
|
3701
|
+
clear: function(el) {
|
|
3702
|
+
var chips = el.querySelectorAll('.bw_chip');
|
|
3703
|
+
for (var i = chips.length - 1; i >= 0; i--) {
|
|
3704
|
+
chips[i].parentNode.removeChild(chips[i]);
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3535
3709
|
};
|
|
3536
3710
|
}
|
|
3537
3711
|
|
|
@@ -3725,15 +3899,14 @@
|
|
|
3725
3899
|
// Variant class helper
|
|
3726
3900
|
bw.variantClass = variantClass;
|
|
3727
3901
|
|
|
3728
|
-
// Create functions that return
|
|
3729
|
-
if (typeof bw.
|
|
3902
|
+
// Create functions that return DOM elements
|
|
3903
|
+
if (typeof bw.createDOM === 'function') {
|
|
3730
3904
|
Object.entries(components).forEach(function(entry) {
|
|
3731
3905
|
var name = entry[0], fn = entry[1];
|
|
3732
3906
|
if (name.indexOf('make') === 0) {
|
|
3733
3907
|
var createName = 'create' + name.substring(4);
|
|
3734
3908
|
bw[createName] = function(props) {
|
|
3735
|
-
|
|
3736
|
-
return bw.renderComponent(taco);
|
|
3909
|
+
return bw.createDOM(fn(props));
|
|
3737
3910
|
};
|
|
3738
3911
|
}
|
|
3739
3912
|
});
|