@vielzeug/refine 1.5.1 → 1.5.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/dist/async.cjs +9 -9
- package/dist/async.cjs.map +1 -1
- package/dist/async.js +30 -31
- package/dist/async.js.map +1 -1
- package/dist/button.cjs +6 -6
- package/dist/button.cjs.map +1 -1
- package/dist/button.js +29 -30
- package/dist/button.js.map +1 -1
- package/dist/calendar.cjs +44 -44
- package/dist/calendar.cjs.map +1 -1
- package/dist/calendar.js +115 -117
- package/dist/calendar.js.map +1 -1
- package/dist/checkbox-group.cjs +7 -7
- package/dist/checkbox-group.cjs.map +1 -1
- package/dist/checkbox-group.js +71 -73
- package/dist/checkbox-group.js.map +1 -1
- package/dist/checkbox.cjs +3 -3
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.js +28 -29
- package/dist/checkbox.js.map +1 -1
- package/dist/code-window.cjs +7 -7
- package/dist/code-window.cjs.map +1 -1
- package/dist/code-window.js +17 -18
- package/dist/code-window.js.map +1 -1
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.cjs.map +1 -1
- package/dist/combobox.js +11 -12
- package/dist/combobox.js.map +1 -1
- package/dist/custom-elements.json +5267 -5267
- package/dist/datagrid.cjs +66 -66
- package/dist/datagrid.cjs.map +1 -1
- package/dist/datagrid.js +267 -268
- package/dist/datagrid.js.map +1 -1
- package/dist/date-picker.cjs +11 -11
- package/dist/date-picker.cjs.map +1 -1
- package/dist/date-picker.js +8 -9
- package/dist/date-picker.js.map +1 -1
- package/dist/file-input.cjs +6 -6
- package/dist/file-input.cjs.map +1 -1
- package/dist/file-input.js +50 -51
- package/dist/file-input.js.map +1 -1
- package/dist/grid.cjs +1 -1
- package/dist/grid.cjs.map +1 -1
- package/dist/grid.js +47 -48
- package/dist/grid.js.map +1 -1
- package/dist/icon.cjs +1 -1
- package/dist/icon.cjs.map +1 -1
- package/dist/icon.js +26 -27
- package/dist/icon.js.map +1 -1
- package/dist/input.cjs +20 -20
- package/dist/input.cjs.map +1 -1
- package/dist/input.js +98 -100
- package/dist/input.js.map +1 -1
- package/dist/message-composer.cjs +18 -18
- package/dist/message-composer.cjs.map +1 -1
- package/dist/message-composer.js +113 -115
- package/dist/message-composer.js.map +1 -1
- package/dist/navbar.cjs +11 -11
- package/dist/navbar.cjs.map +1 -1
- package/dist/navbar.js +78 -79
- package/dist/navbar.js.map +1 -1
- package/dist/otp-input.cjs +4 -4
- package/dist/otp-input.cjs.map +1 -1
- package/dist/otp-input.js +31 -32
- package/dist/otp-input.js.map +1 -1
- package/dist/progress.cjs +13 -13
- package/dist/progress.cjs.map +1 -1
- package/dist/progress.js +45 -46
- package/dist/progress.js.map +1 -1
- package/dist/radio-group.cjs +5 -5
- package/dist/radio-group.cjs.map +1 -1
- package/dist/radio-group.js +83 -85
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.cjs +3 -3
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.js +27 -28
- package/dist/radio.js.map +1 -1
- package/dist/rating.cjs +4 -4
- package/dist/rating.cjs.map +1 -1
- package/dist/rating.js +30 -31
- package/dist/rating.js.map +1 -1
- package/dist/select.cjs +4 -4
- package/dist/select.cjs.map +1 -1
- package/dist/select.js +88 -89
- package/dist/select.js.map +1 -1
- package/dist/sidebar.cjs +11 -11
- package/dist/sidebar.cjs.map +1 -1
- package/dist/sidebar.js +97 -98
- package/dist/sidebar.js.map +1 -1
- package/dist/skeleton.cjs +3 -3
- package/dist/skeleton.cjs.map +1 -1
- package/dist/skeleton.js +23 -24
- package/dist/skeleton.js.map +1 -1
- package/dist/slider.cjs +3 -3
- package/dist/slider.cjs.map +1 -1
- package/dist/slider.js +65 -66
- package/dist/slider.js.map +1 -1
- package/dist/switch.cjs +3 -3
- package/dist/switch.cjs.map +1 -1
- package/dist/switch.js +23 -24
- package/dist/switch.js.map +1 -1
- package/dist/tab-panel.cjs +7 -7
- package/dist/tab-panel.cjs.map +1 -1
- package/dist/tab-panel.js +21 -23
- package/dist/tab-panel.js.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +4 -5
- package/dist/testing.js.map +1 -1
- package/dist/textarea.cjs +13 -13
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.js +92 -94
- package/dist/textarea.js.map +1 -1
- package/dist/time-picker.cjs +9 -9
- package/dist/time-picker.cjs.map +1 -1
- package/dist/time-picker.js +47 -48
- package/dist/time-picker.js.map +1 -1
- package/package.json +1 -1
- package/dist/ore/dist/_dev.cjs +0 -2
- package/dist/ore/dist/_dev.cjs.map +0 -1
- package/dist/ore/dist/_dev.js +0 -12
- package/dist/ore/dist/_dev.js.map +0 -1
- package/dist/ore/dist/base-element.cjs +0 -2
- package/dist/ore/dist/base-element.cjs.map +0 -1
- package/dist/ore/dist/base-element.js +0 -158
- package/dist/ore/dist/base-element.js.map +0 -1
- package/dist/ore/dist/context.cjs +0 -2
- package/dist/ore/dist/context.cjs.map +0 -1
- package/dist/ore/dist/context.js +0 -11
- package/dist/ore/dist/context.js.map +0 -1
- package/dist/ore/dist/define.cjs +0 -2
- package/dist/ore/dist/define.cjs.map +0 -1
- package/dist/ore/dist/define.js +0 -27
- package/dist/ore/dist/define.js.map +0 -1
- package/dist/ore/dist/directives/classMap.cjs +0 -1
- package/dist/ore/dist/directives/classMap.js +0 -1
- package/dist/ore/dist/directives/each.cjs +0 -1
- package/dist/ore/dist/directives/each.js +0 -5
- package/dist/ore/dist/directives/live.cjs +0 -2
- package/dist/ore/dist/directives/live.cjs.map +0 -1
- package/dist/ore/dist/directives/live.js +0 -6
- package/dist/ore/dist/directives/live.js.map +0 -1
- package/dist/ore/dist/directives/model.cjs +0 -1
- package/dist/ore/dist/directives/model.js +0 -3
- package/dist/ore/dist/directives/raw.cjs +0 -2
- package/dist/ore/dist/directives/raw.cjs.map +0 -1
- package/dist/ore/dist/directives/raw.js +0 -38
- package/dist/ore/dist/directives/raw.js.map +0 -1
- package/dist/ore/dist/directives/styleMap.cjs +0 -2
- package/dist/ore/dist/directives/styleMap.cjs.map +0 -1
- package/dist/ore/dist/directives/styleMap.js +0 -20
- package/dist/ore/dist/directives/styleMap.js.map +0 -1
- package/dist/ore/dist/directives/when.cjs +0 -2
- package/dist/ore/dist/directives/when.cjs.map +0 -1
- package/dist/ore/dist/directives/when.js +0 -38
- package/dist/ore/dist/directives/when.js.map +0 -1
- package/dist/ore/dist/directives.cjs +0 -1
- package/dist/ore/dist/directives.js +0 -8
- package/dist/ore/dist/errors.cjs +0 -3
- package/dist/ore/dist/errors.cjs.map +0 -1
- package/dist/ore/dist/errors.js +0 -50
- package/dist/ore/dist/errors.js.map +0 -1
- package/dist/ore/dist/forms/context.cjs +0 -2
- package/dist/ore/dist/forms/context.cjs.map +0 -1
- package/dist/ore/dist/forms/context.js +0 -6
- package/dist/ore/dist/forms/context.js.map +0 -1
- package/dist/ore/dist/forms/field.cjs +0 -2
- package/dist/ore/dist/forms/field.cjs.map +0 -1
- package/dist/ore/dist/forms/field.js +0 -42
- package/dist/ore/dist/forms/field.js.map +0 -1
- package/dist/ore/dist/forms.cjs +0 -1
- package/dist/ore/dist/forms.js +0 -3
- package/dist/ore/dist/observers/intersection-observe.cjs +0 -2
- package/dist/ore/dist/observers/intersection-observe.cjs.map +0 -1
- package/dist/ore/dist/observers/intersection-observe.js +0 -12
- package/dist/ore/dist/observers/intersection-observe.js.map +0 -1
- package/dist/ore/dist/observers/media-observe.cjs +0 -1
- package/dist/ore/dist/observers/media-observe.js +0 -1
- package/dist/ore/dist/observers/mutation-observe.cjs +0 -1
- package/dist/ore/dist/observers/mutation-observe.js +0 -1
- package/dist/ore/dist/observers/resize-observe.cjs +0 -2
- package/dist/ore/dist/observers/resize-observe.cjs.map +0 -1
- package/dist/ore/dist/observers/resize-observe.js +0 -20
- package/dist/ore/dist/observers/resize-observe.js.map +0 -1
- package/dist/ore/dist/observers.cjs +0 -1
- package/dist/ore/dist/observers.js +0 -5
- package/dist/ore/dist/props.cjs +0 -2
- package/dist/ore/dist/props.cjs.map +0 -1
- package/dist/ore/dist/props.js +0 -56
- package/dist/ore/dist/props.js.map +0 -1
- package/dist/ore/dist/runtime.cjs +0 -2
- package/dist/ore/dist/runtime.cjs.map +0 -1
- package/dist/ore/dist/runtime.js +0 -25
- package/dist/ore/dist/runtime.js.map +0 -1
- package/dist/ore/dist/testing/flush.cjs +0 -2
- package/dist/ore/dist/testing/flush.cjs.map +0 -1
- package/dist/ore/dist/testing/flush.js +0 -11
- package/dist/ore/dist/testing/flush.js.map +0 -1
- package/dist/ore/dist/testing/mount.cjs +0 -2
- package/dist/ore/dist/testing/mount.cjs.map +0 -1
- package/dist/ore/dist/testing/mount.js +0 -94
- package/dist/ore/dist/testing/mount.js.map +0 -1
- package/dist/ore/dist/testing/query.cjs +0 -2
- package/dist/ore/dist/testing/query.cjs.map +0 -1
- package/dist/ore/dist/testing/query.js +0 -12
- package/dist/ore/dist/testing/query.js.map +0 -1
- package/dist/ore/dist/testing/render-hook.cjs +0 -1
- package/dist/ore/dist/testing/render-hook.js +0 -3
- package/dist/ore/dist/testing/testing.cjs +0 -1
- package/dist/ore/dist/testing/testing.js +0 -4
- package/dist/ore/dist/testing/wait.cjs +0 -1
- package/dist/ore/dist/testing/wait.js +0 -1
- package/dist/ore/dist/testing.cjs +0 -1
- package/dist/ore/dist/testing.js +0 -6
- package/dist/ore/dist/types/bindings.cjs +0 -2
- package/dist/ore/dist/types/bindings.cjs.map +0 -1
- package/dist/ore/dist/types/bindings.js +0 -15
- package/dist/ore/dist/types/bindings.js.map +0 -1
- package/dist/ore/dist/types.cjs +0 -2
- package/dist/ore/dist/types.cjs.map +0 -1
- package/dist/ore/dist/types.js +0 -15
- package/dist/ore/dist/types.js.map +0 -1
- package/dist/ore/dist/utils/css.cjs +0 -2
- package/dist/ore/dist/utils/css.cjs.map +0 -1
- package/dist/ore/dist/utils/css.js +0 -18
- package/dist/ore/dist/utils/css.js.map +0 -1
- package/dist/ore/dist/utils/dom.cjs +0 -2
- package/dist/ore/dist/utils/dom.cjs.map +0 -1
- package/dist/ore/dist/utils/dom.js +0 -43
- package/dist/ore/dist/utils/dom.js.map +0 -1
- package/dist/ore/dist/utils/id.cjs +0 -2
- package/dist/ore/dist/utils/id.cjs.map +0 -1
- package/dist/ore/dist/utils/id.js +0 -4
- package/dist/ore/dist/utils/id.js.map +0 -1
package/dist/message-composer.js
CHANGED
|
@@ -1,128 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import "
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import { bind as C, define as w, html as T, inject as E, onCleanup as D, onElement as O, prop as k, ref as A, useEmit as j, useSlots as M } from "@vielzeug/ore";
|
|
20
|
-
import { computed as N, watch as P } from "@vielzeug/ripple";
|
|
1
|
+
import { coarsePointerMixin as e, reducedMotionMixin as t } from "./styles/mixins/accessibility.css.js";
|
|
2
|
+
import { sizeVariantMixin as n } from "./styles/mixins/shape.css.js";
|
|
3
|
+
import { disabledLoadingMixin as r } from "./styles/mixins/states.css.js";
|
|
4
|
+
import { colorThemeMixin as i, forcedColorsFocusMixin as a, forcedColorsMixin as o } from "./styles/mixins/theme.css.js";
|
|
5
|
+
import { disablableBundle as s, loadableBundle as c, sizableBundle as l, themableBundle as u } from "./shared/prop-bundles.js";
|
|
6
|
+
import { MESSAGE_COMPOSER_SIZE_PRESET as d } from "./shared/size-presets.js";
|
|
7
|
+
import { lifecycleSignal as f } from "./headless/ore.js";
|
|
8
|
+
import { createAutoResize as p } from "./headless/auto-resize.js";
|
|
9
|
+
import { counterClassName as m } from "./headless/field-base.js";
|
|
10
|
+
import { createTextField as h } from "./headless/text-field.js";
|
|
11
|
+
import { createComposerControl as g } from "./headless/composer.js";
|
|
12
|
+
import { errorAttr as _ } from "./inputs/shared/field-binding.js";
|
|
13
|
+
import { FORM_CTX as v, useFormContext as y } from "./inputs/shared/form-context.js";
|
|
14
|
+
import b from "./inputs/message-composer/message-composer.css.js";
|
|
15
|
+
import { bind as x, define as S, html as C, inject as w, onCleanup as T, onElement as E, prop as D, ref as O, useEmit as k, useSlots as A } from "@vielzeug/ore";
|
|
16
|
+
import { live as j } from "@vielzeug/ore/directives";
|
|
17
|
+
import { computed as M, watch as N } from "@vielzeug/ripple";
|
|
18
|
+
import { useField as P } from "@vielzeug/ore/forms";
|
|
21
19
|
//#region src/inputs/message-composer/message-composer.ts
|
|
22
20
|
var F = "Send message", I = "arrow-up", L = "ore-message-composer";
|
|
23
|
-
|
|
21
|
+
S(L, {
|
|
24
22
|
formAssociated: !0,
|
|
25
23
|
props: {
|
|
26
|
-
...d,
|
|
27
24
|
...u,
|
|
28
|
-
...c,
|
|
29
25
|
...l,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"send-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
...s,
|
|
27
|
+
...c,
|
|
28
|
+
"clear-on-send": D.bool(!0),
|
|
29
|
+
error: D.string(),
|
|
30
|
+
fullwidth: D.bool(!1),
|
|
31
|
+
helper: D.string(),
|
|
32
|
+
label: D.string(),
|
|
33
|
+
maxlength: D.json(void 0),
|
|
34
|
+
name: D.string(),
|
|
35
|
+
placeholder: D.string(),
|
|
36
|
+
readonly: D.bool(!1),
|
|
37
|
+
ref: D.json(void 0),
|
|
38
|
+
required: D.bool(!1),
|
|
39
|
+
rows: D.json(void 0),
|
|
40
|
+
"send-icon": D.string(),
|
|
41
|
+
"send-label": D.string(),
|
|
42
|
+
"send-shortcut": D.oneOf(["enter", "mod+enter"], "enter"),
|
|
43
|
+
value: D.string(),
|
|
44
|
+
variant: D.string()
|
|
47
45
|
},
|
|
48
|
-
setup(
|
|
49
|
-
let
|
|
50
|
-
disabled:
|
|
51
|
-
error:
|
|
52
|
-
helper:
|
|
53
|
-
maxLength:
|
|
54
|
-
onInput: (e,
|
|
46
|
+
setup(e) {
|
|
47
|
+
let t = k(), n = A(), r = w(v), i = y(e, r), a = i.disabled, o = f(T), s = O(), c = p(), l = h({
|
|
48
|
+
disabled: a,
|
|
49
|
+
error: e.error,
|
|
50
|
+
helper: e.helper,
|
|
51
|
+
maxLength: e.maxlength,
|
|
52
|
+
onInput: (e, n) => t("input", {
|
|
55
53
|
originalEvent: e,
|
|
56
|
-
value:
|
|
54
|
+
value: n
|
|
57
55
|
}),
|
|
58
56
|
prefix: "composer",
|
|
59
|
-
readonly:
|
|
60
|
-
required:
|
|
61
|
-
signal:
|
|
62
|
-
validateOn:
|
|
63
|
-
value:
|
|
57
|
+
readonly: e.readonly,
|
|
58
|
+
required: e.required,
|
|
59
|
+
signal: o,
|
|
60
|
+
validateOn: r?.validateOn,
|
|
61
|
+
value: e.value
|
|
64
62
|
});
|
|
65
|
-
|
|
66
|
-
disabled:
|
|
63
|
+
l.attachFormField(P({
|
|
64
|
+
disabled: l.disabled,
|
|
67
65
|
onReset: () => {
|
|
68
|
-
|
|
66
|
+
l.reset(), c.recompute();
|
|
69
67
|
},
|
|
70
68
|
toFormValue: (e) => e,
|
|
71
|
-
validationMessage:
|
|
72
|
-
validity:
|
|
73
|
-
value:
|
|
69
|
+
validationMessage: l.validationMessage,
|
|
70
|
+
validity: l.validity,
|
|
71
|
+
value: l.value
|
|
74
72
|
}));
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
originalEvent:
|
|
78
|
-
value:
|
|
79
|
-
}) &&
|
|
73
|
+
function u(n) {
|
|
74
|
+
t("send", {
|
|
75
|
+
originalEvent: n,
|
|
76
|
+
value: l.value.value.trim()
|
|
77
|
+
}) && e["clear-on-send"].value !== !1 && (l.clear(), c.recompute(), s.value?.focus());
|
|
80
78
|
}
|
|
81
|
-
let
|
|
82
|
-
disabled:
|
|
83
|
-
loading:
|
|
84
|
-
onSend:
|
|
85
|
-
sendShortcut:
|
|
86
|
-
value:
|
|
79
|
+
let d = g({
|
|
80
|
+
disabled: a,
|
|
81
|
+
loading: M(() => !!e.loading.value),
|
|
82
|
+
onSend: u,
|
|
83
|
+
sendShortcut: e["send-shortcut"],
|
|
84
|
+
value: l.value
|
|
87
85
|
});
|
|
88
|
-
return
|
|
89
|
-
let n =
|
|
90
|
-
|
|
91
|
-
let a =
|
|
92
|
-
|
|
86
|
+
return E(s, (t) => {
|
|
87
|
+
let n = l.wire(t), r = c.wire(t), i = (e) => d.handleKeydown(e);
|
|
88
|
+
t.addEventListener("keydown", i), e.ref.value?.(t);
|
|
89
|
+
let a = N(e.ref, (e) => {
|
|
90
|
+
e?.(t);
|
|
93
91
|
});
|
|
94
92
|
return () => {
|
|
95
|
-
|
|
93
|
+
t.removeEventListener("keydown", i), n(), r(), a.dispose(), e.ref.value?.(null);
|
|
96
94
|
};
|
|
97
|
-
}),
|
|
98
|
-
error:
|
|
99
|
-
size:
|
|
100
|
-
variant:
|
|
101
|
-
} }),
|
|
95
|
+
}), x({ attr: {
|
|
96
|
+
error: _(l.errorText),
|
|
97
|
+
size: i.size,
|
|
98
|
+
variant: i.variant
|
|
99
|
+
} }), C`
|
|
102
100
|
<div class="composer" part="composer">
|
|
103
101
|
<textarea
|
|
104
102
|
class="field"
|
|
105
103
|
part="field"
|
|
106
|
-
ref="${
|
|
107
|
-
:rows="${() =>
|
|
108
|
-
:name="${() =>
|
|
109
|
-
:placeholder="${() =>
|
|
110
|
-
:maxlength="${() =>
|
|
111
|
-
?disabled="${
|
|
112
|
-
?readonly="${() => !!
|
|
113
|
-
?required="${() => !!
|
|
114
|
-
:value="${
|
|
115
|
-
:aria-label="${() =>
|
|
116
|
-
:aria-keyshortcuts="${
|
|
117
|
-
:aria-describedby="${
|
|
118
|
-
:aria-errormessage="${
|
|
119
|
-
:aria-invalid="${
|
|
120
|
-
<span class="${() =>
|
|
121
|
-
<div id="${
|
|
122
|
-
${() =>
|
|
104
|
+
ref="${s}"
|
|
105
|
+
:rows="${() => e.rows.value ?? 1}"
|
|
106
|
+
:name="${() => e.name.value ?? ""}"
|
|
107
|
+
:placeholder="${() => e.placeholder.value ?? "Message…"}"
|
|
108
|
+
:maxlength="${() => e.maxlength.value}"
|
|
109
|
+
?disabled="${a}"
|
|
110
|
+
?readonly="${() => !!e.readonly.value}"
|
|
111
|
+
?required="${() => !!e.required.value}"
|
|
112
|
+
:value="${j(l.value)}"
|
|
113
|
+
:aria-label="${() => e.label.value || "Message"}"
|
|
114
|
+
:aria-keyshortcuts="${d.keyShortcutsHint}"
|
|
115
|
+
:aria-describedby="${l.ariaDescribedBy}"
|
|
116
|
+
:aria-errormessage="${l.ariaErrorMessage}"
|
|
117
|
+
:aria-invalid="${l.ariaInvalid}"></textarea>
|
|
118
|
+
<span class="${() => m(l.counter?.value)}" aria-live="polite" ?hidden="${() => !l.counter}">${() => l.counter?.value.counterText.replace(" / ", "/") ?? ""}</span>
|
|
119
|
+
<div id="${l.assistiveId}" class="helper-text" aria-live="polite" part="helper" ?hidden="${() => !!l.errorText.value || !l.helperText.value}">
|
|
120
|
+
${() => l.helperText.value}
|
|
123
121
|
</div>
|
|
124
|
-
<div id="${
|
|
125
|
-
${() =>
|
|
122
|
+
<div id="${l.errorId}" class="helper-text" role="alert" part="error" ?hidden="${() => !l.errorText.value}">
|
|
123
|
+
${() => l.errorText.value}
|
|
126
124
|
</div>
|
|
127
125
|
<div class="toolbar" part="toolbar">
|
|
128
126
|
<div class="toolbar-start" part="toolbar-start">
|
|
@@ -131,19 +129,19 @@ w(L, {
|
|
|
131
129
|
<div class="toolbar-end" part="toolbar-end">
|
|
132
130
|
<slot name="suffix"></slot>
|
|
133
131
|
<slot name="send"></slot>
|
|
134
|
-
${() =>
|
|
132
|
+
${() => n.has("send").value ? "" : C`<ore-button
|
|
135
133
|
class="send-btn"
|
|
136
134
|
part="send-button"
|
|
137
135
|
type="button"
|
|
138
136
|
icon-only
|
|
139
137
|
variant="solid"
|
|
140
|
-
:color="${() =>
|
|
141
|
-
:size="${
|
|
142
|
-
:label="${() =>
|
|
143
|
-
?loading="${() => !!
|
|
144
|
-
?disabled="${() => !
|
|
145
|
-
@click="${(e) =>
|
|
146
|
-
<ore-icon name="${() =>
|
|
138
|
+
:color="${() => e.color.value || "primary"}"
|
|
139
|
+
:size="${i.size}"
|
|
140
|
+
:label="${() => e["send-label"].value || F}"
|
|
141
|
+
?loading="${() => !!e.loading.value}"
|
|
142
|
+
?disabled="${() => !d.canSend.value}"
|
|
143
|
+
@click="${(e) => d.send(e)}">
|
|
144
|
+
<ore-icon name="${() => e["send-icon"].value || I}" size="16"></ore-icon>
|
|
147
145
|
</ore-button>`}
|
|
148
146
|
</div>
|
|
149
147
|
</div>
|
|
@@ -152,14 +150,14 @@ w(L, {
|
|
|
152
150
|
},
|
|
153
151
|
shadow: { delegatesFocus: !0 },
|
|
154
152
|
styles: [
|
|
155
|
-
a,
|
|
156
|
-
t,
|
|
157
|
-
n,
|
|
158
153
|
i,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
r
|
|
162
|
-
|
|
154
|
+
e,
|
|
155
|
+
t,
|
|
156
|
+
r,
|
|
157
|
+
o,
|
|
158
|
+
a(".field"),
|
|
159
|
+
n(d),
|
|
160
|
+
b
|
|
163
161
|
]
|
|
164
162
|
});
|
|
165
163
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-composer.js","names":[],"sources":["../src/inputs/message-composer/message-composer.ts"],"sourcesContent":["import { define, html, inject, prop, ref, bind, onCleanup, onElement, useEmit, useSlots } from '@vielzeug/ore';\nimport { live } from '@vielzeug/ore/directives';\nimport { useField } from '@vielzeug/ore/forms';\nimport { computed, watch } from '@vielzeug/ripple';\n\nimport type { ComponentSize, ThemeColor, VisualVariant } from '../../types';\n\nimport {\n counterClassName,\n createAutoResize,\n createComposerControl,\n createTextField,\n lifecycleSignal,\n type SendShortcut,\n} from '../../headless';\nimport {\n disablableBundle,\n loadableBundle,\n MESSAGE_COMPOSER_SIZE_PRESET,\n sizableBundle,\n themableBundle,\n} from '../../shared';\nimport {\n colorThemeMixin,\n coarsePointerMixin,\n disabledLoadingMixin,\n forcedColorsFocusMixin,\n forcedColorsMixin,\n reducedMotionMixin,\n sizeVariantMixin,\n} from '../../styles';\nimport { errorAttr } from '../shared/field-binding';\nimport { FORM_CTX, useFormContext } from '../shared/form-context';\nimport '../../content/icon/icon';\nimport '../button/button';\nimport componentStyles from './message-composer.css?inline';\n\nexport type { SendShortcut } from '../../headless';\n\nconst DEFAULT_SEND_LABEL = 'Send message';\nconst SEND_ICON = 'arrow-up';\n\n/** Events emitted by the message composer */\nexport type OreMessageComposerEvents = {\n /** Fired on every keystroke with the current value. */\n input: { originalEvent: Event; value: string };\n /**\n * Fired for a send attempt (the resolved `send-shortcut` or the send button) while the\n * composer isn't blank/disabled/loading. Cancelable — call `preventDefault()` to keep the\n * current text in the field instead of the default clear + refocus.\n */\n send: { originalEvent: KeyboardEvent | MouseEvent; value: string };\n};\n\n/** Message composer properties */\nexport type OreMessageComposerProps = {\n /** Clear the value and refocus after a non-cancelled `send` (default `true`) */\n 'clear-on-send'?: boolean;\n /** Theme color (card focus ring + default send button color) */\n color?: ThemeColor;\n /** Disable the whole composer (field, slots, and send action) */\n disabled?: boolean;\n /** Error message shown below the field */\n error?: string;\n /** Stretch the composer to the full width of its container */\n fullwidth?: boolean;\n /** Helper text shown below the field */\n helper?: string;\n /** Accessible name for the field — never rendered visually, only as `aria-label` */\n label?: string;\n /** Blocks further sends (e.g. a send is already in flight) without disabling editing */\n loading?: boolean;\n /** Maximum character count; shows a counter */\n maxlength?: number;\n /** Form field name */\n name?: string;\n /** Placeholder text */\n placeholder?: string;\n /** Make the field read-only */\n readonly?: boolean;\n /**\n * JS-only callback fired with the inner `<textarea>` element when it mounts, and with\n * `null` when it unmounts. Set as a JS property: `composer.ref = (el) => { ... }`.\n */\n ref?: ((el: HTMLTextAreaElement | null) => void) | null;\n /** Require a non-blank value for `<ore-form>` validation */\n required?: boolean;\n /** Number of visible rows before auto-resize grows the field */\n rows?: number;\n /** Lucide icon name for the default send button (default `'arrow-up'`) */\n 'send-icon'?: string;\n /** Accessible label for the send button (default `'Send message'`) */\n 'send-label'?: string;\n /** Keyboard shortcut that sends: 'enter' (Shift+Enter for a newline) or 'mod+enter' (Enter always inserts a newline; Ctrl/Cmd+Enter sends) */\n 'send-shortcut'?: SendShortcut;\n /** Component size */\n size?: ComponentSize;\n /** Current text value */\n value?: string;\n /** Visual variant of the card — same variant set as `ore-textarea`, applied to the card. */\n variant?: Exclude<VisualVariant, 'frost' | 'text'>;\n};\n\n/**\n * A message/comment composer — a card with an auto-resizing field on top and a toolbar row\n * below it, built directly on the same headless primitives as `ore-textarea` (`createTextField`,\n * `createAutoResize`) rather than composing `ore-textarea` itself. Nesting a fully-styled sibling\n * component and suppressing most of its chrome (as an earlier version of this component did) is\n * a leaky composition — this owns its single `<textarea>` outright, so there's exactly one\n * implementation of the field's appearance to reason about, not two fighting each other.\n *\n * Handles the send gesture (Enter to send, Shift+Enter for a newline, or a Ctrl/Cmd+Enter\n * alternative), IME-safe composition, and clear-and-refocus after sending.\n *\n * @element ore-message-composer\n *\n * @attr {string} value - Current text value\n * @attr {string} placeholder - Placeholder text\n * @attr {string} label - Accessible name for the field (not rendered visually)\n * @attr {string} name - Form field name\n * @attr {string} helper - Helper text shown below the field\n * @attr {string} error - Error message shown below the field\n * @attr {boolean} disabled - Disable the whole composer\n * @attr {boolean} readonly - Read-only mode\n * @attr {boolean} required - Require a non-blank value for `<ore-form>` validation\n * @attr {boolean} loading - Blocks further sends without disabling editing\n * @attr {number} maxlength - Max character count; shows a counter\n * @attr {number} rows - Visible rows before auto-resize grows the field (default 1)\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} variant - Visual variant of the card: 'solid' | 'flat' | 'bordered' | 'outline' | 'ghost'\n * @attr {string} size - 'sm' | 'md' | 'lg'\n * @attr {boolean} fullwidth - Stretch to the full width of the container\n * @attr {string} send-icon - Lucide icon name for the default send button (default 'arrow-up')\n * @attr {string} send-label - Accessible label for the send button (default 'Send message')\n * @attr {string} send-shortcut - 'enter' (default) | 'mod+enter'\n * @attr {boolean} clear-on-send - Clear the value and refocus after a non-cancelled send (default true)\n *\n * @fires input - Fired on every keystroke. detail: { value, originalEvent }\n * @fires send - Fired on a send attempt. Cancelable. detail: { value, originalEvent }\n *\n * @slot prefix - Content at the start of the toolbar row (e.g. an attach menu)\n * @slot suffix - Content at the end of the toolbar row, before the send button (e.g. a model picker)\n * @slot send - Replaces the default send button entirely — the only supported way to customize it\n *\n * @cssprop --message-composer-bg - Card background color\n * @cssprop --message-composer-border-color - Card border color\n * @cssprop --message-composer-radius - Card border radius\n * @cssprop --message-composer-padding - Card inner padding\n * @cssprop --message-composer-gap - Gap between the field/toolbar rows and between toolbar items\n * @cssprop --message-composer-placeholder-color - Field placeholder text color\n * @cssprop --message-composer-min-height - Minimum field height (default one line)\n * @cssprop --message-composer-hover-bg - Card background on hover (flat/ghost variants)\n * @cssprop --message-composer-hover-border-color - Card border on hover (flat/bordered variants)\n * @cssprop --message-composer-focus-bg - Card background when focused (flat variant)\n * @cssprop --message-composer-focus-border-color - Card border when focused (flat variant)\n *\n * @part composer - Root card container\n * @part field - The native `<textarea>` element\n * @part helper - Helper text element\n * @part error - Error text element (`role=\"alert\"`)\n * @part toolbar - Toolbar row below the field\n * @part toolbar-start - Toolbar group holding the `prefix` slot\n * @part toolbar-end - Toolbar group holding the `suffix` slot and the send button\n * @part send-button - The default send button (absent when the `send` slot is used)\n *\n * @example\n * ```html\n * <ore-message-composer placeholder=\"Message…\" send-shortcut=\"mod+enter\"></ore-message-composer>\n * ```\n */\nexport const MESSAGE_COMPOSER_TAG = 'ore-message-composer' as const;\ndefine<OreMessageComposerProps>(MESSAGE_COMPOSER_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...loadableBundle,\n 'clear-on-send': prop.bool(true),\n error: prop.string(),\n fullwidth: prop.bool(false),\n helper: prop.string(),\n label: prop.string(),\n maxlength: prop.json(undefined as number | undefined),\n name: prop.string(),\n placeholder: prop.string(),\n readonly: prop.bool(false),\n ref: prop.json(undefined as ((el: HTMLTextAreaElement | null) => void) | null | undefined),\n required: prop.bool(false),\n rows: prop.json(undefined as number | undefined),\n 'send-icon': prop.string(),\n 'send-label': prop.string(),\n 'send-shortcut': prop.oneOf(['enter', 'mod+enter'] as const, 'enter'),\n value: prop.string(),\n variant: prop.string<Exclude<VisualVariant, 'frost' | 'text'>>(),\n },\n setup(props) {\n const emit = useEmit<OreMessageComposerEvents>();\n const slots = useSlots<'prefix' | 'send' | 'suffix'>();\n\n const formCtx = inject(FORM_CTX);\n const fCtxProps = useFormContext(props, formCtx);\n const isDisabled = fCtxProps.disabled;\n\n const abortSignal = lifecycleSignal(onCleanup);\n const textareaRef = ref<HTMLTextAreaElement>();\n const autoResize = createAutoResize();\n\n const tf = createTextField({\n disabled: isDisabled,\n error: props.error,\n helper: props.helper,\n maxLength: props.maxlength,\n onInput: (event, value) => emit('input', { originalEvent: event, value }),\n prefix: 'composer',\n readonly: props.readonly,\n required: props.required,\n signal: abortSignal,\n validateOn: formCtx?.validateOn,\n value: props.value,\n });\n\n // Directly form-associated now that the field is owned here rather than borrowed from a\n // nested `ore-textarea` (which previously registered with the ancestor `<form>` on this\n // component's behalf).\n tf.attachFormField(\n useField<string>({\n disabled: tf.disabled,\n onReset: () => {\n tf.reset();\n autoResize.recompute();\n },\n toFormValue: (v) => v,\n validationMessage: tf.validationMessage,\n validity: tf.validity,\n value: tf.value,\n }),\n );\n\n function attemptSend(event: KeyboardEvent | MouseEvent): void {\n const notPrevented = emit('send', { originalEvent: event, value: tf.value.value.trim() });\n\n // `preventDefault()` on `send` means \"keep the current text — skip the default clear\n // + refocus\" (see the event's own doc comment): both halves of that default are gated on\n // the same condition, not just the clear.\n if (notPrevented && props['clear-on-send'].value !== false) {\n tf.clear();\n autoResize.recompute();\n textareaRef.value?.focus();\n }\n }\n\n const composer = createComposerControl({\n disabled: isDisabled,\n loading: computed(() => Boolean(props.loading.value)),\n onSend: attemptSend,\n sendShortcut: props['send-shortcut'],\n value: tf.value,\n });\n\n onElement(textareaRef, (textareaEl) => {\n const unwireField = tf.wire(textareaEl);\n const unwireAutoResize = autoResize.wire(textareaEl);\n const handleKeydown = (e: KeyboardEvent) => composer.handleKeydown(e);\n\n textareaEl.addEventListener('keydown', handleKeydown);\n\n // Immediate fire for when the prop is already set on mount.\n props.ref.value?.(textareaEl);\n\n // Reactive watcher so that if props.ref is set *after* the inner <textarea> mounts\n // (e.g. a parent sets it via a ref callback after render), the new callback still\n // receives the live element.\n const refSub = watch(props.ref, (cb) => {\n cb?.(textareaEl);\n });\n\n return () => {\n textareaEl.removeEventListener('keydown', handleKeydown);\n unwireField();\n unwireAutoResize();\n refSub.dispose();\n props.ref.value?.(null);\n };\n });\n\n bind({\n attr: {\n error: errorAttr(tf.errorText),\n size: fCtxProps.size,\n variant: fCtxProps.variant,\n },\n });\n\n const counterClass = () => counterClassName(tf.counter?.value);\n const counterHidden = () => !tf.counter;\n const counterText = () => tf.counter?.value.counterText.replace(' / ', '/') ?? '';\n const helperHidden = () => !!tf.errorText.value || !tf.helperText.value;\n const errorHidden = () => !tf.errorText.value;\n\n return html`\n <div class=\"composer\" part=\"composer\">\n <textarea\n class=\"field\"\n part=\"field\"\n ref=\"${textareaRef}\"\n :rows=\"${() => props.rows.value ?? 1}\"\n :name=\"${() => props.name.value ?? ''}\"\n :placeholder=\"${() => props.placeholder.value ?? 'Message…'}\"\n :maxlength=\"${() => props.maxlength.value}\"\n ?disabled=\"${isDisabled}\"\n ?readonly=\"${() => Boolean(props.readonly.value)}\"\n ?required=\"${() => Boolean(props.required.value)}\"\n :value=\"${live(tf.value)}\"\n :aria-label=\"${() => props.label.value || 'Message'}\"\n :aria-keyshortcuts=\"${composer.keyShortcutsHint}\"\n :aria-describedby=\"${tf.ariaDescribedBy}\"\n :aria-errormessage=\"${tf.ariaErrorMessage}\"\n :aria-invalid=\"${tf.ariaInvalid}\"></textarea>\n <span class=\"${counterClass}\" aria-live=\"polite\" ?hidden=\"${counterHidden}\">${counterText}</span>\n <div id=\"${tf.assistiveId}\" class=\"helper-text\" aria-live=\"polite\" part=\"helper\" ?hidden=\"${helperHidden}\">\n ${() => tf.helperText.value}\n </div>\n <div id=\"${tf.errorId}\" class=\"helper-text\" role=\"alert\" part=\"error\" ?hidden=\"${errorHidden}\">\n ${() => tf.errorText.value}\n </div>\n <div class=\"toolbar\" part=\"toolbar\">\n <div class=\"toolbar-start\" part=\"toolbar-start\">\n <slot name=\"prefix\"></slot>\n </div>\n <div class=\"toolbar-end\" part=\"toolbar-end\">\n <slot name=\"suffix\"></slot>\n <slot name=\"send\"></slot>\n ${() =>\n slots.has('send').value\n ? ''\n : html`<ore-button\n class=\"send-btn\"\n part=\"send-button\"\n type=\"button\"\n icon-only\n variant=\"solid\"\n :color=\"${() => props.color.value || 'primary'}\"\n :size=\"${fCtxProps.size}\"\n :label=\"${() => props['send-label'].value || DEFAULT_SEND_LABEL}\"\n ?loading=\"${() => Boolean(props.loading.value)}\"\n ?disabled=\"${() => !composer.canSend.value}\"\n @click=\"${(e: MouseEvent) => composer.send(e)}\">\n <ore-icon name=\"${() => props['send-icon'].value || SEND_ICON}\" size=\"16\"></ore-icon>\n </ore-button>`}\n </div>\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [\n colorThemeMixin,\n coarsePointerMixin,\n reducedMotionMixin,\n disabledLoading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M,UAAU,MAAM;uBAC7B,EAAW;6BACL,EAAQ,EAAM,SAAS,MAAO;6BAC9B,EAAQ,EAAM,SAAS,MAAO;oBACvC,EAAK,EAAG,KAAK,EAAE;+BACJ,EAAM,MAAM,SAAS,UAAU;gCAC9B,EAAS,iBAAiB;+BAC3B,EAAG,gBAAgB;gCAClB,EAAG,iBAAiB;2BACzB,EAAG,YAAY;6BAxBX,EAAiB,EAAG,SAAS,KAAK,EAyB7B,sCAxBJ,CAAC,EAAG,QAwB8C,UAvBpD,EAAG,SAAS,MAAM,YAAY,QAAQ,OAAO,GAAG,KAAK,GAuBe;mBAC/E,EAAG,YAAY,wEAvBH,CAAC,CAAC,EAAG,UAAU,SAAS,CAAC,EAAG,WAAW,MAuB2C;kBAC/F,EAAG,WAAW,MAAM;;mBAEnB,EAAG,QAAQ,iEAzBA,CAAC,EAAG,UAAU,MAyByD;kBACnF,EAAG,UAAU,MAAM;;;;;;;;;oBAUvB,EAAM,IAAI,MAAM,CAAC,CAAC,QACd,KACA,CAAI;;;;;;oCAMc,EAAM,MAAM,SAAS,UAAU;6BACtC,EAAU,KAAK;oCACR,EAAM,aAAa,CAAC,SAAS,EAAmB;sCAC9C,EAAQ,EAAM,QAAQ,MAAO;uCAC5B,CAAC,EAAS,QAAQ,MAAM;+BAChC,MAAkB,EAAS,KAAK,CAAC,EAAE;4CACtB,EAAM,YAAY,CAAC,SAAS,EAAU;iCACjD;;;;;CAK/B;CACA,QAAQ,EAAE,gBAAgB,GAAK;CAC/B,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA,EAAuB,QAAQ;EAC/B,EAAiB,CAA4B;EAC7C;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"message-composer.js","names":[],"sources":["../src/inputs/message-composer/message-composer.ts"],"sourcesContent":["import { define, html, inject, prop, ref, bind, onCleanup, onElement, useEmit, useSlots } from '@vielzeug/ore';\nimport { live } from '@vielzeug/ore/directives';\nimport { useField } from '@vielzeug/ore/forms';\nimport { computed, watch } from '@vielzeug/ripple';\n\nimport type { ComponentSize, ThemeColor, VisualVariant } from '../../types';\n\nimport {\n counterClassName,\n createAutoResize,\n createComposerControl,\n createTextField,\n lifecycleSignal,\n type SendShortcut,\n} from '../../headless';\nimport {\n disablableBundle,\n loadableBundle,\n MESSAGE_COMPOSER_SIZE_PRESET,\n sizableBundle,\n themableBundle,\n} from '../../shared';\nimport {\n colorThemeMixin,\n coarsePointerMixin,\n disabledLoadingMixin,\n forcedColorsFocusMixin,\n forcedColorsMixin,\n reducedMotionMixin,\n sizeVariantMixin,\n} from '../../styles';\nimport { errorAttr } from '../shared/field-binding';\nimport { FORM_CTX, useFormContext } from '../shared/form-context';\nimport '../../content/icon/icon';\nimport '../button/button';\nimport componentStyles from './message-composer.css?inline';\n\nexport type { SendShortcut } from '../../headless';\n\nconst DEFAULT_SEND_LABEL = 'Send message';\nconst SEND_ICON = 'arrow-up';\n\n/** Events emitted by the message composer */\nexport type OreMessageComposerEvents = {\n /** Fired on every keystroke with the current value. */\n input: { originalEvent: Event; value: string };\n /**\n * Fired for a send attempt (the resolved `send-shortcut` or the send button) while the\n * composer isn't blank/disabled/loading. Cancelable — call `preventDefault()` to keep the\n * current text in the field instead of the default clear + refocus.\n */\n send: { originalEvent: KeyboardEvent | MouseEvent; value: string };\n};\n\n/** Message composer properties */\nexport type OreMessageComposerProps = {\n /** Clear the value and refocus after a non-cancelled `send` (default `true`) */\n 'clear-on-send'?: boolean;\n /** Theme color (card focus ring + default send button color) */\n color?: ThemeColor;\n /** Disable the whole composer (field, slots, and send action) */\n disabled?: boolean;\n /** Error message shown below the field */\n error?: string;\n /** Stretch the composer to the full width of its container */\n fullwidth?: boolean;\n /** Helper text shown below the field */\n helper?: string;\n /** Accessible name for the field — never rendered visually, only as `aria-label` */\n label?: string;\n /** Blocks further sends (e.g. a send is already in flight) without disabling editing */\n loading?: boolean;\n /** Maximum character count; shows a counter */\n maxlength?: number;\n /** Form field name */\n name?: string;\n /** Placeholder text */\n placeholder?: string;\n /** Make the field read-only */\n readonly?: boolean;\n /**\n * JS-only callback fired with the inner `<textarea>` element when it mounts, and with\n * `null` when it unmounts. Set as a JS property: `composer.ref = (el) => { ... }`.\n */\n ref?: ((el: HTMLTextAreaElement | null) => void) | null;\n /** Require a non-blank value for `<ore-form>` validation */\n required?: boolean;\n /** Number of visible rows before auto-resize grows the field */\n rows?: number;\n /** Lucide icon name for the default send button (default `'arrow-up'`) */\n 'send-icon'?: string;\n /** Accessible label for the send button (default `'Send message'`) */\n 'send-label'?: string;\n /** Keyboard shortcut that sends: 'enter' (Shift+Enter for a newline) or 'mod+enter' (Enter always inserts a newline; Ctrl/Cmd+Enter sends) */\n 'send-shortcut'?: SendShortcut;\n /** Component size */\n size?: ComponentSize;\n /** Current text value */\n value?: string;\n /** Visual variant of the card — same variant set as `ore-textarea`, applied to the card. */\n variant?: Exclude<VisualVariant, 'frost' | 'text'>;\n};\n\n/**\n * A message/comment composer — a card with an auto-resizing field on top and a toolbar row\n * below it, built directly on the same headless primitives as `ore-textarea` (`createTextField`,\n * `createAutoResize`) rather than composing `ore-textarea` itself. Nesting a fully-styled sibling\n * component and suppressing most of its chrome (as an earlier version of this component did) is\n * a leaky composition — this owns its single `<textarea>` outright, so there's exactly one\n * implementation of the field's appearance to reason about, not two fighting each other.\n *\n * Handles the send gesture (Enter to send, Shift+Enter for a newline, or a Ctrl/Cmd+Enter\n * alternative), IME-safe composition, and clear-and-refocus after sending.\n *\n * @element ore-message-composer\n *\n * @attr {string} value - Current text value\n * @attr {string} placeholder - Placeholder text\n * @attr {string} label - Accessible name for the field (not rendered visually)\n * @attr {string} name - Form field name\n * @attr {string} helper - Helper text shown below the field\n * @attr {string} error - Error message shown below the field\n * @attr {boolean} disabled - Disable the whole composer\n * @attr {boolean} readonly - Read-only mode\n * @attr {boolean} required - Require a non-blank value for `<ore-form>` validation\n * @attr {boolean} loading - Blocks further sends without disabling editing\n * @attr {number} maxlength - Max character count; shows a counter\n * @attr {number} rows - Visible rows before auto-resize grows the field (default 1)\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} variant - Visual variant of the card: 'solid' | 'flat' | 'bordered' | 'outline' | 'ghost'\n * @attr {string} size - 'sm' | 'md' | 'lg'\n * @attr {boolean} fullwidth - Stretch to the full width of the container\n * @attr {string} send-icon - Lucide icon name for the default send button (default 'arrow-up')\n * @attr {string} send-label - Accessible label for the send button (default 'Send message')\n * @attr {string} send-shortcut - 'enter' (default) | 'mod+enter'\n * @attr {boolean} clear-on-send - Clear the value and refocus after a non-cancelled send (default true)\n *\n * @fires input - Fired on every keystroke. detail: { value, originalEvent }\n * @fires send - Fired on a send attempt. Cancelable. detail: { value, originalEvent }\n *\n * @slot prefix - Content at the start of the toolbar row (e.g. an attach menu)\n * @slot suffix - Content at the end of the toolbar row, before the send button (e.g. a model picker)\n * @slot send - Replaces the default send button entirely — the only supported way to customize it\n *\n * @cssprop --message-composer-bg - Card background color\n * @cssprop --message-composer-border-color - Card border color\n * @cssprop --message-composer-radius - Card border radius\n * @cssprop --message-composer-padding - Card inner padding\n * @cssprop --message-composer-gap - Gap between the field/toolbar rows and between toolbar items\n * @cssprop --message-composer-placeholder-color - Field placeholder text color\n * @cssprop --message-composer-min-height - Minimum field height (default one line)\n * @cssprop --message-composer-hover-bg - Card background on hover (flat/ghost variants)\n * @cssprop --message-composer-hover-border-color - Card border on hover (flat/bordered variants)\n * @cssprop --message-composer-focus-bg - Card background when focused (flat variant)\n * @cssprop --message-composer-focus-border-color - Card border when focused (flat variant)\n *\n * @part composer - Root card container\n * @part field - The native `<textarea>` element\n * @part helper - Helper text element\n * @part error - Error text element (`role=\"alert\"`)\n * @part toolbar - Toolbar row below the field\n * @part toolbar-start - Toolbar group holding the `prefix` slot\n * @part toolbar-end - Toolbar group holding the `suffix` slot and the send button\n * @part send-button - The default send button (absent when the `send` slot is used)\n *\n * @example\n * ```html\n * <ore-message-composer placeholder=\"Message…\" send-shortcut=\"mod+enter\"></ore-message-composer>\n * ```\n */\nexport const MESSAGE_COMPOSER_TAG = 'ore-message-composer' as const;\ndefine<OreMessageComposerProps>(MESSAGE_COMPOSER_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...loadableBundle,\n 'clear-on-send': prop.bool(true),\n error: prop.string(),\n fullwidth: prop.bool(false),\n helper: prop.string(),\n label: prop.string(),\n maxlength: prop.json(undefined as number | undefined),\n name: prop.string(),\n placeholder: prop.string(),\n readonly: prop.bool(false),\n ref: prop.json(undefined as ((el: HTMLTextAreaElement | null) => void) | null | undefined),\n required: prop.bool(false),\n rows: prop.json(undefined as number | undefined),\n 'send-icon': prop.string(),\n 'send-label': prop.string(),\n 'send-shortcut': prop.oneOf(['enter', 'mod+enter'] as const, 'enter'),\n value: prop.string(),\n variant: prop.string<Exclude<VisualVariant, 'frost' | 'text'>>(),\n },\n setup(props) {\n const emit = useEmit<OreMessageComposerEvents>();\n const slots = useSlots<'prefix' | 'send' | 'suffix'>();\n\n const formCtx = inject(FORM_CTX);\n const fCtxProps = useFormContext(props, formCtx);\n const isDisabled = fCtxProps.disabled;\n\n const abortSignal = lifecycleSignal(onCleanup);\n const textareaRef = ref<HTMLTextAreaElement>();\n const autoResize = createAutoResize();\n\n const tf = createTextField({\n disabled: isDisabled,\n error: props.error,\n helper: props.helper,\n maxLength: props.maxlength,\n onInput: (event, value) => emit('input', { originalEvent: event, value }),\n prefix: 'composer',\n readonly: props.readonly,\n required: props.required,\n signal: abortSignal,\n validateOn: formCtx?.validateOn,\n value: props.value,\n });\n\n // Directly form-associated now that the field is owned here rather than borrowed from a\n // nested `ore-textarea` (which previously registered with the ancestor `<form>` on this\n // component's behalf).\n tf.attachFormField(\n useField<string>({\n disabled: tf.disabled,\n onReset: () => {\n tf.reset();\n autoResize.recompute();\n },\n toFormValue: (v) => v,\n validationMessage: tf.validationMessage,\n validity: tf.validity,\n value: tf.value,\n }),\n );\n\n function attemptSend(event: KeyboardEvent | MouseEvent): void {\n const notPrevented = emit('send', { originalEvent: event, value: tf.value.value.trim() });\n\n // `preventDefault()` on `send` means \"keep the current text — skip the default clear\n // + refocus\" (see the event's own doc comment): both halves of that default are gated on\n // the same condition, not just the clear.\n if (notPrevented && props['clear-on-send'].value !== false) {\n tf.clear();\n autoResize.recompute();\n textareaRef.value?.focus();\n }\n }\n\n const composer = createComposerControl({\n disabled: isDisabled,\n loading: computed(() => Boolean(props.loading.value)),\n onSend: attemptSend,\n sendShortcut: props['send-shortcut'],\n value: tf.value,\n });\n\n onElement(textareaRef, (textareaEl) => {\n const unwireField = tf.wire(textareaEl);\n const unwireAutoResize = autoResize.wire(textareaEl);\n const handleKeydown = (e: KeyboardEvent) => composer.handleKeydown(e);\n\n textareaEl.addEventListener('keydown', handleKeydown);\n\n // Immediate fire for when the prop is already set on mount.\n props.ref.value?.(textareaEl);\n\n // Reactive watcher so that if props.ref is set *after* the inner <textarea> mounts\n // (e.g. a parent sets it via a ref callback after render), the new callback still\n // receives the live element.\n const refSub = watch(props.ref, (cb) => {\n cb?.(textareaEl);\n });\n\n return () => {\n textareaEl.removeEventListener('keydown', handleKeydown);\n unwireField();\n unwireAutoResize();\n refSub.dispose();\n props.ref.value?.(null);\n };\n });\n\n bind({\n attr: {\n error: errorAttr(tf.errorText),\n size: fCtxProps.size,\n variant: fCtxProps.variant,\n },\n });\n\n const counterClass = () => counterClassName(tf.counter?.value);\n const counterHidden = () => !tf.counter;\n const counterText = () => tf.counter?.value.counterText.replace(' / ', '/') ?? '';\n const helperHidden = () => !!tf.errorText.value || !tf.helperText.value;\n const errorHidden = () => !tf.errorText.value;\n\n return html`\n <div class=\"composer\" part=\"composer\">\n <textarea\n class=\"field\"\n part=\"field\"\n ref=\"${textareaRef}\"\n :rows=\"${() => props.rows.value ?? 1}\"\n :name=\"${() => props.name.value ?? ''}\"\n :placeholder=\"${() => props.placeholder.value ?? 'Message…'}\"\n :maxlength=\"${() => props.maxlength.value}\"\n ?disabled=\"${isDisabled}\"\n ?readonly=\"${() => Boolean(props.readonly.value)}\"\n ?required=\"${() => Boolean(props.required.value)}\"\n :value=\"${live(tf.value)}\"\n :aria-label=\"${() => props.label.value || 'Message'}\"\n :aria-keyshortcuts=\"${composer.keyShortcutsHint}\"\n :aria-describedby=\"${tf.ariaDescribedBy}\"\n :aria-errormessage=\"${tf.ariaErrorMessage}\"\n :aria-invalid=\"${tf.ariaInvalid}\"></textarea>\n <span class=\"${counterClass}\" aria-live=\"polite\" ?hidden=\"${counterHidden}\">${counterText}</span>\n <div id=\"${tf.assistiveId}\" class=\"helper-text\" aria-live=\"polite\" part=\"helper\" ?hidden=\"${helperHidden}\">\n ${() => tf.helperText.value}\n </div>\n <div id=\"${tf.errorId}\" class=\"helper-text\" role=\"alert\" part=\"error\" ?hidden=\"${errorHidden}\">\n ${() => tf.errorText.value}\n </div>\n <div class=\"toolbar\" part=\"toolbar\">\n <div class=\"toolbar-start\" part=\"toolbar-start\">\n <slot name=\"prefix\"></slot>\n </div>\n <div class=\"toolbar-end\" part=\"toolbar-end\">\n <slot name=\"suffix\"></slot>\n <slot name=\"send\"></slot>\n ${() =>\n slots.has('send').value\n ? ''\n : html`<ore-button\n class=\"send-btn\"\n part=\"send-button\"\n type=\"button\"\n icon-only\n variant=\"solid\"\n :color=\"${() => props.color.value || 'primary'}\"\n :size=\"${fCtxProps.size}\"\n :label=\"${() => props['send-label'].value || DEFAULT_SEND_LABEL}\"\n ?loading=\"${() => Boolean(props.loading.value)}\"\n ?disabled=\"${() => !composer.canSend.value}\"\n @click=\"${(e: MouseEvent) => composer.send(e)}\">\n <ore-icon name=\"${() => props['send-icon'].value || SEND_ICON}\" size=\"16\"></ore-icon>\n </ore-button>`}\n </div>\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [\n colorThemeMixin,\n coarsePointerMixin,\n reducedMotionMixin,\n disabledLoadingMixin,\n forcedColorsMixin,\n forcedColorsFocusMixin('.field'),\n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,SAAS,MAAO;6BAC9B,EAAQ,EAAM,SAAS,MAAO;oBACvC,EAAK,EAAG,KAAK,EAAE;+BACJ,EAAM,MAAM,SAAS,UAAU;gCAC9B,EAAS,iBAAiB;+BAC3B,EAAG,gBAAgB;gCAClB,EAAG,iBAAiB;2BACzB,EAAG,YAAY;6BAxBX,EAAiB,EAAG,SAAS,KAAK,EAyB7B,sCAxBJ,CAAC,EAAG,QAwB8C,UAvBpD,EAAG,SAAS,MAAM,YAAY,QAAQ,OAAO,GAAG,KAAK,GAuBe;mBAC/E,EAAG,YAAY,wEAvBH,CAAC,CAAC,EAAG,UAAU,SAAS,CAAC,EAAG,WAAW,MAuB2C;kBAC/F,EAAG,WAAW,MAAM;;mBAEnB,EAAG,QAAQ,iEAzBA,CAAC,EAAG,UAAU,MAyByD;kBACnF,EAAG,UAAU,MAAM;;;;;;;;;oBAUvB,EAAM,IAAI,MAAM,CAAC,CAAC,QACd,KACA,CAAI;;;;;;oCAMc,EAAM,MAAM,SAAS,UAAU;6BACtC,EAAU,KAAK;oCACR,EAAM,aAAa,CAAC,SAAS,EAAmB;sCAC9C,EAAQ,EAAM,QAAQ,MAAO;uCAC5B,CAAC,EAAS,QAAQ,MAAM;+BAChC,MAAkB,EAAS,KAAK,CAAC,EAAE;4CACtB,EAAM,YAAY,CAAC,SAAS,EAAU;iCACjD;;;;;CAK/B;CACA,QAAQ,EAAE,gBAAgB,GAAK;CAC/B,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA,EAAuB,QAAQ;EAC/B,EAAiB,CAA4B;EAC7C;CACF;AACF,CAAC"}
|
package/dist/navbar.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/accessibility.css.cjs"),t=require("./styles/mixins/shape.css.cjs"),n=require("./styles/mixins/theme.css.cjs"),r=require("./styles/mixins/variants.css.cjs"),i=require("./utils/link.cjs"),a=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/accessibility.css.cjs"),t=require("./styles/mixins/shape.css.cjs"),n=require("./styles/mixins/theme.css.cjs"),r=require("./styles/mixins/variants.css.cjs"),i=require("./utils/link.cjs"),a=require("./layout/navbar/navbar.css.cjs");let o=require("@vielzeug/ore"),s=require("@vielzeug/ripple"),c=require("@vielzeug/ore/observers");var l=(e,t,n,r)=>e?(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)):()=>{},u=e=>!(e instanceof HTMLElement)||e.tagName.includes(`-`)||e.childElementCount>0?!0:(e.textContent??``).trim().length>0,d=e=>{let t=String(e??``).trim();if(!t)return;let n=/max-width\s*:\s*([0-9]+(?:\.[0-9]+)?)px/i.exec(t);if(!n)return;let r=Number.parseFloat(n[1]);return Number.isFinite(r)?r:void 0},f=e=>{let t=e.parentElement;for(;t?.tagName.toLowerCase()===`ore-grid-item`;)t=t.parentElement;return t},p=e=>{let t=f(e)?.clientWidth??0;return t>0?t:e.offsetWidth},m=e=>{let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return null},h=(0,o.createContext)(`NavbarContext`),g=`ore-navbar`;(0,o.define)(g,{props:{breakpoint:o.prop.string(`(max-width: 768px)`),color:o.prop.string(),"container-breakpoints":o.prop.bool(!1),elevation:o.prop.number(),floating:o.prop.bool(!1),label:o.prop.string(`Main navigation`),"mobile-sidebar":o.prop.string(),rounded:o.prop.string(),"scroll-threshold":o.prop.number(80),sticky:o.prop.bool(!1),variant:o.prop.string()},setup(e){let t=(0,o.getHost)(),n=(0,o.useEmit)(),r=(0,o.useSlots)(),i=()=>r.has(`logo`).value,a=()=>r.elements(`mobile-menu`).value.some(u),g=(0,s.signal)(null),_=(0,s.signal)(!1),v=(0,s.signal)(!1),y=(0,s.signal)(!1),b=(0,s.signal)(!1),x=(0,s.signal)(!1),S=(0,s.signal)(!1),C=(0,s.signal)(0),w=(0,s.signal)(!1),T=(0,s.signal)(!1),E=(0,s.signal)(d(e.breakpoint.value)),D=(0,s.signal)(!1),O=()=>{let n=String(e[`mobile-sidebar`].value??``).trim();if(!n)return null;let r=t.getRootNode();return(r instanceof ShadowRoot||r instanceof Document?r.querySelector(n):null)??document.querySelector(n)};(0,o.provide)(h,{closeMobileMenu:()=>j(),isMobile:(0,s.computed)(()=>y.value),mobileMenuOpen:(0,s.computed)(()=>b.value)});let k=()=>{if(e.floating.value&&e.sticky.value)return S.value?`sticky`:`floating`;if(e.floating.value)return`floating`;if(e.sticky.value)return`sticky`},A=e=>{let t=!!e;if(!a()){let e=g.value??O();if(e){t?e.openMobile?.():e.closeMobile?.();return}}t&&!a()||b.value!==t&&(b.value=t,n(`mobile-menu-change`,{open:t}))},j=()=>A(!1),M=()=>A(!0),N=()=>{if(!a()){let e=g.value??O();if(e){typeof e.toggleMobile==`function`?e.toggleMobile():typeof e.openMobile==`function`&&typeof e.closeMobile==`function`&&(e.hasAttribute(`data-mobile-open`)?e.closeMobile():e.openMobile());return}}A(!b.value)},P=()=>{let e=(g.value&&!a()?_.value:!1)||w.value||T.value;y.value=e,e||j()},F=e=>e?e.scrollTop||0:window.scrollY||document.documentElement.scrollTop||0,I=e=>{C.value=F(e)},L=(t=null)=>{if(!(e.floating.value&&e.sticky.value)){S.value&&=!1;return}let n=Math.max(0,Number(e[`scroll-threshold`].value)||0),r=F(t)-C.value;S.value=r>n};return(0,o.bind)({attr:{"data-mobile":()=>y.value?!0:void 0,"data-mobile-open":()=>y.value&&b.value?!0:void 0,"data-mode":()=>k()??null,"data-mode-transitioning":()=>x.value?!0:void 0,"data-preview-mode":()=>D.value?!0:void 0,"data-scrolled":()=>e.floating.value&&e.sticky.value&&S.value?!0:void 0}}),(0,o.onMounted)(()=>{let n=t,r=m(t);n.closeMobileMenu=j,n.openMobileMenu=M,n.toggleMobileMenu=N;let i=l(window,`scroll`,()=>{L(r)},{passive:!0}),o=r?l(r,`scroll`,()=>{L(r)},{passive:!0}):void 0,u=l(t,`keydown`,e=>{e.key!==`Escape`||!b.value||j()}),h,y,C,A,F=()=>{y?.(),y=void 0,g.value=null,_.value=!1,v.value=!1;let e=O();if(!e)return;let t=t=>{let n=e.hasAttribute(`data-bottom-nav`),r=e.hasAttribute(`data-mobile-open`);_.value=n,v.value=t?.detail?t.detail.open:r,v.value&&!_.value&&(_.value=!0),P()},n=new MutationObserver(()=>{t()});t(),n.observe(e,{attributeFilter:[`data-bottom-nav`,`data-mobile-open`],attributes:!0}),e.addEventListener(`mobile-open-change`,t),y=()=>{n.disconnect(),e.removeEventListener(`mobile-open-change`,t)},g.value=e},R=()=>{x.value=!0,C!=null&&clearTimeout(C),C=setTimeout(()=>{x.value=!1,C=void 0},220)},z=(0,s.watch)((0,s.computed)(()=>e.floating.value&&e.sticky.value),e=>{if(!e){S.value&&=!1,x.value&&=!1,A=void 0,C!=null&&(clearTimeout(C),C=void 0);return}I(r),L(r),A=k()},{immediate:!0}),B=(0,s.watch)(e[`mobile-sidebar`],()=>{F()},{immediate:!0}),V=(0,s.watch)((0,s.computed)(()=>k()),t=>{if(!(e.floating.value&&e.sticky.value)){A=t??void 0;return}let n=t??void 0;A&&n&&A!==n&&R(),A=n},{immediate:!0}),H=(0,s.watch)((0,s.computed)(()=>a()),e=>{!e&&b.value&&j()},{immediate:!0});(0,s.watch)(e.breakpoint,n=>{h?.(),h=void 0;let r=String(n??``).trim();E.value=d(r),w.value=!1;let i=p(t);if(T.value=i>0&&E.value!=null?i<=E.value:!1,P(),e[`container-breakpoints`].value&&E.value!=null||!r||typeof window.matchMedia!=`function`)return;let a=window.matchMedia(r),o=e=>{w.value=e,P()},s=e=>{o(e.matches)};o(a.matches),a.addEventListener(`change`,s),h=()=>{a.removeEventListener(`change`,s)}},{immediate:!0});let U=typeof ResizeObserver==`function`?(()=>{let e=(0,c.resizeObserver)(t),n=t.parentElement,r=f(t),i=n?(0,c.resizeObserver)(n):void 0,a=r&&r!==n?(0,c.resizeObserver)(r):void 0;return(0,s.watch)((0,s.computed)(()=>[e.value.width,e.value.height,i?.value.width,i?.value.height,a?.value.width,a?.value.height]),()=>{let e=p(t),n=f(t)?.clientWidth??0;T.value=e>0&&E.value!=null?e<=E.value:!1,D.value=n>0&&n<window.innerWidth,P()})})():void 0;return()=>{u?.(),i?.(),o?.(),z?.dispose(),V?.dispose(),H?.dispose(),B?.dispose(),h?.(),y?.(),U?.dispose(),C!=null&&(clearTimeout(C),C=void 0)}}),o.html`
|
|
2
2
|
<nav part="nav" aria-label="${e.label}">
|
|
3
3
|
<div class="navbar" part="bar">
|
|
4
4
|
<div class="navbar-logo" part="logo" ?hidden=${()=>!i()}>
|
|
@@ -21,13 +21,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
21
21
|
class="mobile-toggle"
|
|
22
22
|
part="mobile-toggle"
|
|
23
23
|
type="button"
|
|
24
|
-
aria-label="${()=>
|
|
24
|
+
aria-label="${()=>a()?b.value?`Close navigation menu`:`Open navigation menu`:v.value?`Close navigation menu`:`Open navigation menu`}"
|
|
25
25
|
aria-controls="mobile-menu-panel"
|
|
26
|
-
aria-expanded="${()=>String(
|
|
27
|
-
?hidden=${()=>!y.value||!
|
|
26
|
+
aria-expanded="${()=>String(a()?b.value:v.value)}"
|
|
27
|
+
?hidden=${()=>!y.value||!a()&&!g.value}
|
|
28
28
|
@click="${N}">
|
|
29
29
|
<ore-icon
|
|
30
|
-
name="${()=>(
|
|
30
|
+
name="${()=>(a()?b.value:v.value)?`x`:`menu`}"
|
|
31
31
|
size="18"
|
|
32
32
|
stroke-width="2.5"
|
|
33
33
|
aria-hidden="true"></ore-icon>
|
|
@@ -40,11 +40,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
40
40
|
part="mobile-menu"
|
|
41
41
|
role="navigation"
|
|
42
42
|
:aria-label="${()=>`${e.label.value} mobile menu`}"
|
|
43
|
-
?hidden=${()=>!y.value||!b.value||!
|
|
43
|
+
?hidden=${()=>!y.value||!b.value||!a()}>
|
|
44
44
|
<slot name="mobile-menu"></slot>
|
|
45
45
|
</div>
|
|
46
46
|
</nav>
|
|
47
|
-
`},styles:[n.colorThemeMixin,n.elevationMixin,t.roundedVariantMixin,e.coarsePointerMixin,e.reducedMotionMixin,r.frostVariantMixin(`.navbar`),
|
|
47
|
+
`},styles:[n.colorThemeMixin,n.elevationMixin,t.roundedVariantMixin,e.coarsePointerMixin,e.reducedMotionMixin,r.frostVariantMixin(`.navbar`),a.default]});var _=`ore-navbar-item`;(0,o.define)(_,{props:{active:o.prop.bool(!1),disabled:o.prop.bool(!1),href:o.prop.string(),rel:o.prop.string(),target:o.prop.string()},setup(e){let t=(0,o.useSlots)(),n=()=>t.has(`icon`).value,r=()=>t.has(`end`).value,a=(0,o.inject)(h);(0,o.bind)({attr:{"navbar-mobile":()=>a?.isMobile.value?!0:void 0,"navbar-mobile-open":()=>a?.mobileMenuOpen.value?!0:void 0}});let c=()=>!!e.href.value&&!e.disabled.value,l=(0,s.computed)(()=>i.computeSafeRel(e.rel.value,e.target.value)),u=()=>{a?.mobileMenuOpen.value&&a.closeMobileMenu()},d=()=>o.html`
|
|
48
48
|
<span class="item-icon" part="item-icon" ?hidden=${()=>!n()} aria-hidden="true">
|
|
49
49
|
<slot name="icon"></slot>
|
|
50
50
|
</span>
|
|
@@ -52,8 +52,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
52
52
|
<span class="item-end" part="item-end" ?hidden=${()=>!r()}>
|
|
53
53
|
<slot name="end"></slot>
|
|
54
54
|
</span>
|
|
55
|
-
`;return
|
|
56
|
-
${()=>
|
|
55
|
+
`;return o.html`
|
|
56
|
+
${()=>c()?o.html`
|
|
57
57
|
<a
|
|
58
58
|
class="item"
|
|
59
59
|
part="item"
|
|
@@ -64,8 +64,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
64
64
|
@click=${u}>
|
|
65
65
|
${d()}
|
|
66
66
|
</a>
|
|
67
|
-
`:e.disabled.value?
|
|
67
|
+
`:e.disabled.value?o.html`<div class="item" part="item" tabindex="-1" aria-disabled="true">${d()}</div>`:o.html`<button class="item" part="item" type="button" @click=${u}>
|
|
68
68
|
${d()}
|
|
69
69
|
</button>`}
|
|
70
|
-
`},styles:[e.coarsePointerMixin,
|
|
70
|
+
`},styles:[e.coarsePointerMixin,a.default]}),exports.NAVBAR_CTX=h,exports.NAVBAR_ITEM_TAG=_,exports.NAVBAR_TAG=g;
|
|
71
71
|
//# sourceMappingURL=navbar.cjs.map
|