@bwui/vue 0.0.0-stage → 0.1.2
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/LICENSE +21 -0
- package/README.md +15 -2
- package/dist/cn.d.ts +1 -0
- package/dist/cn.js +3 -0
- package/dist/combobox.d.ts +59 -0
- package/dist/combobox.js +119 -0
- package/dist/date-picker.d.ts +70 -0
- package/dist/date-picker.js +237 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/pages.d.ts +89 -0
- package/dist/pages.js +149 -0
- package/dist/primitives.d.ts +171 -0
- package/dist/primitives.js +173 -0
- package/package.json +42 -3
- package/src/cn.ts +3 -0
- package/src/combobox.ts +147 -0
- package/src/date-picker.ts +283 -0
- package/src/index.ts +37 -0
- package/src/pages.ts +173 -0
- package/src/primitives.ts +256 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nigel Copley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@bwui/vue`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 adapter for Brickwork. Components emit the same `bw-*` classes as the
|
|
4
|
+
HTML gallery, `@bwui/react`, and `django-brickwork`. Peer CSS is `@bwui/css`.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @bwui/vue @bwui/css
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import "@bwui/css";
|
|
12
|
+
import { Homepage, ContactForm, Combobox } from "@bwui/vue";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Four jobs: `<Homepage>`, `<Landing>`, `<ContactForm>` plus form primitives
|
|
16
|
+
(`Field`, `Input`, `Combobox`, `DatePicker`, `DateRangePicker`, `TimeInput`).
|
package/dist/cn.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cn(...parts: Array<string | false | null | undefined>): string;
|
package/dist/cn.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
export type ComboboxOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const Combobox: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
|
+
id: StringConstructor;
|
|
9
|
+
name: StringConstructor;
|
|
10
|
+
options: {
|
|
11
|
+
type: PropType<ComboboxOption[]>;
|
|
12
|
+
required: true;
|
|
13
|
+
};
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
placeholder: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
disabled: BooleanConstructor;
|
|
23
|
+
required: BooleanConstructor;
|
|
24
|
+
emptyLabel: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
31
|
+
id: StringConstructor;
|
|
32
|
+
name: StringConstructor;
|
|
33
|
+
options: {
|
|
34
|
+
type: PropType<ComboboxOption[]>;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
modelValue: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
placeholder: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
disabled: BooleanConstructor;
|
|
46
|
+
required: BooleanConstructor;
|
|
47
|
+
emptyLabel: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
}>> & Readonly<{
|
|
52
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
53
|
+
}>, {
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
required: boolean;
|
|
56
|
+
modelValue: string;
|
|
57
|
+
placeholder: string;
|
|
58
|
+
emptyLabel: string;
|
|
59
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { computed, defineComponent, h, onMounted, onUnmounted, ref } from 'vue';
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
export const Combobox = defineComponent({
|
|
4
|
+
name: 'BwCombobox',
|
|
5
|
+
props: {
|
|
6
|
+
id: String,
|
|
7
|
+
name: String,
|
|
8
|
+
options: { type: Array, required: true },
|
|
9
|
+
modelValue: { type: String, default: '' },
|
|
10
|
+
placeholder: { type: String, default: 'Search' },
|
|
11
|
+
disabled: Boolean,
|
|
12
|
+
required: Boolean,
|
|
13
|
+
emptyLabel: { type: String, default: 'No matches' },
|
|
14
|
+
},
|
|
15
|
+
emits: ['update:modelValue'],
|
|
16
|
+
setup(props, { emit, attrs }) {
|
|
17
|
+
const open = ref(false);
|
|
18
|
+
const query = ref('');
|
|
19
|
+
const active = ref(0);
|
|
20
|
+
const root = ref(null);
|
|
21
|
+
const selected = computed(() => props.options.find((o) => o.value === props.modelValue) ?? null);
|
|
22
|
+
const filtered = computed(() => {
|
|
23
|
+
const q = query.value.trim().toLowerCase();
|
|
24
|
+
if (!q)
|
|
25
|
+
return props.options;
|
|
26
|
+
return props.options.filter((o) => o.label.toLowerCase().includes(q));
|
|
27
|
+
});
|
|
28
|
+
function commit(value) {
|
|
29
|
+
emit('update:modelValue', value);
|
|
30
|
+
query.value = props.options.find((o) => o.value === value)?.label ?? value;
|
|
31
|
+
open.value = false;
|
|
32
|
+
}
|
|
33
|
+
function onPointer(e) {
|
|
34
|
+
if (!root.value?.contains(e.target))
|
|
35
|
+
open.value = false;
|
|
36
|
+
}
|
|
37
|
+
onMounted(() => document.addEventListener('pointerdown', onPointer));
|
|
38
|
+
onUnmounted(() => document.removeEventListener('pointerdown', onPointer));
|
|
39
|
+
return () => h('div', {
|
|
40
|
+
ref: root,
|
|
41
|
+
class: cn('bw-combobox', String(attrs.class || '')),
|
|
42
|
+
'data-bw-combobox': '',
|
|
43
|
+
...(open.value ? { 'data-bw-open': '' } : {}),
|
|
44
|
+
}, [
|
|
45
|
+
h('select', {
|
|
46
|
+
class: 'bw-input bw-combobox__floor',
|
|
47
|
+
id: props.id,
|
|
48
|
+
name: props.name,
|
|
49
|
+
value: props.modelValue,
|
|
50
|
+
required: props.required,
|
|
51
|
+
disabled: props.disabled,
|
|
52
|
+
tabindex: -1,
|
|
53
|
+
'aria-hidden': 'true',
|
|
54
|
+
hidden: true,
|
|
55
|
+
onChange: (e) => commit(e.target.value),
|
|
56
|
+
}, [
|
|
57
|
+
h('option', { value: '' }, 'Choose'),
|
|
58
|
+
...props.options.map((opt) => h('option', { value: opt.value, disabled: opt.disabled }, opt.label)),
|
|
59
|
+
]),
|
|
60
|
+
h('div', { class: 'bw-combobox__field' }, [
|
|
61
|
+
h('input', {
|
|
62
|
+
class: 'bw-input bw-combobox__input',
|
|
63
|
+
role: 'combobox',
|
|
64
|
+
'aria-expanded': open.value,
|
|
65
|
+
autocomplete: 'off',
|
|
66
|
+
disabled: props.disabled,
|
|
67
|
+
placeholder: props.placeholder,
|
|
68
|
+
value: open.value ? query.value : (selected.value?.label ?? query.value),
|
|
69
|
+
onFocus: () => {
|
|
70
|
+
open.value = true;
|
|
71
|
+
},
|
|
72
|
+
onInput: (e) => {
|
|
73
|
+
query.value = e.target.value;
|
|
74
|
+
open.value = true;
|
|
75
|
+
active.value = 0;
|
|
76
|
+
},
|
|
77
|
+
onKeydown: (e) => {
|
|
78
|
+
if (e.key === 'ArrowDown') {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
open.value = true;
|
|
81
|
+
active.value = Math.min(active.value + 1, Math.max(filtered.value.length - 1, 0));
|
|
82
|
+
}
|
|
83
|
+
else if (e.key === 'ArrowUp') {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
active.value = Math.max(active.value - 1, 0);
|
|
86
|
+
}
|
|
87
|
+
else if (e.key === 'Enter') {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
const opt = filtered.value[active.value];
|
|
90
|
+
if (opt && !opt.disabled)
|
|
91
|
+
commit(opt.value);
|
|
92
|
+
}
|
|
93
|
+
else if (e.key === 'Escape') {
|
|
94
|
+
open.value = false;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
h('ul', { class: 'bw-combobox__listbox', role: 'listbox' }, [
|
|
99
|
+
...filtered.value.map((opt, idx) => h('li', {
|
|
100
|
+
class: 'bw-combobox__option',
|
|
101
|
+
role: 'option',
|
|
102
|
+
'data-bw-value': opt.value,
|
|
103
|
+
'aria-selected': opt.value === props.modelValue,
|
|
104
|
+
...(idx === active.value ? { 'data-bw-active': '' } : {}),
|
|
105
|
+
onMousemove: () => {
|
|
106
|
+
active.value = idx;
|
|
107
|
+
},
|
|
108
|
+
onMousedown: (e) => {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
if (!opt.disabled)
|
|
111
|
+
commit(opt.value);
|
|
112
|
+
},
|
|
113
|
+
}, opt.label)),
|
|
114
|
+
h('li', { class: 'bw-combobox__empty', hidden: filtered.value.length > 0 }, props.emptyLabel),
|
|
115
|
+
]),
|
|
116
|
+
]),
|
|
117
|
+
]);
|
|
118
|
+
},
|
|
119
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare const DatePicker: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
id: StringConstructor;
|
|
3
|
+
name: StringConstructor;
|
|
4
|
+
modelValue: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
placeholder: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
disabled: BooleanConstructor;
|
|
13
|
+
required: BooleanConstructor;
|
|
14
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
|
+
id: StringConstructor;
|
|
18
|
+
name: StringConstructor;
|
|
19
|
+
modelValue: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
placeholder: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
disabled: BooleanConstructor;
|
|
28
|
+
required: BooleanConstructor;
|
|
29
|
+
}>> & Readonly<{
|
|
30
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
|
+
}>, {
|
|
32
|
+
disabled: boolean;
|
|
33
|
+
required: boolean;
|
|
34
|
+
modelValue: string;
|
|
35
|
+
placeholder: string;
|
|
36
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
37
|
+
export declare const DateRangePicker: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
38
|
+
start: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
end: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
startName: StringConstructor;
|
|
47
|
+
endName: StringConstructor;
|
|
48
|
+
disabled: BooleanConstructor;
|
|
49
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:start" | "update:end")[], "update:start" | "update:end", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
52
|
+
start: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
end: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
60
|
+
startName: StringConstructor;
|
|
61
|
+
endName: StringConstructor;
|
|
62
|
+
disabled: BooleanConstructor;
|
|
63
|
+
}>> & Readonly<{
|
|
64
|
+
"onUpdate:start"?: ((...args: any[]) => any) | undefined;
|
|
65
|
+
"onUpdate:end"?: ((...args: any[]) => any) | undefined;
|
|
66
|
+
}>, {
|
|
67
|
+
disabled: boolean;
|
|
68
|
+
start: string;
|
|
69
|
+
end: string;
|
|
70
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { defineComponent, h, onMounted, onUnmounted, ref } from 'vue';
|
|
2
|
+
import { cn } from './cn';
|
|
3
|
+
const MONTHS = [
|
|
4
|
+
'January',
|
|
5
|
+
'February',
|
|
6
|
+
'March',
|
|
7
|
+
'April',
|
|
8
|
+
'May',
|
|
9
|
+
'June',
|
|
10
|
+
'July',
|
|
11
|
+
'August',
|
|
12
|
+
'September',
|
|
13
|
+
'October',
|
|
14
|
+
'November',
|
|
15
|
+
'December',
|
|
16
|
+
];
|
|
17
|
+
const DOW = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
|
18
|
+
function parseISO(s) {
|
|
19
|
+
if (!s)
|
|
20
|
+
return null;
|
|
21
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
|
|
22
|
+
if (!m)
|
|
23
|
+
return null;
|
|
24
|
+
return new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]));
|
|
25
|
+
}
|
|
26
|
+
function toISO(d) {
|
|
27
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
28
|
+
}
|
|
29
|
+
function sameDay(a, b) {
|
|
30
|
+
return Boolean(a &&
|
|
31
|
+
b &&
|
|
32
|
+
a.getFullYear() === b.getFullYear() &&
|
|
33
|
+
a.getMonth() === b.getMonth() &&
|
|
34
|
+
a.getDate() === b.getDate());
|
|
35
|
+
}
|
|
36
|
+
function Calendar(opts) {
|
|
37
|
+
const first = new Date(opts.view.getFullYear(), opts.view.getMonth(), 1);
|
|
38
|
+
const startDow = (first.getDay() + 6) % 7;
|
|
39
|
+
const count = new Date(opts.view.getFullYear(), opts.view.getMonth() + 1, 0).getDate();
|
|
40
|
+
const cells = Array.from({ length: startDow }, () => null);
|
|
41
|
+
for (let day = 1; day <= count; day += 1) {
|
|
42
|
+
cells.push(new Date(opts.view.getFullYear(), opts.view.getMonth(), day));
|
|
43
|
+
}
|
|
44
|
+
return h('div', { class: 'bw-calendar' }, [
|
|
45
|
+
h('div', { class: 'bw-calendar__nav' }, [
|
|
46
|
+
h('button', {
|
|
47
|
+
type: 'button',
|
|
48
|
+
class: 'bw-btn bw-btn--ghost bw-btn--sm',
|
|
49
|
+
'aria-label': 'Previous month',
|
|
50
|
+
onClick: () => opts.onView(new Date(opts.view.getFullYear(), opts.view.getMonth() - 1, 1)),
|
|
51
|
+
}, 'Prev'),
|
|
52
|
+
h('p', { class: 'bw-calendar__title' }, `${MONTHS[opts.view.getMonth()]} ${opts.view.getFullYear()}`),
|
|
53
|
+
h('button', {
|
|
54
|
+
type: 'button',
|
|
55
|
+
class: 'bw-btn bw-btn--ghost bw-btn--sm',
|
|
56
|
+
'aria-label': 'Next month',
|
|
57
|
+
onClick: () => opts.onView(new Date(opts.view.getFullYear(), opts.view.getMonth() + 1, 1)),
|
|
58
|
+
}, 'Next'),
|
|
59
|
+
]),
|
|
60
|
+
h('div', { class: 'bw-calendar__grid' }, [
|
|
61
|
+
...DOW.map((d) => h('div', { class: 'bw-calendar__dow' }, d)),
|
|
62
|
+
...cells.map((date, i) => {
|
|
63
|
+
if (!date)
|
|
64
|
+
return h('div', { key: `blank-${i}` });
|
|
65
|
+
const inRange = Boolean(opts.rangeStart && opts.rangeEnd && date > opts.rangeStart && date < opts.rangeEnd);
|
|
66
|
+
const isSelected = sameDay(date, opts.selected ?? null) ||
|
|
67
|
+
sameDay(date, opts.rangeStart ?? null) ||
|
|
68
|
+
sameDay(date, opts.rangeEnd ?? null);
|
|
69
|
+
return h('button', {
|
|
70
|
+
key: toISO(date),
|
|
71
|
+
type: 'button',
|
|
72
|
+
class: 'bw-calendar__day',
|
|
73
|
+
'aria-label': toISO(date),
|
|
74
|
+
'aria-selected': isSelected,
|
|
75
|
+
...(inRange ? { 'data-bw-in-range': '' } : {}),
|
|
76
|
+
onClick: () => opts.onSelect(date),
|
|
77
|
+
}, String(date.getDate()));
|
|
78
|
+
}),
|
|
79
|
+
]),
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
export const DatePicker = defineComponent({
|
|
83
|
+
name: 'BwDatePicker',
|
|
84
|
+
props: {
|
|
85
|
+
id: String,
|
|
86
|
+
name: String,
|
|
87
|
+
modelValue: { type: String, default: '' },
|
|
88
|
+
placeholder: { type: String, default: 'YYYY-MM-DD' },
|
|
89
|
+
disabled: Boolean,
|
|
90
|
+
required: Boolean,
|
|
91
|
+
},
|
|
92
|
+
emits: ['update:modelValue'],
|
|
93
|
+
setup(props, { emit, attrs }) {
|
|
94
|
+
const open = ref(false);
|
|
95
|
+
const parsed = parseISO(props.modelValue) || new Date();
|
|
96
|
+
const view = ref(new Date(parsed.getFullYear(), parsed.getMonth(), 1));
|
|
97
|
+
const root = ref(null);
|
|
98
|
+
function onPointer(e) {
|
|
99
|
+
if (!root.value?.contains(e.target))
|
|
100
|
+
open.value = false;
|
|
101
|
+
}
|
|
102
|
+
onMounted(() => document.addEventListener('pointerdown', onPointer));
|
|
103
|
+
onUnmounted(() => document.removeEventListener('pointerdown', onPointer));
|
|
104
|
+
return () => h('div', { ref: root, class: cn('bw-date-picker-chrome', String(attrs.class || '')) }, [
|
|
105
|
+
h('div', { class: 'bw-date-picker-chrome__field' }, [
|
|
106
|
+
h('input', {
|
|
107
|
+
id: props.id,
|
|
108
|
+
name: props.name,
|
|
109
|
+
class: 'bw-input',
|
|
110
|
+
value: props.modelValue,
|
|
111
|
+
required: props.required,
|
|
112
|
+
disabled: props.disabled,
|
|
113
|
+
placeholder: props.placeholder,
|
|
114
|
+
autocomplete: 'off',
|
|
115
|
+
onInput: (e) => emit('update:modelValue', e.target.value),
|
|
116
|
+
onFocus: () => {
|
|
117
|
+
open.value = true;
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
h('button', {
|
|
121
|
+
type: 'button',
|
|
122
|
+
class: 'bw-date-picker-chrome__trigger',
|
|
123
|
+
'aria-label': 'Open calendar',
|
|
124
|
+
disabled: props.disabled,
|
|
125
|
+
onClick: () => {
|
|
126
|
+
open.value = !open.value;
|
|
127
|
+
},
|
|
128
|
+
}, 'Cal'),
|
|
129
|
+
]),
|
|
130
|
+
h('div', { class: 'bw-date-picker-chrome__panel', hidden: !open.value }, [
|
|
131
|
+
Calendar({
|
|
132
|
+
view: view.value,
|
|
133
|
+
selected: parseISO(props.modelValue),
|
|
134
|
+
onView: (next) => {
|
|
135
|
+
view.value = next;
|
|
136
|
+
},
|
|
137
|
+
onSelect: (date) => {
|
|
138
|
+
emit('update:modelValue', toISO(date));
|
|
139
|
+
open.value = false;
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
]),
|
|
143
|
+
]);
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
export const DateRangePicker = defineComponent({
|
|
147
|
+
name: 'BwDateRangePicker',
|
|
148
|
+
props: {
|
|
149
|
+
start: { type: String, default: '' },
|
|
150
|
+
end: { type: String, default: '' },
|
|
151
|
+
startName: String,
|
|
152
|
+
endName: String,
|
|
153
|
+
disabled: Boolean,
|
|
154
|
+
},
|
|
155
|
+
emits: ['update:start', 'update:end'],
|
|
156
|
+
setup(props, { emit, attrs }) {
|
|
157
|
+
const open = ref(false);
|
|
158
|
+
const parsed = parseISO(props.start) || new Date();
|
|
159
|
+
const view = ref(new Date(parsed.getFullYear(), parsed.getMonth(), 1));
|
|
160
|
+
const root = ref(null);
|
|
161
|
+
function onPointer(e) {
|
|
162
|
+
if (!root.value?.contains(e.target))
|
|
163
|
+
open.value = false;
|
|
164
|
+
}
|
|
165
|
+
onMounted(() => document.addEventListener('pointerdown', onPointer));
|
|
166
|
+
onUnmounted(() => document.removeEventListener('pointerdown', onPointer));
|
|
167
|
+
return () => h('div', {
|
|
168
|
+
ref: root,
|
|
169
|
+
class: cn('bw-date-picker-chrome', String(attrs.class || '')),
|
|
170
|
+
'data-bw-range': 'true',
|
|
171
|
+
}, [
|
|
172
|
+
h('div', { class: 'bw-date-picker-chrome__range' }, [
|
|
173
|
+
h('input', {
|
|
174
|
+
name: props.startName,
|
|
175
|
+
class: 'bw-input',
|
|
176
|
+
value: props.start,
|
|
177
|
+
disabled: props.disabled,
|
|
178
|
+
placeholder: 'From',
|
|
179
|
+
autocomplete: 'off',
|
|
180
|
+
onInput: (e) => emit('update:start', e.target.value),
|
|
181
|
+
onFocus: () => {
|
|
182
|
+
open.value = true;
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
h('span', { class: 'bw-date-picker-chrome__separator' }, 'to'),
|
|
186
|
+
h('input', {
|
|
187
|
+
name: props.endName,
|
|
188
|
+
class: 'bw-input',
|
|
189
|
+
value: props.end,
|
|
190
|
+
disabled: props.disabled,
|
|
191
|
+
placeholder: 'To',
|
|
192
|
+
autocomplete: 'off',
|
|
193
|
+
onInput: (e) => emit('update:end', e.target.value),
|
|
194
|
+
onFocus: () => {
|
|
195
|
+
open.value = true;
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
h('button', {
|
|
199
|
+
type: 'button',
|
|
200
|
+
class: 'bw-date-picker-chrome__trigger',
|
|
201
|
+
'aria-label': 'Open range calendar',
|
|
202
|
+
disabled: props.disabled,
|
|
203
|
+
onClick: () => {
|
|
204
|
+
open.value = !open.value;
|
|
205
|
+
},
|
|
206
|
+
}, 'Cal'),
|
|
207
|
+
]),
|
|
208
|
+
h('div', { class: 'bw-date-picker-chrome__panel', hidden: !open.value }, [
|
|
209
|
+
Calendar({
|
|
210
|
+
view: view.value,
|
|
211
|
+
rangeStart: parseISO(props.start),
|
|
212
|
+
rangeEnd: parseISO(props.end),
|
|
213
|
+
onView: (next) => {
|
|
214
|
+
view.value = next;
|
|
215
|
+
},
|
|
216
|
+
onSelect: (date) => {
|
|
217
|
+
const currentStart = parseISO(props.start);
|
|
218
|
+
const currentEnd = parseISO(props.end);
|
|
219
|
+
if (!currentStart || currentEnd) {
|
|
220
|
+
emit('update:start', toISO(date));
|
|
221
|
+
emit('update:end', '');
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (date < currentStart) {
|
|
225
|
+
emit('update:start', toISO(date));
|
|
226
|
+
emit('update:end', toISO(currentStart));
|
|
227
|
+
open.value = false;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
emit('update:end', toISO(date));
|
|
231
|
+
open.value = false;
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
]),
|
|
235
|
+
]);
|
|
236
|
+
},
|
|
237
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Button, ButtonLink, Badge, Card, Alert, Stack, Cluster, Grid, Container, Field, Form, FormActions, Label, Hint, FieldError, Input, Textarea, Select, Checkbox, Radio, TimeInput, DateTimeInput, SkipLink, ThemeToggle, } from './primitives';
|
|
2
|
+
export { Combobox } from './combobox';
|
|
3
|
+
export type { ComboboxOption } from './combobox';
|
|
4
|
+
export { DatePicker, DateRangePicker } from './date-picker';
|
|
5
|
+
export { Homepage, Landing, ContactForm } from './pages';
|
|
6
|
+
export { cn } from './cn';
|
|
7
|
+
export * as tokens from '@bwui/tokens';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Button, ButtonLink, Badge, Card, Alert, Stack, Cluster, Grid, Container, Field, Form, FormActions, Label, Hint, FieldError, Input, Textarea, Select, Checkbox, Radio, TimeInput, DateTimeInput, SkipLink, ThemeToggle, } from './primitives';
|
|
2
|
+
export { Combobox } from './combobox';
|
|
3
|
+
export { DatePicker, DateRangePicker } from './date-picker';
|
|
4
|
+
export { Homepage, Landing, ContactForm } from './pages';
|
|
5
|
+
export { cn } from './cn';
|
|
6
|
+
export * as tokens from '@bwui/tokens';
|
package/dist/pages.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import { type ComboboxOption } from './combobox';
|
|
3
|
+
export declare const Homepage: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
brand: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
title: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
description: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
brand: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
title: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
description: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
}>> & Readonly<{}>, {
|
|
32
|
+
title: string;
|
|
33
|
+
brand: string;
|
|
34
|
+
description: string;
|
|
35
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
36
|
+
export declare const Landing: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
37
|
+
brand: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
title: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
description: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
52
|
+
brand: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
title: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
60
|
+
description: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
default: string;
|
|
63
|
+
};
|
|
64
|
+
}>> & Readonly<{}>, {
|
|
65
|
+
title: string;
|
|
66
|
+
brand: string;
|
|
67
|
+
description: string;
|
|
68
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
69
|
+
export declare const ContactForm: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
70
|
+
topics: {
|
|
71
|
+
type: PropType<ComboboxOption[]>;
|
|
72
|
+
default: () => {
|
|
73
|
+
value: string;
|
|
74
|
+
label: string;
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
77
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
78
|
+
[key: string]: any;
|
|
79
|
+
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
80
|
+
topics: {
|
|
81
|
+
type: PropType<ComboboxOption[]>;
|
|
82
|
+
default: () => {
|
|
83
|
+
value: string;
|
|
84
|
+
label: string;
|
|
85
|
+
}[];
|
|
86
|
+
};
|
|
87
|
+
}>> & Readonly<{}>, {
|
|
88
|
+
topics: ComboboxOption[];
|
|
89
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|