@dice-roller/vue 1.4.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/dist/types/components/DiceRoller.vue.d.ts +2 -2
- package/dist/types/components/DiceRollerBootstrap.vue.d.ts +2 -2
- package/dist/types/components/DiceRollerRenderless.vue.d.ts +2 -2
- package/dist/types/components/DiceRollerTailwind.vue.d.ts +2 -2
- package/dist/types/types.d.ts +6 -6
- package/dist/vue.js +73 -73
- package/dist/vue.umd.cjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Requires Vue 3.5.45 or newer within Vue 3.
|
|
|
16
16
|
npm install @dice-roller/vue
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Vue and `@dice-roller/rpg-dice-roller` are required peer dependencies. npm installs required peers automatically; with other package managers, ensure compatible versions are installed in your application.
|
|
19
|
+
Vue and v6 of `@dice-roller/rpg-dice-roller` are required peer dependencies. npm installs required peers automatically; with other package managers, ensure compatible versions are installed in your application.
|
|
20
20
|
|
|
21
21
|
## Quick start
|
|
22
22
|
|
|
@@ -217,11 +217,11 @@ The component manages the input's `id`, `value`, `type`, `name` and validation a
|
|
|
217
217
|
|
|
218
218
|
All four components emit these events:
|
|
219
219
|
|
|
220
|
-
| Event | Arguments
|
|
221
|
-
| ----------------- |
|
|
222
|
-
| `update:notation` | `notation: string`
|
|
223
|
-
| `notation:change` | `notation: string`
|
|
224
|
-
| `roll` | `notation: string`, `result:
|
|
220
|
+
| Event | Arguments | Description |
|
|
221
|
+
| ----------------- | ------------------------------------------ | ----------------------------------------------------------------------- |
|
|
222
|
+
| `update:notation` | `notation: string` | Local notation changed; used by `v-model:notation`. |
|
|
223
|
+
| `notation:change` | `notation: string` | Local notation changed through user input. |
|
|
224
|
+
| `roll` | `notation: string`, `result: Roll \| null` | A roll was attempted. The result is `null` for an empty or failed roll. |
|
|
225
225
|
|
|
226
226
|
Parent-driven notation changes do not emit notation-change events. Results are dice roll objects; use `result.total` for the total or `String(result)` for the formatted result.
|
|
227
227
|
|
|
@@ -322,17 +322,17 @@ For component props, pass getters such as `notation: () => props.notation` and `
|
|
|
322
322
|
|
|
323
323
|
Destructure the return object in setup. Refs use `.value` in JavaScript and unwrap as top-level bindings in templates.
|
|
324
324
|
|
|
325
|
-
| Value | Type | Description
|
|
326
|
-
| ----------------------- | --------------------- |
|
|
327
|
-
| `currentNotation` | Writable computed ref | Editable notation. Assigning a different value calls `onNotationChange`.
|
|
328
|
-
| `setNotation(notation)` | Function | Updates the local notation.
|
|
329
|
-
| `output` |
|
|
330
|
-
| `error` | Ref | Roll error message or `null`; cleared at the next roll attempt.
|
|
331
|
-
| `roll()` | Function | Rolls the current notation and updates the result/error state.
|
|
332
|
-
| `labels` | Computed ref | Resolved interface and error labels.
|
|
333
|
-
| `bind` | Computed ref | `{ value: string }` input binding.
|
|
334
|
-
| `on` | Object | `input`, `change` and `keydown` handlers for `v-on`.
|
|
335
|
-
| `copy` | Reactive object | Clipboard methods and state, described below.
|
|
325
|
+
| Value | Type | Description |
|
|
326
|
+
| ----------------------- | --------------------- | ---------------------------------------------------------------------------- |
|
|
327
|
+
| `currentNotation` | Writable computed ref | Editable notation. Assigning a different value calls `onNotationChange`. |
|
|
328
|
+
| `setNotation(notation)` | Function | Updates the local notation. |
|
|
329
|
+
| `output` | Shallow ref | Latest v6 `Roll`, or `null` before a roll and after an empty or failed roll. |
|
|
330
|
+
| `error` | Ref | Roll error message or `null`; cleared at the next roll attempt. |
|
|
331
|
+
| `roll()` | Function | Rolls the current notation and updates the result/error state. |
|
|
332
|
+
| `labels` | Computed ref | Resolved interface and error labels. |
|
|
333
|
+
| `bind` | Computed ref | `{ value: string }` input binding. |
|
|
334
|
+
| `on` | Object | `input`, `change` and `keydown` handlers for `v-on`. |
|
|
335
|
+
| `copy` | Reactive object | Clipboard methods and state, described below. |
|
|
336
336
|
|
|
337
337
|
Use `v-bind="bind"` and `v-on="on"` together. Alternatively, use `v-model="currentNotation"` with `@keydown="on.keydown"`. Enter rolls without submitting a surrounding form; held-key repeats and Enter during IME composition are ignored.
|
|
338
338
|
|
|
@@ -391,7 +391,7 @@ Use unique input and error IDs when rendering multiple instances.
|
|
|
391
391
|
| `bind` | `{ value: string }` binding for the notation input. |
|
|
392
392
|
| `on` | `input`, `change` and `keydown` event handlers. |
|
|
393
393
|
| `roll` | Function that rolls the current notation. |
|
|
394
|
-
| `output` | Latest `
|
|
394
|
+
| `output` | Latest v6 `Roll` object or `null`. |
|
|
395
395
|
| `error` | Roll error message or `null`. |
|
|
396
396
|
| `labels` | Resolved interface and error labels. |
|
|
397
397
|
| `copy` | Clipboard object with `copy()`, `isSupported`, `copied`, `text` and `error`. |
|
|
@@ -18,9 +18,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
18
18
|
default: () => {};
|
|
19
19
|
};
|
|
20
20
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
22
21
|
"notation:change": (notation: string) => any;
|
|
23
22
|
"update:notation": (notation: string) => any;
|
|
23
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
24
24
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
25
25
|
btnLabel: {
|
|
26
26
|
type: StringConstructor;
|
|
@@ -38,9 +38,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
38
38
|
default: () => {};
|
|
39
39
|
};
|
|
40
40
|
}>> & Readonly<{
|
|
41
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
42
41
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
43
42
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
43
|
+
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
44
44
|
}>, {
|
|
45
45
|
btnLabel: string;
|
|
46
46
|
className: string;
|
|
@@ -53,9 +53,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
|
|
|
53
53
|
validator(value: string): boolean;
|
|
54
54
|
};
|
|
55
55
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
56
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
57
56
|
"notation:change": (notation: string) => any;
|
|
58
57
|
"update:notation": (notation: string) => any;
|
|
58
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
59
59
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
60
60
|
bgVariant: {
|
|
61
61
|
type: PropType<BootstrapBackgroundVariant>;
|
|
@@ -106,9 +106,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
|
|
|
106
106
|
validator(value: string): boolean;
|
|
107
107
|
};
|
|
108
108
|
}>> & Readonly<{
|
|
109
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
110
109
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
111
110
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
111
|
+
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
112
112
|
}>, {
|
|
113
113
|
btnLabel: string;
|
|
114
114
|
inputAttrs: DiceRollerInputAttrs;
|
|
@@ -10,9 +10,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
10
10
|
default: () => {};
|
|
11
11
|
};
|
|
12
12
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
14
13
|
"notation:change": (notation: string) => any;
|
|
15
14
|
"update:notation": (notation: string) => any;
|
|
15
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
16
16
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
17
|
notation: StringConstructor;
|
|
18
18
|
labels: {
|
|
@@ -20,9 +20,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
20
20
|
default: () => {};
|
|
21
21
|
};
|
|
22
22
|
}>> & Readonly<{
|
|
23
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
24
23
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
25
24
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
25
|
+
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
26
26
|
}>, {
|
|
27
27
|
labels: Partial<DiceRollerLabels>;
|
|
28
28
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -14,9 +14,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
14
14
|
default: () => {};
|
|
15
15
|
};
|
|
16
16
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
18
17
|
"notation:change": (notation: string) => any;
|
|
19
18
|
"update:notation": (notation: string) => any;
|
|
19
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
21
|
btnLabel: {
|
|
22
22
|
type: StringConstructor;
|
|
@@ -30,9 +30,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
30
30
|
default: () => {};
|
|
31
31
|
};
|
|
32
32
|
}>> & Readonly<{
|
|
33
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
34
33
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
35
34
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
35
|
+
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
36
36
|
}>, {
|
|
37
37
|
btnLabel: string;
|
|
38
38
|
inputAttrs: DiceRollerInputAttrs;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ComputedRef, InputHTMLAttributes, MaybeRefOrGetter, VNodeChild, WritableComputedRef, Ref } from 'vue';
|
|
1
|
+
import type { Roll } from '@dice-roller/rpg-dice-roller';
|
|
2
|
+
import type { ComputedRef, InputHTMLAttributes, MaybeRefOrGetter, ShallowRef, VNodeChild, WritableComputedRef, Ref } from 'vue';
|
|
3
3
|
export interface DiceRollerLabels {
|
|
4
4
|
notation: string;
|
|
5
5
|
copy: string;
|
|
@@ -13,7 +13,7 @@ export interface UseDiceRollerOptions {
|
|
|
13
13
|
notation?: MaybeRefOrGetter<string | null | undefined>;
|
|
14
14
|
labels?: MaybeRefOrGetter<Partial<DiceRollerLabels> | undefined>;
|
|
15
15
|
onNotationChange?: (notation: string) => void;
|
|
16
|
-
onRoll?: (notation: string, result:
|
|
16
|
+
onRoll?: (notation: string, result: Roll | null) => void;
|
|
17
17
|
}
|
|
18
18
|
export interface DiceRollerClipboard {
|
|
19
19
|
copy: () => Promise<void>;
|
|
@@ -30,7 +30,7 @@ export interface DiceRollerInputHandlers {
|
|
|
30
30
|
export interface UseDiceRollerReturn {
|
|
31
31
|
currentNotation: WritableComputedRef<string>;
|
|
32
32
|
error: Ref<string | null>;
|
|
33
|
-
output:
|
|
33
|
+
output: ShallowRef<Roll | null>;
|
|
34
34
|
roll: () => void;
|
|
35
35
|
labels: ComputedRef<DiceRollerLabels>;
|
|
36
36
|
setNotation: (notation: string) => void;
|
|
@@ -43,7 +43,7 @@ export interface UseDiceRollerReturn {
|
|
|
43
43
|
export type DiceRollerEmits = {
|
|
44
44
|
'notation:change': [notation: string];
|
|
45
45
|
'update:notation': [notation: string];
|
|
46
|
-
roll: [notation: string, result:
|
|
46
|
+
roll: [notation: string, result: Roll | null];
|
|
47
47
|
};
|
|
48
48
|
export type DiceRollerSlots = {
|
|
49
49
|
button?: () => VNodeChild;
|
|
@@ -51,7 +51,7 @@ export type DiceRollerSlots = {
|
|
|
51
51
|
export interface DiceRollerSlotProps {
|
|
52
52
|
currentNotation: string;
|
|
53
53
|
error: string | null;
|
|
54
|
-
output:
|
|
54
|
+
output: Roll | null;
|
|
55
55
|
roll: () => void;
|
|
56
56
|
labels: DiceRollerLabels;
|
|
57
57
|
bind: {
|
package/dist/vue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed as e, createCommentVNode as t, createElementBlock as n, createElementVNode as r, createTextVNode as i, createVNode as a, defineComponent as o, getCurrentInstance as s, getCurrentScope as c, mergeProps as l, normalizeClass as u, normalizeStyle as d, onMounted as f, onScopeDispose as p, openBlock as m, reactive as h, ref as g, renderSlot as _, shallowReadonly as v, shallowRef as y, toDisplayString as b, toHandlers as x, toValue as S, unref as C, useId as w, watch as T } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { Roll as E, errors as D } from "@dice-roller/rpg-dice-roller";
|
|
3
3
|
// src/accessibility.ts
|
|
4
|
-
var
|
|
4
|
+
var O = {
|
|
5
5
|
position: "absolute",
|
|
6
6
|
width: "1px",
|
|
7
7
|
height: "1px",
|
|
@@ -13,12 +13,12 @@ var D = {
|
|
|
13
13
|
border: 0
|
|
14
14
|
};
|
|
15
15
|
// node_modules/@vueuse/shared/dist/index.js
|
|
16
|
-
function
|
|
16
|
+
function k(e, t) {
|
|
17
17
|
return c() ? (p(e, t), !0) : !1;
|
|
18
18
|
}
|
|
19
|
-
var
|
|
19
|
+
var A = typeof window < "u" && typeof document < "u";
|
|
20
20
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
21
|
-
function
|
|
21
|
+
function ee(e, t, n = {}) {
|
|
22
22
|
let { immediate: r = !0, immediateCallback: i = !1 } = n, a = y(!1), o;
|
|
23
23
|
function s() {
|
|
24
24
|
o &&= (clearTimeout(o), void 0);
|
|
@@ -31,26 +31,26 @@ function A(e, t, n = {}) {
|
|
|
31
31
|
a.value = !1, o = void 0, e(...n);
|
|
32
32
|
}, S(t));
|
|
33
33
|
}
|
|
34
|
-
return r && (a.value = !0,
|
|
34
|
+
return r && (a.value = !0, A && l()), k(c), {
|
|
35
35
|
isPending: v(a),
|
|
36
36
|
start: l,
|
|
37
37
|
stop: c
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
function
|
|
40
|
+
A && window.document, A && window.navigator, A && window.location;
|
|
41
|
+
function te() {
|
|
42
42
|
let e = y(!1), t = s();
|
|
43
43
|
return t && f(() => {
|
|
44
44
|
e.value = !0;
|
|
45
45
|
}, t), e;
|
|
46
46
|
}
|
|
47
47
|
/* @__NO_SIDE_EFFECTS__ */
|
|
48
|
-
function
|
|
49
|
-
let n =
|
|
48
|
+
function ne(t) {
|
|
49
|
+
let n = te();
|
|
50
50
|
return e(() => (n.value, !!t()));
|
|
51
51
|
}
|
|
52
52
|
// src/composables/useDiceRoller.ts
|
|
53
|
-
function
|
|
53
|
+
function j(t = {}) {
|
|
54
54
|
let n = e(() => ({
|
|
55
55
|
notation: "Notation",
|
|
56
56
|
copy: "Copy to clipboard",
|
|
@@ -59,7 +59,7 @@ function M(t = {}) {
|
|
|
59
59
|
invalidNotation: "Invalid notation",
|
|
60
60
|
error: "An error has occurred",
|
|
61
61
|
...S(t.labels)
|
|
62
|
-
})), r = g(S(t.notation) ?? ""), i = g(null), a =
|
|
62
|
+
})), r = g(S(t.notation) ?? ""), i = g(null), a = y(null), o = g(null);
|
|
63
63
|
T(() => S(t.notation), (e) => {
|
|
64
64
|
r.value = e ?? "";
|
|
65
65
|
});
|
|
@@ -69,7 +69,7 @@ function M(t = {}) {
|
|
|
69
69
|
a.value = r.value ? new E(r.value) : null;
|
|
70
70
|
} catch (e) {
|
|
71
71
|
let t = e;
|
|
72
|
-
a.value = null, i.value = `${
|
|
72
|
+
a.value = null, i.value = `${e instanceof D.NotationError ? n.value.invalidNotation : n.value.error}: ${t.message}`;
|
|
73
73
|
} finally {
|
|
74
74
|
t.onRoll?.(r.value, a.value);
|
|
75
75
|
}
|
|
@@ -80,7 +80,7 @@ function M(t = {}) {
|
|
|
80
80
|
set: c
|
|
81
81
|
}), u = (e) => {
|
|
82
82
|
e.key !== "Enter" || e.isComposing || e.keyCode === 229 || (e.preventDefault(), !e.repeat && !e.target?.disabled && r.value && s());
|
|
83
|
-
}, d = e(() => a.value ? String(a.value) : ""), f = g(""), p = g(!1), m = /* @__PURE__ */
|
|
83
|
+
}, d = e(() => a.value ? String(a.value) : ""), f = g(""), p = g(!1), m = /* @__PURE__ */ ne(() => typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function"), { start: _, stop: v } = ee(() => {
|
|
84
84
|
p.value = !1;
|
|
85
85
|
}, 1500, { immediate: !1 });
|
|
86
86
|
return {
|
|
@@ -114,11 +114,11 @@ function M(t = {}) {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
// src/composables/idGenerator.ts
|
|
117
|
-
function
|
|
117
|
+
function M(e = "") {
|
|
118
118
|
return { id: g(`${e}${w()}`) };
|
|
119
119
|
}
|
|
120
120
|
// node_modules/@heroicons/vue/24/outline/esm/ClipboardIcon.js
|
|
121
|
-
function
|
|
121
|
+
function N(e, t) {
|
|
122
122
|
return m(), n("svg", {
|
|
123
123
|
xmlns: "http://www.w3.org/2000/svg",
|
|
124
124
|
fill: "none",
|
|
@@ -134,12 +134,12 @@ function P(e, t) {
|
|
|
134
134
|
})]);
|
|
135
135
|
}
|
|
136
136
|
// src/components/DiceRoller.vue?vue&type=script&setup=true&lang.ts
|
|
137
|
-
var
|
|
137
|
+
var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
138
138
|
"aria-invalid",
|
|
139
139
|
"aria-describedby",
|
|
140
140
|
"id",
|
|
141
141
|
"placeholder"
|
|
142
|
-
],
|
|
142
|
+
], I = ["disabled"], L = ["id"], R = /* @__PURE__ */ o({
|
|
143
143
|
inheritAttrs: !1,
|
|
144
144
|
__name: "DiceRoller",
|
|
145
145
|
props: {
|
|
@@ -165,7 +165,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
165
165
|
"roll"
|
|
166
166
|
],
|
|
167
167
|
setup(e, { emit: o }) {
|
|
168
|
-
let s = o, c = e, { id: f } =
|
|
168
|
+
let s = o, c = e, { id: f } = M(`${c.id || "dice-roller"}-`), { error: p, output: h, roll: g, labels: v, bind: y, on: S, copy: w } = j({
|
|
169
169
|
notation: () => c.notation,
|
|
170
170
|
labels: () => c.labels,
|
|
171
171
|
onNotationChange: (e) => {
|
|
@@ -181,7 +181,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
181
181
|
role: "status",
|
|
182
182
|
"aria-live": "polite",
|
|
183
183
|
"aria-atomic": "true",
|
|
184
|
-
style: d(C(
|
|
184
|
+
style: d(C(O))
|
|
185
185
|
}, b(C(h) ? String(C(h)) : ""), 5),
|
|
186
186
|
C(h) ? (m(), n("output", {
|
|
187
187
|
key: 0,
|
|
@@ -196,24 +196,24 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
196
196
|
"aria-label": C(v).copy,
|
|
197
197
|
class: u(`${e.className}-copy-button`),
|
|
198
198
|
onClick: s[0] ||= (e) => C(w).copy()
|
|
199
|
-
}, [a(C(
|
|
199
|
+
}, [a(C(N), { class: u(`${e.className}-copy-icon`) }, null, 8, ["class"]), C(w).copied ? (m(), n("span", {
|
|
200
200
|
key: 0,
|
|
201
201
|
class: u(`${e.className}-copy-label-success`)
|
|
202
202
|
}, b(C(v).copied), 3)) : (m(), n("span", {
|
|
203
203
|
key: 1,
|
|
204
204
|
class: u(`${e.className}-copy-label`)
|
|
205
|
-
}, b(C(v).copy), 3))], 10,
|
|
205
|
+
}, b(C(v).copy), 3))], 10, ae)) : t("", !0)], 10, ie)) : t("", !0),
|
|
206
206
|
r("span", {
|
|
207
207
|
role: "status",
|
|
208
208
|
"aria-live": "polite",
|
|
209
|
-
style: d(C(w).error ? void 0 : C(
|
|
209
|
+
style: d(C(w).error ? void 0 : C(O)),
|
|
210
210
|
class: u(`${e.className}-copy-status`)
|
|
211
211
|
}, b(C(w).error || (C(w).copied ? C(v).copied : "")), 7),
|
|
212
212
|
r("div", { class: u(`${e.className}-input-group`) }, [
|
|
213
213
|
r("label", {
|
|
214
214
|
for: C(f),
|
|
215
215
|
class: u(`${e.className}-label`)
|
|
216
|
-
}, b(C(v).notation), 11,
|
|
216
|
+
}, b(C(v).notation), 11, P),
|
|
217
217
|
r("input", l({
|
|
218
218
|
...e.inputAttrs,
|
|
219
219
|
...C(y)
|
|
@@ -225,34 +225,34 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
225
225
|
id: C(f),
|
|
226
226
|
placeholder: `e.g. ${e.notation || "4d6"}`,
|
|
227
227
|
class: [`${e.className}-input`, C(p) ? `${e.className}-input-invalid` : null]
|
|
228
|
-
}, x(C(S), !0)), null, 16,
|
|
228
|
+
}, x(C(S), !0)), null, 16, F),
|
|
229
229
|
r("button", {
|
|
230
230
|
type: "button",
|
|
231
231
|
class: u(`${e.className}-button`),
|
|
232
232
|
disabled: !C(y).value || e.inputAttrs.disabled,
|
|
233
233
|
onClick: s[1] ||= (...e) => C(g) && C(g)(...e)
|
|
234
|
-
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 10,
|
|
234
|
+
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 10, I)
|
|
235
235
|
], 2),
|
|
236
236
|
C(p) ? (m(), n("span", {
|
|
237
237
|
key: 1,
|
|
238
238
|
id: `${C(f)}-error`,
|
|
239
239
|
role: "alert",
|
|
240
240
|
class: u(`${e.className}-error`)
|
|
241
|
-
}, b(C(p)), 11,
|
|
242
|
-
], 16,
|
|
241
|
+
}, b(C(p)), 11, L)) : t("", !0)
|
|
242
|
+
], 16, re));
|
|
243
243
|
}
|
|
244
|
-
}),
|
|
244
|
+
}), z = ["id"], B = ["for"], V = ["title", "aria-label"], H = {
|
|
245
245
|
key: 0,
|
|
246
246
|
class: "pointer-events-none absolute right-full top-1/2 z-10 mr-2 -translate-y-1/2 whitespace-nowrap rounded bg-[color:var(--dice-roller-copy-surface,#111827)] px-2 py-1 text-sm font-medium text-[color:var(--dice-roller-copy-text,#fff)] shadow-md"
|
|
247
|
-
},
|
|
247
|
+
}, U = {
|
|
248
248
|
key: 1,
|
|
249
249
|
class: "sr-only"
|
|
250
|
-
},
|
|
250
|
+
}, W = { class: "flex flex-col sm:flex-row gap-y-4" }, G = ["for"], K = [
|
|
251
251
|
"aria-invalid",
|
|
252
252
|
"aria-describedby",
|
|
253
253
|
"id",
|
|
254
254
|
"placeholder"
|
|
255
|
-
],
|
|
255
|
+
], q = ["disabled"], J = ["id"], oe = /* @__PURE__ */ o({
|
|
256
256
|
inheritAttrs: !1,
|
|
257
257
|
__name: "DiceRollerTailwind",
|
|
258
258
|
props: {
|
|
@@ -274,7 +274,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
274
274
|
"roll"
|
|
275
275
|
],
|
|
276
276
|
setup(e, { emit: o }) {
|
|
277
|
-
let s = o, c = e, { id: f } =
|
|
277
|
+
let s = o, c = e, { id: f } = M(`${c.id || "dice-roller"}-`), { error: p, output: h, roll: g, labels: v, bind: y, on: S, copy: w } = j({
|
|
278
278
|
notation: () => c.notation,
|
|
279
279
|
labels: () => c.labels,
|
|
280
280
|
onNotationChange: (e) => {
|
|
@@ -290,7 +290,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
290
290
|
role: "status",
|
|
291
291
|
"aria-live": "polite",
|
|
292
292
|
"aria-atomic": "true",
|
|
293
|
-
style: d(C(
|
|
293
|
+
style: d(C(O))
|
|
294
294
|
}, b(C(h) ? String(C(h)) : ""), 5),
|
|
295
295
|
C(h) ? (m(), n("output", {
|
|
296
296
|
key: 0,
|
|
@@ -305,17 +305,17 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
305
305
|
"aria-label": C(v).copy,
|
|
306
306
|
class: "relative inline-flex shrink-0 items-center group/copy focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))]",
|
|
307
307
|
onClick: s[0] ||= (e) => C(w).copy()
|
|
308
|
-
}, [a(C(
|
|
308
|
+
}, [a(C(N), { class: "w-6 h-6 opacity-50 group-hover/copy:opacity-100" }), C(w).copied ? (m(), n("span", H, b(C(v).copied), 1)) : (m(), n("span", U, b(C(v).copy), 1))], 8, V)) : t("", !0)], 8, B)) : t("", !0),
|
|
309
309
|
r("span", {
|
|
310
310
|
role: "status",
|
|
311
311
|
"aria-live": "polite",
|
|
312
312
|
class: u(C(w).error ? "block mt-2 text-[color:var(--dice-roller-error,#b91c1c)] dark:text-[color:var(--dice-roller-error-dark,var(--dice-roller-error,#fecaca))]" : "sr-only")
|
|
313
313
|
}, b(C(w).error || (C(w).copied ? C(v).copied : "")), 3),
|
|
314
|
-
r("div",
|
|
314
|
+
r("div", W, [
|
|
315
315
|
r("label", {
|
|
316
316
|
for: C(f),
|
|
317
317
|
class: "sr-only"
|
|
318
|
-
}, b(C(v).notation), 9,
|
|
318
|
+
}, b(C(v).notation), 9, G),
|
|
319
319
|
r("input", l({
|
|
320
320
|
...e.inputAttrs,
|
|
321
321
|
...C(y)
|
|
@@ -327,32 +327,32 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
327
327
|
id: C(f),
|
|
328
328
|
placeholder: `e.g. ${e.notation || "4d6"}`,
|
|
329
329
|
class: ["min-w-0 flex-1 block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-[color:var(--dice-roller-input-placeholder,#6b7280)] dark:placeholder-[color:var(--dice-roller-input-placeholder-dark,var(--dice-roller-input-placeholder,#94a3b8))] focus:ring-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus:border-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))] focus:placeholder-[color:var(--dice-roller-input-placeholder-focus,#9ca3af)] dark:focus:placeholder-[color:var(--dice-roller-input-placeholder-focus-dark,var(--dice-roller-input-placeholder-focus,#94a3b8))] invalid:text-[color:var(--dice-roller-input-error-text,var(--dice-roller-error,#b91c1c))] invalid:border-[color:var(--dice-roller-input-error-border,#fecaca)] invalid:bg-[color:var(--dice-roller-input-error-surface,#fef2f2)] sm:border-r-0 sm:rounded-r-none", C(p) ? "text-[color:var(--dice-roller-input-error-text,var(--dice-roller-error,#b91c1c))] border-[color:var(--dice-roller-input-error-border,#fecaca)] bg-[color:var(--dice-roller-input-error-surface,#fef2f2)]" : "bg-[color:var(--dice-roller-input-surface,#fff)] dark:bg-[color:var(--dice-roller-input-surface-dark,var(--dice-roller-input-surface,#0f172a))] text-[color:var(--dice-roller-input-text,#111827)] dark:text-[color:var(--dice-roller-input-text-dark,var(--dice-roller-input-text,#e2e8f0))] border-[color:var(--dice-roller-border,#d1d5db)] dark:border-[color:var(--dice-roller-border-dark,var(--dice-roller-border,#374151))]"]
|
|
330
|
-
}, x(C(S), !0)), null, 16,
|
|
330
|
+
}, x(C(S), !0)), null, 16, K),
|
|
331
331
|
r("button", {
|
|
332
332
|
type: "button",
|
|
333
333
|
class: "inline-flex shrink-0 items-center justify-center whitespace-nowrap px-8 h-11 font-bold text-[color:var(--dice-roller-on-primary,#111827)] bg-gradient-to-br from-[color:var(--dice-roller-button-from,var(--dice-roller-primary,#eda18b))] to-[color:var(--dice-roller-button-to,var(--dice-roller-primary,#d4f4c6))] border sm:border-l-0 border-[color:var(--dice-roller-border,#d1d5db)] rounded transition dark:border-[color:var(--dice-roller-border-dark,var(--dice-roller-border,#374151))] focus:from-[color:var(--dice-roller-button-hover-from,var(--dice-roller-primary-hover,var(--dice-roller-primary,#e88c71)))] focus:to-[color:var(--dice-roller-button-hover-to,var(--dice-roller-primary-hover,var(--dice-roller-primary,#bbf0a3)))] focus:text-[color:var(--dice-roller-on-primary,#1f2937)] focus:ring-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus:border-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))] hover:from-[color:var(--dice-roller-button-hover-from,var(--dice-roller-primary-hover,var(--dice-roller-primary,#e88c71)))] hover:to-[color:var(--dice-roller-button-hover-to,var(--dice-roller-primary-hover,var(--dice-roller-primary,#bbf0a3)))] hover:text-[color:var(--dice-roller-on-primary,#1f2937)] sm:rounded-l-none",
|
|
334
334
|
disabled: !C(y).value || e.inputAttrs.disabled,
|
|
335
335
|
onClick: s[1] ||= (...e) => C(g) && C(g)(...e)
|
|
336
|
-
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 8,
|
|
336
|
+
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 8, q)
|
|
337
337
|
]),
|
|
338
338
|
C(p) ? (m(), n("span", {
|
|
339
339
|
key: 1,
|
|
340
340
|
id: `${C(f)}-error`,
|
|
341
341
|
role: "alert",
|
|
342
342
|
class: "block mt-4 text-sm text-[color:var(--dice-roller-error,#b91c1c)] dark:text-[color:var(--dice-roller-error-dark,var(--dice-roller-error,#fecaca))]"
|
|
343
|
-
}, b(C(p)), 9,
|
|
344
|
-
], 16,
|
|
343
|
+
}, b(C(p)), 9, J)) : t("", !0)
|
|
344
|
+
], 16, z));
|
|
345
345
|
}
|
|
346
|
-
}),
|
|
346
|
+
}), se = ["id"], ce = { class: "card-body" }, le = ["for"], ue = { class: "flex-grow-1 text-break" }, de = ["title", "aria-label"], fe = {
|
|
347
347
|
key: 0,
|
|
348
348
|
"aria-hidden": "true",
|
|
349
349
|
class: "position-absolute top-50 end-100 translate-middle-y me-2 badge text-bg-dark fs-6 fw-normal text-nowrap shadow pe-none"
|
|
350
|
-
},
|
|
350
|
+
}, pe = ["for"], me = { class: "input-group" }, he = [
|
|
351
351
|
"aria-invalid",
|
|
352
352
|
"aria-describedby",
|
|
353
353
|
"id",
|
|
354
354
|
"placeholder"
|
|
355
|
-
],
|
|
355
|
+
], ge = ["disabled"], _e = ["id"], Y = [
|
|
356
356
|
"primary",
|
|
357
357
|
"secondary",
|
|
358
358
|
"success",
|
|
@@ -361,20 +361,20 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
361
361
|
"info",
|
|
362
362
|
"light",
|
|
363
363
|
"dark"
|
|
364
|
-
],
|
|
365
|
-
...
|
|
364
|
+
], X = [
|
|
365
|
+
...Y,
|
|
366
366
|
"body",
|
|
367
367
|
"white",
|
|
368
368
|
"transparent"
|
|
369
|
-
],
|
|
370
|
-
...
|
|
369
|
+
], Z = [
|
|
370
|
+
...Y,
|
|
371
371
|
"body",
|
|
372
372
|
"muted",
|
|
373
373
|
"white",
|
|
374
374
|
"black-50",
|
|
375
375
|
"white-50"
|
|
376
|
-
],
|
|
377
|
-
...
|
|
376
|
+
], Q = [
|
|
377
|
+
...Y,
|
|
378
378
|
"link",
|
|
379
379
|
"outline-primary",
|
|
380
380
|
"outline-secondary",
|
|
@@ -384,14 +384,14 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
384
384
|
"outline-info",
|
|
385
385
|
"outline-light",
|
|
386
386
|
"outline-dark"
|
|
387
|
-
], $ = [...
|
|
387
|
+
], $ = [...Y, "white"], ve = /* @__PURE__ */ o({
|
|
388
388
|
inheritAttrs: !1,
|
|
389
389
|
__name: "DiceRollerBootstrap",
|
|
390
390
|
props: {
|
|
391
391
|
bgVariant: {
|
|
392
392
|
type: String,
|
|
393
393
|
validator(e) {
|
|
394
|
-
return
|
|
394
|
+
return X.includes(e);
|
|
395
395
|
}
|
|
396
396
|
},
|
|
397
397
|
borderVariant: {
|
|
@@ -408,7 +408,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
408
408
|
type: String,
|
|
409
409
|
default: "primary",
|
|
410
410
|
validator(e) {
|
|
411
|
-
return
|
|
411
|
+
return Q.includes(e);
|
|
412
412
|
}
|
|
413
413
|
},
|
|
414
414
|
id: String,
|
|
@@ -421,7 +421,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
421
421
|
outputBgVariant: {
|
|
422
422
|
type: String,
|
|
423
423
|
validator(e) {
|
|
424
|
-
return
|
|
424
|
+
return X.includes(e);
|
|
425
425
|
}
|
|
426
426
|
},
|
|
427
427
|
outputBorderVariant: {
|
|
@@ -433,25 +433,25 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
433
433
|
outputTextVariant: {
|
|
434
434
|
type: String,
|
|
435
435
|
validator(e) {
|
|
436
|
-
return
|
|
436
|
+
return Z.includes(e);
|
|
437
437
|
}
|
|
438
438
|
},
|
|
439
439
|
outputVariant: {
|
|
440
440
|
type: String,
|
|
441
441
|
validator(e) {
|
|
442
|
-
return
|
|
442
|
+
return Y.includes(e);
|
|
443
443
|
}
|
|
444
444
|
},
|
|
445
445
|
textVariant: {
|
|
446
446
|
type: String,
|
|
447
447
|
validator(e) {
|
|
448
|
-
return
|
|
448
|
+
return Z.includes(e);
|
|
449
449
|
}
|
|
450
450
|
},
|
|
451
451
|
variant: {
|
|
452
452
|
type: String,
|
|
453
453
|
validator(e) {
|
|
454
|
-
return
|
|
454
|
+
return Y.includes(e);
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
},
|
|
@@ -471,7 +471,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
471
471
|
[`bg-${f.outputBgVariant}`]: f.outputBgVariant,
|
|
472
472
|
[`text-${f.outputTextVariant}`]: f.outputTextVariant,
|
|
473
473
|
[`border-${f.outputBorderVariant}`]: f.outputBorderVariant
|
|
474
|
-
})), g = e(() => `btn-${f.btnVariant || "primary"}`), { id: v } =
|
|
474
|
+
})), g = e(() => `btn-${f.btnVariant || "primary"}`), { id: v } = M(`${f.id || "dice-roller"}-`), { error: y, output: S, roll: w, labels: T, bind: E, on: D, copy: k } = j({
|
|
475
475
|
notation: () => f.notation,
|
|
476
476
|
labels: () => f.labels,
|
|
477
477
|
onNotationChange: (e) => {
|
|
@@ -482,12 +482,12 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
482
482
|
return (e, s) => (m(), n("div", l(e.$attrs, {
|
|
483
483
|
id: o.id,
|
|
484
484
|
class: ["dice-roller card", p.value]
|
|
485
|
-
}), [r("div",
|
|
485
|
+
}), [r("div", ce, [
|
|
486
486
|
r("span", {
|
|
487
487
|
role: "status",
|
|
488
488
|
"aria-live": "polite",
|
|
489
489
|
"aria-atomic": "true",
|
|
490
|
-
style: d(C(
|
|
490
|
+
style: d(C(O))
|
|
491
491
|
}, b(C(S) ? String(C(S)) : ""), 5),
|
|
492
492
|
C(S) ? (m(), n("output", {
|
|
493
493
|
key: 0,
|
|
@@ -495,21 +495,21 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
495
495
|
"aria-live": "off",
|
|
496
496
|
for: C(v),
|
|
497
497
|
class: u(["d-flex align-items-center justify-content-between gap-3 mb-4 p-3 fs-4 rounded border", h.value])
|
|
498
|
-
}, [r("span",
|
|
498
|
+
}, [r("span", ue, b(C(S)), 1), C(k).isSupported ? (m(), n("button", {
|
|
499
499
|
key: 0,
|
|
500
500
|
type: "button",
|
|
501
501
|
title: C(T).copy,
|
|
502
502
|
"aria-label": C(T).copy,
|
|
503
503
|
class: "btn btn-link link-body-emphasis text-decoration-none p-2 d-inline-flex align-items-center flex-shrink-0 position-relative",
|
|
504
504
|
onClick: s[0] ||= (e) => C(k).copy()
|
|
505
|
-
}, [a(C(
|
|
505
|
+
}, [a(C(N), {
|
|
506
506
|
class: "flex-shrink-0",
|
|
507
507
|
style: {
|
|
508
508
|
width: "1.5rem",
|
|
509
509
|
height: "1.5rem"
|
|
510
510
|
},
|
|
511
511
|
"aria-hidden": "true"
|
|
512
|
-
}), C(k).copied ? (m(), n("span",
|
|
512
|
+
}), C(k).copied ? (m(), n("span", fe, b(C(T).copied), 1)) : t("", !0)], 8, de)) : t("", !0)], 10, le)) : t("", !0),
|
|
513
513
|
r("span", {
|
|
514
514
|
role: "status",
|
|
515
515
|
"aria-live": "polite",
|
|
@@ -518,8 +518,8 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
518
518
|
r("label", {
|
|
519
519
|
for: C(v),
|
|
520
520
|
class: "form-label visually-hidden"
|
|
521
|
-
}, b(C(T).notation), 9,
|
|
522
|
-
r("div",
|
|
521
|
+
}, b(C(T).notation), 9, pe),
|
|
522
|
+
r("div", me, [r("input", l({
|
|
523
523
|
...o.inputAttrs,
|
|
524
524
|
...C(E)
|
|
525
525
|
}, {
|
|
@@ -530,21 +530,21 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
530
530
|
id: C(v),
|
|
531
531
|
placeholder: `e.g. ${o.notation || "4d6"}`,
|
|
532
532
|
class: ["form-control", C(y) ? "is-invalid" : ""]
|
|
533
|
-
}, x(C(
|
|
533
|
+
}, x(C(D), !0)), null, 16, he), r("button", {
|
|
534
534
|
type: "button",
|
|
535
535
|
class: u(["btn", g.value]),
|
|
536
536
|
disabled: !C(E).value || o.inputAttrs.disabled,
|
|
537
537
|
onClick: s[1] ||= (...e) => C(w) && C(w)(...e)
|
|
538
|
-
}, [_(e.$slots, "button", {}, () => [i(b(o.btnLabel), 1)])], 10,
|
|
538
|
+
}, [_(e.$slots, "button", {}, () => [i(b(o.btnLabel), 1)])], 10, ge)]),
|
|
539
539
|
C(y) ? (m(), n("span", {
|
|
540
540
|
key: 1,
|
|
541
541
|
id: `${C(v)}-error`,
|
|
542
542
|
role: "alert",
|
|
543
543
|
class: "d-block mt-3 invalid-feedback"
|
|
544
|
-
}, b(C(y)), 9,
|
|
545
|
-
])], 16,
|
|
544
|
+
}, b(C(y)), 9, _e)) : t("", !0)
|
|
545
|
+
])], 16, se));
|
|
546
546
|
}
|
|
547
|
-
}),
|
|
547
|
+
}), ye = /* @__PURE__ */ o({
|
|
548
548
|
__name: "DiceRollerRenderless",
|
|
549
549
|
props: {
|
|
550
550
|
notation: String,
|
|
@@ -559,7 +559,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
559
559
|
"roll"
|
|
560
560
|
],
|
|
561
561
|
setup(e, { emit: t }) {
|
|
562
|
-
let n = t, r = e, { currentNotation: i, error: a, output: o, roll: s, labels: c, bind: l, on: u, copy: d } =
|
|
562
|
+
let n = t, r = e, { currentNotation: i, error: a, output: o, roll: s, labels: c, bind: l, on: u, copy: d } = j({
|
|
563
563
|
notation: () => r.notation,
|
|
564
564
|
labels: () => r.labels,
|
|
565
565
|
onNotationChange: (e) => {
|
|
@@ -579,4 +579,4 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
});
|
|
582
|
-
export {
|
|
582
|
+
export { R as DiceRoller, ve as DiceRollerBootstrap, ye as DiceRollerRenderless, oe as DiceRollerTailwind, j as useDiceRoller };
|
package/dist/vue.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("@dice-roller/rpg-dice-roller")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@dice-roller/rpg-dice-roller`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.DiceRollerVue={},e.Vue,e.rpgDiceRoller))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r={position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,border:0};function i(e,n){return(0,t.getCurrentScope)()?((0,t.onScopeDispose)(e,n),!0):!1}var a=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;function o(e,n,r={}){let{immediate:o=!0,immediateCallback:s=!1}=r,c=(0,t.shallowRef)(!1),l;function u(){l&&=(clearTimeout(l),void 0)}function d(){c.value=!1,u()}function f(...r){s&&e(),u(),c.value=!0,l=setTimeout(()=>{c.value=!1,l=void 0,e(...r)},(0,t.toValue)(n))}return o&&(c.value=!0,a&&f()),i(d),{isPending:(0,t.shallowReadonly)(c),start:f,stop:d}}a&&window.document,a&&window.navigator,a&&window.location;function s(){let e=(0,t.shallowRef)(!1),n=(0,t.getCurrentInstance)();return n&&(0,t.onMounted)(()=>{e.value=!0},n),e}function c(e){let n=s();return(0,t.computed)(()=>(n.value,!!e()))}function l(e={}){let r=(0,t.computed)(()=>({notation:`Notation`,copy:`Copy to clipboard`,copied:`Copied!`,copyError:`Unable to copy to clipboard. Please try again.`,invalidNotation:`Invalid notation`,error:`An error has occurred`,...(0,t.toValue)(e.labels)})),i=(0,t.ref)((0,t.toValue)(e.notation)??``),a=(0,t.ref)(null),s=(0,t.ref)(null),l=(0,t.ref)(null);(0,t.watch)(()=>(0,t.toValue)(e.notation),e=>{i.value=e??``});let u=()=>{a.value=null,l.value=null;try{s.value=i.value?new n.DiceRoll(i.value):null}catch(e){let t=e;s.value=null,a.value=`${t.name===`SyntaxError`?r.value.invalidNotation:r.value.error}: ${t.message}`}finally{e.onRoll?.(i.value,s.value)}},d=t=>{i.value!==t&&(i.value=t,e.onNotationChange?.(t))},f=(0,t.computed)({get:()=>i.value,set:d}),p=e=>{e.key!==`Enter`||e.isComposing||e.keyCode===229||(e.preventDefault(),!e.repeat&&!e.target?.disabled&&i.value&&u())},m=(0,t.computed)(()=>s.value?String(s.value):``),h=(0,t.ref)(``),g=(0,t.ref)(!1),_=c(()=>typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`),{start:v,stop:y}=o(()=>{g.value=!1},1500,{immediate:!1});return{currentNotation:f,error:a,output:s,roll:u,labels:r,setNotation:d,bind:(0,t.computed)(()=>({value:f.value})),on:{input:e=>d(e.target.value),change:e=>d(e.target.value),keydown:p},copy:(0,t.reactive)({copy:async()=>{if(l.value=null,g.value=!1,y(),!s.value)return;let e=m.value;try{await navigator.clipboard.writeText(e),h.value=e,g.value=!0,v()}catch{l.value=r.value.copyError}},copied:g,text:h,isSupported:_,error:l})}}function u(e=``){return{id:(0,t.ref)(`${e}${(0,t.useId)()}`)}}function d(e,n){return(0,t.openBlock)(),(0,t.createElementBlock)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,"stroke-width":`1.5`,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`},[(0,t.createElementVNode)(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184`})])}var f=[`id`],p=[`for`],m=[`title`,`aria-label`],h=[`for`],g=[`aria-invalid`,`aria-describedby`,`id`,`placeholder`],_=[`disabled`],v=[`id`],y=(0,t.defineComponent)({inheritAttrs:!1,__name:`DiceRoller`,props:{btnLabel:{type:String,default:`Roll`},className:{type:String,default:`dice-roller`},id:String,notation:String,labels:Object,inputAttrs:{type:Object,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let i=n,a=e,{id:o}=u(`${a.id||`dice-roller`}-`),{error:s,output:c,roll:y,labels:b,bind:x,on:S,copy:C}=l({notation:()=>a.notation,labels:()=>a.labels,onNotationChange:e=>{i(`update:notation`,e),i(`notation:change`,e)},onRoll:(e,t)=>i(`roll`,e,t)});return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`section`,(0,t.mergeProps)(n.$attrs,{id:e.id,class:e.className}),[(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,style:(0,t.normalizeStyle)((0,t.unref)(r))},(0,t.toDisplayString)((0,t.unref)(c)?String((0,t.unref)(c)):``),5),(0,t.unref)(c)?((0,t.openBlock)(),(0,t.createElementBlock)(`output`,{key:0,name:`output`,"aria-live":`off`,for:(0,t.unref)(o),class:(0,t.normalizeClass)(`${e.className}-output`)},[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(c))+` `,1),(0,t.unref)(C).isSupported?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,type:`button`,title:(0,t.unref)(b).copy,"aria-label":(0,t.unref)(b).copy,class:(0,t.normalizeClass)(`${e.className}-copy-button`),onClick:i[0]||=e=>(0,t.unref)(C).copy()},[(0,t.createVNode)((0,t.unref)(d),{class:(0,t.normalizeClass)(`${e.className}-copy-icon`)},null,8,[`class`]),(0,t.unref)(C).copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,class:(0,t.normalizeClass)(`${e.className}-copy-label-success`)},(0,t.toDisplayString)((0,t.unref)(b).copied),3)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,class:(0,t.normalizeClass)(`${e.className}-copy-label`)},(0,t.toDisplayString)((0,t.unref)(b).copy),3))],10,m)):(0,t.createCommentVNode)(``,!0)],10,p)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,style:(0,t.normalizeStyle)((0,t.unref)(C).error?void 0:(0,t.unref)(r)),class:(0,t.normalizeClass)(`${e.className}-copy-status`)},(0,t.toDisplayString)((0,t.unref)(C).error||((0,t.unref)(C).copied?(0,t.unref)(b).copied:``)),7),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)(`${e.className}-input-group`)},[(0,t.createElementVNode)(`label`,{for:(0,t.unref)(o),class:(0,t.normalizeClass)(`${e.className}-label`)},(0,t.toDisplayString)((0,t.unref)(b).notation),11,h),(0,t.createElementVNode)(`input`,(0,t.mergeProps)({...e.inputAttrs,...(0,t.unref)(x)},{"aria-invalid":(0,t.unref)(s)?`true`:void 0,"aria-describedby":[e.inputAttrs[`aria-describedby`],(0,t.unref)(s)?`${(0,t.unref)(o)}-error`:null].filter(Boolean).join(` `)||void 0,type:`text`,name:`notation`,id:(0,t.unref)(o),placeholder:`e.g. ${e.notation||`4d6`}`,class:[`${e.className}-input`,(0,t.unref)(s)?`${e.className}-input-invalid`:null]},(0,t.toHandlers)((0,t.unref)(S),!0)),null,16,g),(0,t.createElementVNode)(`button`,{type:`button`,class:(0,t.normalizeClass)(`${e.className}-button`),disabled:!(0,t.unref)(x).value||e.inputAttrs.disabled,onClick:i[1]||=(...e)=>(0,t.unref)(y)&&(0,t.unref)(y)(...e)},[(0,t.renderSlot)(n.$slots,`button`,{},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e.btnLabel),1)])],10,_)],2),(0,t.unref)(s)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,id:`${(0,t.unref)(o)}-error`,role:`alert`,class:(0,t.normalizeClass)(`${e.className}-error`)},(0,t.toDisplayString)((0,t.unref)(s)),11,v)):(0,t.createCommentVNode)(``,!0)],16,f))}}),b=[`id`],x=[`for`],S=[`title`,`aria-label`],C={key:0,class:`pointer-events-none absolute right-full top-1/2 z-10 mr-2 -translate-y-1/2 whitespace-nowrap rounded bg-[color:var(--dice-roller-copy-surface,#111827)] px-2 py-1 text-sm font-medium text-[color:var(--dice-roller-copy-text,#fff)] shadow-md`},w={key:1,class:`sr-only`},T={class:`flex flex-col sm:flex-row gap-y-4`},E=[`for`],D=[`aria-invalid`,`aria-describedby`,`id`,`placeholder`],O=[`disabled`],k=[`id`],A=(0,t.defineComponent)({inheritAttrs:!1,__name:`DiceRollerTailwind`,props:{btnLabel:{type:String,default:`Roll`},id:String,notation:String,labels:Object,inputAttrs:{type:Object,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let i=n,a=e,{id:o}=u(`${a.id||`dice-roller`}-`),{error:s,output:c,roll:f,labels:p,bind:m,on:h,copy:g}=l({notation:()=>a.notation,labels:()=>a.labels,onNotationChange:e=>{i(`update:notation`,e),i(`notation:change`,e)},onRoll:(e,t)=>i(`roll`,e,t)});return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,(0,t.mergeProps)(n.$attrs,{id:e.id,class:`dice-roller p-4 rounded bg-[color:var(--dice-roller-surface,#f1f5f9)] dark:bg-[color:var(--dice-roller-surface-dark,var(--dice-roller-surface,#4b5563))] text-[color:var(--dice-roller-text,#1f2937)] dark:text-[color:var(--dice-roller-text-dark,var(--dice-roller-text,#e5e7eb))]`}),[(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,style:(0,t.normalizeStyle)((0,t.unref)(r))},(0,t.toDisplayString)((0,t.unref)(c)?String((0,t.unref)(c)):``),5),(0,t.unref)(c)?((0,t.openBlock)(),(0,t.createElementBlock)(`output`,{key:0,name:`output`,"aria-live":`off`,for:(0,t.unref)(o),class:`flex flex-row flex-nowrap justify-between mb-4 p-4 text-2xl rounded bg-[color:var(--dice-roller-output-surface,#fff)] dark:bg-[color:var(--dice-roller-output-surface-dark,var(--dice-roller-output-surface,#1e293b))] text-[color:var(--dice-roller-output-text,#000)] dark:text-[color:var(--dice-roller-output-text-dark,var(--dice-roller-output-text,#e2e8f0))] border-l-8 border-[color:var(--dice-roller-output-accent,var(--dice-roller-primary,#d4f4c6))] dark:border-[color:var(--dice-roller-output-accent-dark,var(--dice-roller-output-accent,var(--dice-roller-primary,#6b8f63)))]`},[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(c))+` `,1),(0,t.unref)(g).isSupported?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,type:`button`,title:(0,t.unref)(p).copy,"aria-label":(0,t.unref)(p).copy,class:`relative inline-flex shrink-0 items-center group/copy focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))]`,onClick:i[0]||=e=>(0,t.unref)(g).copy()},[(0,t.createVNode)((0,t.unref)(d),{class:`w-6 h-6 opacity-50 group-hover/copy:opacity-100`}),(0,t.unref)(g).copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,C,(0,t.toDisplayString)((0,t.unref)(p).copied),1)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,w,(0,t.toDisplayString)((0,t.unref)(p).copy),1))],8,S)):(0,t.createCommentVNode)(``,!0)],8,x)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,class:(0,t.normalizeClass)((0,t.unref)(g).error?`block mt-2 text-[color:var(--dice-roller-error,#b91c1c)] dark:text-[color:var(--dice-roller-error-dark,var(--dice-roller-error,#fecaca))]`:`sr-only`)},(0,t.toDisplayString)((0,t.unref)(g).error||((0,t.unref)(g).copied?(0,t.unref)(p).copied:``)),3),(0,t.createElementVNode)(`div`,T,[(0,t.createElementVNode)(`label`,{for:(0,t.unref)(o),class:`sr-only`},(0,t.toDisplayString)((0,t.unref)(p).notation),9,E),(0,t.createElementVNode)(`input`,(0,t.mergeProps)({...e.inputAttrs,...(0,t.unref)(m)},{"aria-invalid":(0,t.unref)(s)?`true`:void 0,"aria-describedby":[e.inputAttrs[`aria-describedby`],(0,t.unref)(s)?`${(0,t.unref)(o)}-error`:null].filter(Boolean).join(` `)||void 0,type:`text`,name:`notation`,id:(0,t.unref)(o),placeholder:`e.g. ${e.notation||`4d6`}`,class:[`min-w-0 flex-1 block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-[color:var(--dice-roller-input-placeholder,#6b7280)] dark:placeholder-[color:var(--dice-roller-input-placeholder-dark,var(--dice-roller-input-placeholder,#94a3b8))] focus:ring-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus:border-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))] focus:placeholder-[color:var(--dice-roller-input-placeholder-focus,#9ca3af)] dark:focus:placeholder-[color:var(--dice-roller-input-placeholder-focus-dark,var(--dice-roller-input-placeholder-focus,#94a3b8))] invalid:text-[color:var(--dice-roller-input-error-text,var(--dice-roller-error,#b91c1c))] invalid:border-[color:var(--dice-roller-input-error-border,#fecaca)] invalid:bg-[color:var(--dice-roller-input-error-surface,#fef2f2)] sm:border-r-0 sm:rounded-r-none`,(0,t.unref)(s)?`text-[color:var(--dice-roller-input-error-text,var(--dice-roller-error,#b91c1c))] border-[color:var(--dice-roller-input-error-border,#fecaca)] bg-[color:var(--dice-roller-input-error-surface,#fef2f2)]`:`bg-[color:var(--dice-roller-input-surface,#fff)] dark:bg-[color:var(--dice-roller-input-surface-dark,var(--dice-roller-input-surface,#0f172a))] text-[color:var(--dice-roller-input-text,#111827)] dark:text-[color:var(--dice-roller-input-text-dark,var(--dice-roller-input-text,#e2e8f0))] border-[color:var(--dice-roller-border,#d1d5db)] dark:border-[color:var(--dice-roller-border-dark,var(--dice-roller-border,#374151))]`]},(0,t.toHandlers)((0,t.unref)(h),!0)),null,16,D),(0,t.createElementVNode)(`button`,{type:`button`,class:`inline-flex shrink-0 items-center justify-center whitespace-nowrap px-8 h-11 font-bold text-[color:var(--dice-roller-on-primary,#111827)] bg-gradient-to-br from-[color:var(--dice-roller-button-from,var(--dice-roller-primary,#eda18b))] to-[color:var(--dice-roller-button-to,var(--dice-roller-primary,#d4f4c6))] border sm:border-l-0 border-[color:var(--dice-roller-border,#d1d5db)] rounded transition dark:border-[color:var(--dice-roller-border-dark,var(--dice-roller-border,#374151))] focus:from-[color:var(--dice-roller-button-hover-from,var(--dice-roller-primary-hover,var(--dice-roller-primary,#e88c71)))] focus:to-[color:var(--dice-roller-button-hover-to,var(--dice-roller-primary-hover,var(--dice-roller-primary,#bbf0a3)))] focus:text-[color:var(--dice-roller-on-primary,#1f2937)] focus:ring-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus:border-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))] hover:from-[color:var(--dice-roller-button-hover-from,var(--dice-roller-primary-hover,var(--dice-roller-primary,#e88c71)))] hover:to-[color:var(--dice-roller-button-hover-to,var(--dice-roller-primary-hover,var(--dice-roller-primary,#bbf0a3)))] hover:text-[color:var(--dice-roller-on-primary,#1f2937)] sm:rounded-l-none`,disabled:!(0,t.unref)(m).value||e.inputAttrs.disabled,onClick:i[1]||=(...e)=>(0,t.unref)(f)&&(0,t.unref)(f)(...e)},[(0,t.renderSlot)(n.$slots,`button`,{},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e.btnLabel),1)])],8,O)]),(0,t.unref)(s)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,id:`${(0,t.unref)(o)}-error`,role:`alert`,class:`block mt-4 text-sm text-[color:var(--dice-roller-error,#b91c1c)] dark:text-[color:var(--dice-roller-error-dark,var(--dice-roller-error,#fecaca))]`},(0,t.toDisplayString)((0,t.unref)(s)),9,k)):(0,t.createCommentVNode)(``,!0)],16,b))}}),j=[`id`],M={class:`card-body`},N=[`for`],P={class:`flex-grow-1 text-break`},F=[`title`,`aria-label`],I={key:0,"aria-hidden":`true`,class:`position-absolute top-50 end-100 translate-middle-y me-2 badge text-bg-dark fs-6 fw-normal text-nowrap shadow pe-none`},L=[`for`],R={class:`input-group`},z=[`aria-invalid`,`aria-describedby`,`id`,`placeholder`],B=[`disabled`],V=[`id`],H=[`primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`],U=[...H,`body`,`white`,`transparent`],W=[...H,`body`,`muted`,`white`,`black-50`,`white-50`],G=[...H,`link`,`outline-primary`,`outline-secondary`,`outline-success`,`outline-danger`,`outline-warning`,`outline-info`,`outline-light`,`outline-dark`],K=[...H,`white`],q=(0,t.defineComponent)({inheritAttrs:!1,__name:`DiceRollerBootstrap`,props:{bgVariant:{type:String,validator(e){return U.includes(e)}},borderVariant:{type:String,validator(e){return K.includes(e)}},btnLabel:{type:String,default:`Roll`},btnVariant:{type:String,default:`primary`,validator(e){return G.includes(e)}},id:String,notation:String,labels:Object,inputAttrs:{type:Object,default:()=>({})},outputBgVariant:{type:String,validator(e){return U.includes(e)}},outputBorderVariant:{type:String,validator(e){return K.includes(e)}},outputTextVariant:{type:String,validator(e){return W.includes(e)}},outputVariant:{type:String,validator(e){return H.includes(e)}},textVariant:{type:String,validator(e){return W.includes(e)}},variant:{type:String,validator(e){return H.includes(e)}}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let i=n,a=e,o=(0,t.computed)(()=>({[`text-bg-${a.variant}`]:a.variant,[`bg-${a.bgVariant}`]:a.bgVariant,[`text-${a.textVariant}`]:a.textVariant,[`border-${a.borderVariant}`]:a.borderVariant})),s=(0,t.computed)(()=>({[`text-bg-${a.outputVariant}`]:a.outputVariant,[`bg-${a.outputBgVariant}`]:a.outputBgVariant,[`text-${a.outputTextVariant}`]:a.outputTextVariant,[`border-${a.outputBorderVariant}`]:a.outputBorderVariant})),c=(0,t.computed)(()=>`btn-${a.btnVariant||`primary`}`),{id:f}=u(`${a.id||`dice-roller`}-`),{error:p,output:m,roll:h,labels:g,bind:_,on:v,copy:y}=l({notation:()=>a.notation,labels:()=>a.labels,onNotationChange:e=>{i(`update:notation`,e),i(`notation:change`,e)},onRoll:(e,t)=>i(`roll`,e,t)});return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,(0,t.mergeProps)(n.$attrs,{id:e.id,class:[`dice-roller card`,o.value]}),[(0,t.createElementVNode)(`div`,M,[(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,style:(0,t.normalizeStyle)((0,t.unref)(r))},(0,t.toDisplayString)((0,t.unref)(m)?String((0,t.unref)(m)):``),5),(0,t.unref)(m)?((0,t.openBlock)(),(0,t.createElementBlock)(`output`,{key:0,name:`output`,"aria-live":`off`,for:(0,t.unref)(f),class:(0,t.normalizeClass)([`d-flex align-items-center justify-content-between gap-3 mb-4 p-3 fs-4 rounded border`,s.value])},[(0,t.createElementVNode)(`span`,P,(0,t.toDisplayString)((0,t.unref)(m)),1),(0,t.unref)(y).isSupported?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,type:`button`,title:(0,t.unref)(g).copy,"aria-label":(0,t.unref)(g).copy,class:`btn btn-link link-body-emphasis text-decoration-none p-2 d-inline-flex align-items-center flex-shrink-0 position-relative`,onClick:i[0]||=e=>(0,t.unref)(y).copy()},[(0,t.createVNode)((0,t.unref)(d),{class:`flex-shrink-0`,style:{width:`1.5rem`,height:`1.5rem`},"aria-hidden":`true`}),(0,t.unref)(y).copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,I,(0,t.toDisplayString)((0,t.unref)(g).copied),1)):(0,t.createCommentVNode)(``,!0)],8,F)):(0,t.createCommentVNode)(``,!0)],10,N)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,class:(0,t.normalizeClass)((0,t.unref)(y).error?`d-block mt-2 invalid-feedback`:`visually-hidden`)},(0,t.toDisplayString)((0,t.unref)(y).error||((0,t.unref)(y).copied?(0,t.unref)(g).copied:``)),3),(0,t.createElementVNode)(`label`,{for:(0,t.unref)(f),class:`form-label visually-hidden`},(0,t.toDisplayString)((0,t.unref)(g).notation),9,L),(0,t.createElementVNode)(`div`,R,[(0,t.createElementVNode)(`input`,(0,t.mergeProps)({...e.inputAttrs,...(0,t.unref)(_)},{"aria-invalid":(0,t.unref)(p)?`true`:void 0,"aria-describedby":[e.inputAttrs[`aria-describedby`],(0,t.unref)(p)?`${(0,t.unref)(f)}-error`:null].filter(Boolean).join(` `)||void 0,type:`text`,name:`notation`,id:(0,t.unref)(f),placeholder:`e.g. ${e.notation||`4d6`}`,class:[`form-control`,(0,t.unref)(p)?`is-invalid`:``]},(0,t.toHandlers)((0,t.unref)(v),!0)),null,16,z),(0,t.createElementVNode)(`button`,{type:`button`,class:(0,t.normalizeClass)([`btn`,c.value]),disabled:!(0,t.unref)(_).value||e.inputAttrs.disabled,onClick:i[1]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e)},[(0,t.renderSlot)(n.$slots,`button`,{},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e.btnLabel),1)])],10,B)]),(0,t.unref)(p)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,id:`${(0,t.unref)(f)}-error`,role:`alert`,class:`d-block mt-3 invalid-feedback`},(0,t.toDisplayString)((0,t.unref)(p)),9,V)):(0,t.createCommentVNode)(``,!0)])],16,j))}}),J=(0,t.defineComponent)({__name:`DiceRollerRenderless`,props:{notation:String,labels:{type:Object,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let r=n,i=e,{currentNotation:a,error:o,output:s,roll:c,labels:u,bind:d,on:f,copy:p}=l({notation:()=>i.notation,labels:()=>i.labels,onNotationChange:e=>{r(`update:notation`,e),r(`notation:change`,e)},onRoll:(e,t)=>r(`roll`,e,t)});return(e,n)=>(0,t.renderSlot)(e.$slots,`default`,{currentNotation:(0,t.unref)(a),error:(0,t.unref)(o),output:(0,t.unref)(s),roll:(0,t.unref)(c),labels:(0,t.unref)(u),bind:(0,t.unref)(d),on:(0,t.unref)(f),copy:(0,t.unref)(p)})}});e.DiceRoller=y,e.DiceRollerBootstrap=q,e.DiceRollerRenderless=J,e.DiceRollerTailwind=A,e.useDiceRoller=l});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("@dice-roller/rpg-dice-roller")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@dice-roller/rpg-dice-roller`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.DiceRollerVue={},e.Vue,e.rpgDiceRoller))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r={position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,border:0};function i(e,n){return(0,t.getCurrentScope)()?((0,t.onScopeDispose)(e,n),!0):!1}var a=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;function o(e,n,r={}){let{immediate:o=!0,immediateCallback:s=!1}=r,c=(0,t.shallowRef)(!1),l;function u(){l&&=(clearTimeout(l),void 0)}function d(){c.value=!1,u()}function f(...r){s&&e(),u(),c.value=!0,l=setTimeout(()=>{c.value=!1,l=void 0,e(...r)},(0,t.toValue)(n))}return o&&(c.value=!0,a&&f()),i(d),{isPending:(0,t.shallowReadonly)(c),start:f,stop:d}}a&&window.document,a&&window.navigator,a&&window.location;function s(){let e=(0,t.shallowRef)(!1),n=(0,t.getCurrentInstance)();return n&&(0,t.onMounted)(()=>{e.value=!0},n),e}function c(e){let n=s();return(0,t.computed)(()=>(n.value,!!e()))}function l(e={}){let r=(0,t.computed)(()=>({notation:`Notation`,copy:`Copy to clipboard`,copied:`Copied!`,copyError:`Unable to copy to clipboard. Please try again.`,invalidNotation:`Invalid notation`,error:`An error has occurred`,...(0,t.toValue)(e.labels)})),i=(0,t.ref)((0,t.toValue)(e.notation)??``),a=(0,t.ref)(null),s=(0,t.shallowRef)(null),l=(0,t.ref)(null);(0,t.watch)(()=>(0,t.toValue)(e.notation),e=>{i.value=e??``});let u=()=>{a.value=null,l.value=null;try{s.value=i.value?new n.Roll(i.value):null}catch(e){let t=e;s.value=null,a.value=`${e instanceof n.errors.NotationError?r.value.invalidNotation:r.value.error}: ${t.message}`}finally{e.onRoll?.(i.value,s.value)}},d=t=>{i.value!==t&&(i.value=t,e.onNotationChange?.(t))},f=(0,t.computed)({get:()=>i.value,set:d}),p=e=>{e.key!==`Enter`||e.isComposing||e.keyCode===229||(e.preventDefault(),!e.repeat&&!e.target?.disabled&&i.value&&u())},m=(0,t.computed)(()=>s.value?String(s.value):``),h=(0,t.ref)(``),g=(0,t.ref)(!1),_=c(()=>typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`),{start:v,stop:y}=o(()=>{g.value=!1},1500,{immediate:!1});return{currentNotation:f,error:a,output:s,roll:u,labels:r,setNotation:d,bind:(0,t.computed)(()=>({value:f.value})),on:{input:e=>d(e.target.value),change:e=>d(e.target.value),keydown:p},copy:(0,t.reactive)({copy:async()=>{if(l.value=null,g.value=!1,y(),!s.value)return;let e=m.value;try{await navigator.clipboard.writeText(e),h.value=e,g.value=!0,v()}catch{l.value=r.value.copyError}},copied:g,text:h,isSupported:_,error:l})}}function u(e=``){return{id:(0,t.ref)(`${e}${(0,t.useId)()}`)}}function d(e,n){return(0,t.openBlock)(),(0,t.createElementBlock)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,"stroke-width":`1.5`,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`},[(0,t.createElementVNode)(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184`})])}var f=[`id`],p=[`for`],m=[`title`,`aria-label`],h=[`for`],g=[`aria-invalid`,`aria-describedby`,`id`,`placeholder`],_=[`disabled`],v=[`id`],y=(0,t.defineComponent)({inheritAttrs:!1,__name:`DiceRoller`,props:{btnLabel:{type:String,default:`Roll`},className:{type:String,default:`dice-roller`},id:String,notation:String,labels:Object,inputAttrs:{type:Object,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let i=n,a=e,{id:o}=u(`${a.id||`dice-roller`}-`),{error:s,output:c,roll:y,labels:b,bind:x,on:S,copy:C}=l({notation:()=>a.notation,labels:()=>a.labels,onNotationChange:e=>{i(`update:notation`,e),i(`notation:change`,e)},onRoll:(e,t)=>i(`roll`,e,t)});return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`section`,(0,t.mergeProps)(n.$attrs,{id:e.id,class:e.className}),[(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,style:(0,t.normalizeStyle)((0,t.unref)(r))},(0,t.toDisplayString)((0,t.unref)(c)?String((0,t.unref)(c)):``),5),(0,t.unref)(c)?((0,t.openBlock)(),(0,t.createElementBlock)(`output`,{key:0,name:`output`,"aria-live":`off`,for:(0,t.unref)(o),class:(0,t.normalizeClass)(`${e.className}-output`)},[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(c))+` `,1),(0,t.unref)(C).isSupported?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,type:`button`,title:(0,t.unref)(b).copy,"aria-label":(0,t.unref)(b).copy,class:(0,t.normalizeClass)(`${e.className}-copy-button`),onClick:i[0]||=e=>(0,t.unref)(C).copy()},[(0,t.createVNode)((0,t.unref)(d),{class:(0,t.normalizeClass)(`${e.className}-copy-icon`)},null,8,[`class`]),(0,t.unref)(C).copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,class:(0,t.normalizeClass)(`${e.className}-copy-label-success`)},(0,t.toDisplayString)((0,t.unref)(b).copied),3)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,class:(0,t.normalizeClass)(`${e.className}-copy-label`)},(0,t.toDisplayString)((0,t.unref)(b).copy),3))],10,m)):(0,t.createCommentVNode)(``,!0)],10,p)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,style:(0,t.normalizeStyle)((0,t.unref)(C).error?void 0:(0,t.unref)(r)),class:(0,t.normalizeClass)(`${e.className}-copy-status`)},(0,t.toDisplayString)((0,t.unref)(C).error||((0,t.unref)(C).copied?(0,t.unref)(b).copied:``)),7),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)(`${e.className}-input-group`)},[(0,t.createElementVNode)(`label`,{for:(0,t.unref)(o),class:(0,t.normalizeClass)(`${e.className}-label`)},(0,t.toDisplayString)((0,t.unref)(b).notation),11,h),(0,t.createElementVNode)(`input`,(0,t.mergeProps)({...e.inputAttrs,...(0,t.unref)(x)},{"aria-invalid":(0,t.unref)(s)?`true`:void 0,"aria-describedby":[e.inputAttrs[`aria-describedby`],(0,t.unref)(s)?`${(0,t.unref)(o)}-error`:null].filter(Boolean).join(` `)||void 0,type:`text`,name:`notation`,id:(0,t.unref)(o),placeholder:`e.g. ${e.notation||`4d6`}`,class:[`${e.className}-input`,(0,t.unref)(s)?`${e.className}-input-invalid`:null]},(0,t.toHandlers)((0,t.unref)(S),!0)),null,16,g),(0,t.createElementVNode)(`button`,{type:`button`,class:(0,t.normalizeClass)(`${e.className}-button`),disabled:!(0,t.unref)(x).value||e.inputAttrs.disabled,onClick:i[1]||=(...e)=>(0,t.unref)(y)&&(0,t.unref)(y)(...e)},[(0,t.renderSlot)(n.$slots,`button`,{},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e.btnLabel),1)])],10,_)],2),(0,t.unref)(s)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,id:`${(0,t.unref)(o)}-error`,role:`alert`,class:(0,t.normalizeClass)(`${e.className}-error`)},(0,t.toDisplayString)((0,t.unref)(s)),11,v)):(0,t.createCommentVNode)(``,!0)],16,f))}}),b=[`id`],x=[`for`],S=[`title`,`aria-label`],C={key:0,class:`pointer-events-none absolute right-full top-1/2 z-10 mr-2 -translate-y-1/2 whitespace-nowrap rounded bg-[color:var(--dice-roller-copy-surface,#111827)] px-2 py-1 text-sm font-medium text-[color:var(--dice-roller-copy-text,#fff)] shadow-md`},w={key:1,class:`sr-only`},T={class:`flex flex-col sm:flex-row gap-y-4`},E=[`for`],D=[`aria-invalid`,`aria-describedby`,`id`,`placeholder`],O=[`disabled`],k=[`id`],A=(0,t.defineComponent)({inheritAttrs:!1,__name:`DiceRollerTailwind`,props:{btnLabel:{type:String,default:`Roll`},id:String,notation:String,labels:Object,inputAttrs:{type:Object,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let i=n,a=e,{id:o}=u(`${a.id||`dice-roller`}-`),{error:s,output:c,roll:f,labels:p,bind:m,on:h,copy:g}=l({notation:()=>a.notation,labels:()=>a.labels,onNotationChange:e=>{i(`update:notation`,e),i(`notation:change`,e)},onRoll:(e,t)=>i(`roll`,e,t)});return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,(0,t.mergeProps)(n.$attrs,{id:e.id,class:`dice-roller p-4 rounded bg-[color:var(--dice-roller-surface,#f1f5f9)] dark:bg-[color:var(--dice-roller-surface-dark,var(--dice-roller-surface,#4b5563))] text-[color:var(--dice-roller-text,#1f2937)] dark:text-[color:var(--dice-roller-text-dark,var(--dice-roller-text,#e5e7eb))]`}),[(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,style:(0,t.normalizeStyle)((0,t.unref)(r))},(0,t.toDisplayString)((0,t.unref)(c)?String((0,t.unref)(c)):``),5),(0,t.unref)(c)?((0,t.openBlock)(),(0,t.createElementBlock)(`output`,{key:0,name:`output`,"aria-live":`off`,for:(0,t.unref)(o),class:`flex flex-row flex-nowrap justify-between mb-4 p-4 text-2xl rounded bg-[color:var(--dice-roller-output-surface,#fff)] dark:bg-[color:var(--dice-roller-output-surface-dark,var(--dice-roller-output-surface,#1e293b))] text-[color:var(--dice-roller-output-text,#000)] dark:text-[color:var(--dice-roller-output-text-dark,var(--dice-roller-output-text,#e2e8f0))] border-l-8 border-[color:var(--dice-roller-output-accent,var(--dice-roller-primary,#d4f4c6))] dark:border-[color:var(--dice-roller-output-accent-dark,var(--dice-roller-output-accent,var(--dice-roller-primary,#6b8f63)))]`},[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(c))+` `,1),(0,t.unref)(g).isSupported?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,type:`button`,title:(0,t.unref)(p).copy,"aria-label":(0,t.unref)(p).copy,class:`relative inline-flex shrink-0 items-center group/copy focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))]`,onClick:i[0]||=e=>(0,t.unref)(g).copy()},[(0,t.createVNode)((0,t.unref)(d),{class:`w-6 h-6 opacity-50 group-hover/copy:opacity-100`}),(0,t.unref)(g).copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,C,(0,t.toDisplayString)((0,t.unref)(p).copied),1)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,w,(0,t.toDisplayString)((0,t.unref)(p).copy),1))],8,S)):(0,t.createCommentVNode)(``,!0)],8,x)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,class:(0,t.normalizeClass)((0,t.unref)(g).error?`block mt-2 text-[color:var(--dice-roller-error,#b91c1c)] dark:text-[color:var(--dice-roller-error-dark,var(--dice-roller-error,#fecaca))]`:`sr-only`)},(0,t.toDisplayString)((0,t.unref)(g).error||((0,t.unref)(g).copied?(0,t.unref)(p).copied:``)),3),(0,t.createElementVNode)(`div`,T,[(0,t.createElementVNode)(`label`,{for:(0,t.unref)(o),class:`sr-only`},(0,t.toDisplayString)((0,t.unref)(p).notation),9,E),(0,t.createElementVNode)(`input`,(0,t.mergeProps)({...e.inputAttrs,...(0,t.unref)(m)},{"aria-invalid":(0,t.unref)(s)?`true`:void 0,"aria-describedby":[e.inputAttrs[`aria-describedby`],(0,t.unref)(s)?`${(0,t.unref)(o)}-error`:null].filter(Boolean).join(` `)||void 0,type:`text`,name:`notation`,id:(0,t.unref)(o),placeholder:`e.g. ${e.notation||`4d6`}`,class:[`min-w-0 flex-1 block w-full h-11 py-2 px-4 text-base border shadow-sm rounded placeholder-[color:var(--dice-roller-input-placeholder,#6b7280)] dark:placeholder-[color:var(--dice-roller-input-placeholder-dark,var(--dice-roller-input-placeholder,#94a3b8))] focus:ring-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus:border-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))] focus:placeholder-[color:var(--dice-roller-input-placeholder-focus,#9ca3af)] dark:focus:placeholder-[color:var(--dice-roller-input-placeholder-focus-dark,var(--dice-roller-input-placeholder-focus,#94a3b8))] invalid:text-[color:var(--dice-roller-input-error-text,var(--dice-roller-error,#b91c1c))] invalid:border-[color:var(--dice-roller-input-error-border,#fecaca)] invalid:bg-[color:var(--dice-roller-input-error-surface,#fef2f2)] sm:border-r-0 sm:rounded-r-none`,(0,t.unref)(s)?`text-[color:var(--dice-roller-input-error-text,var(--dice-roller-error,#b91c1c))] border-[color:var(--dice-roller-input-error-border,#fecaca)] bg-[color:var(--dice-roller-input-error-surface,#fef2f2)]`:`bg-[color:var(--dice-roller-input-surface,#fff)] dark:bg-[color:var(--dice-roller-input-surface-dark,var(--dice-roller-input-surface,#0f172a))] text-[color:var(--dice-roller-input-text,#111827)] dark:text-[color:var(--dice-roller-input-text-dark,var(--dice-roller-input-text,#e2e8f0))] border-[color:var(--dice-roller-border,#d1d5db)] dark:border-[color:var(--dice-roller-border-dark,var(--dice-roller-border,#374151))]`]},(0,t.toHandlers)((0,t.unref)(h),!0)),null,16,D),(0,t.createElementVNode)(`button`,{type:`button`,class:`inline-flex shrink-0 items-center justify-center whitespace-nowrap px-8 h-11 font-bold text-[color:var(--dice-roller-on-primary,#111827)] bg-gradient-to-br from-[color:var(--dice-roller-button-from,var(--dice-roller-primary,#eda18b))] to-[color:var(--dice-roller-button-to,var(--dice-roller-primary,#d4f4c6))] border sm:border-l-0 border-[color:var(--dice-roller-border,#d1d5db)] rounded transition dark:border-[color:var(--dice-roller-border-dark,var(--dice-roller-border,#374151))] focus:from-[color:var(--dice-roller-button-hover-from,var(--dice-roller-primary-hover,var(--dice-roller-primary,#e88c71)))] focus:to-[color:var(--dice-roller-button-hover-to,var(--dice-roller-primary-hover,var(--dice-roller-primary,#bbf0a3)))] focus:text-[color:var(--dice-roller-on-primary,#1f2937)] focus:ring-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus:border-[color:var(--dice-roller-focus,var(--dice-roller-primary,#d4f4c6))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--dice-roller-focus-outline,#1f2937)] dark:focus-visible:outline-[color:var(--dice-roller-focus-outline-dark,var(--dice-roller-focus-outline,#fff))] hover:from-[color:var(--dice-roller-button-hover-from,var(--dice-roller-primary-hover,var(--dice-roller-primary,#e88c71)))] hover:to-[color:var(--dice-roller-button-hover-to,var(--dice-roller-primary-hover,var(--dice-roller-primary,#bbf0a3)))] hover:text-[color:var(--dice-roller-on-primary,#1f2937)] sm:rounded-l-none`,disabled:!(0,t.unref)(m).value||e.inputAttrs.disabled,onClick:i[1]||=(...e)=>(0,t.unref)(f)&&(0,t.unref)(f)(...e)},[(0,t.renderSlot)(n.$slots,`button`,{},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e.btnLabel),1)])],8,O)]),(0,t.unref)(s)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,id:`${(0,t.unref)(o)}-error`,role:`alert`,class:`block mt-4 text-sm text-[color:var(--dice-roller-error,#b91c1c)] dark:text-[color:var(--dice-roller-error-dark,var(--dice-roller-error,#fecaca))]`},(0,t.toDisplayString)((0,t.unref)(s)),9,k)):(0,t.createCommentVNode)(``,!0)],16,b))}}),j=[`id`],M={class:`card-body`},N=[`for`],P={class:`flex-grow-1 text-break`},F=[`title`,`aria-label`],I={key:0,"aria-hidden":`true`,class:`position-absolute top-50 end-100 translate-middle-y me-2 badge text-bg-dark fs-6 fw-normal text-nowrap shadow pe-none`},L=[`for`],R={class:`input-group`},z=[`aria-invalid`,`aria-describedby`,`id`,`placeholder`],B=[`disabled`],V=[`id`],H=[`primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark`],U=[...H,`body`,`white`,`transparent`],W=[...H,`body`,`muted`,`white`,`black-50`,`white-50`],G=[...H,`link`,`outline-primary`,`outline-secondary`,`outline-success`,`outline-danger`,`outline-warning`,`outline-info`,`outline-light`,`outline-dark`],K=[...H,`white`],q=(0,t.defineComponent)({inheritAttrs:!1,__name:`DiceRollerBootstrap`,props:{bgVariant:{type:String,validator(e){return U.includes(e)}},borderVariant:{type:String,validator(e){return K.includes(e)}},btnLabel:{type:String,default:`Roll`},btnVariant:{type:String,default:`primary`,validator(e){return G.includes(e)}},id:String,notation:String,labels:Object,inputAttrs:{type:Object,default:()=>({})},outputBgVariant:{type:String,validator(e){return U.includes(e)}},outputBorderVariant:{type:String,validator(e){return K.includes(e)}},outputTextVariant:{type:String,validator(e){return W.includes(e)}},outputVariant:{type:String,validator(e){return H.includes(e)}},textVariant:{type:String,validator(e){return W.includes(e)}},variant:{type:String,validator(e){return H.includes(e)}}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let i=n,a=e,o=(0,t.computed)(()=>({[`text-bg-${a.variant}`]:a.variant,[`bg-${a.bgVariant}`]:a.bgVariant,[`text-${a.textVariant}`]:a.textVariant,[`border-${a.borderVariant}`]:a.borderVariant})),s=(0,t.computed)(()=>({[`text-bg-${a.outputVariant}`]:a.outputVariant,[`bg-${a.outputBgVariant}`]:a.outputBgVariant,[`text-${a.outputTextVariant}`]:a.outputTextVariant,[`border-${a.outputBorderVariant}`]:a.outputBorderVariant})),c=(0,t.computed)(()=>`btn-${a.btnVariant||`primary`}`),{id:f}=u(`${a.id||`dice-roller`}-`),{error:p,output:m,roll:h,labels:g,bind:_,on:v,copy:y}=l({notation:()=>a.notation,labels:()=>a.labels,onNotationChange:e=>{i(`update:notation`,e),i(`notation:change`,e)},onRoll:(e,t)=>i(`roll`,e,t)});return(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,(0,t.mergeProps)(n.$attrs,{id:e.id,class:[`dice-roller card`,o.value]}),[(0,t.createElementVNode)(`div`,M,[(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,style:(0,t.normalizeStyle)((0,t.unref)(r))},(0,t.toDisplayString)((0,t.unref)(m)?String((0,t.unref)(m)):``),5),(0,t.unref)(m)?((0,t.openBlock)(),(0,t.createElementBlock)(`output`,{key:0,name:`output`,"aria-live":`off`,for:(0,t.unref)(f),class:(0,t.normalizeClass)([`d-flex align-items-center justify-content-between gap-3 mb-4 p-3 fs-4 rounded border`,s.value])},[(0,t.createElementVNode)(`span`,P,(0,t.toDisplayString)((0,t.unref)(m)),1),(0,t.unref)(y).isSupported?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,type:`button`,title:(0,t.unref)(g).copy,"aria-label":(0,t.unref)(g).copy,class:`btn btn-link link-body-emphasis text-decoration-none p-2 d-inline-flex align-items-center flex-shrink-0 position-relative`,onClick:i[0]||=e=>(0,t.unref)(y).copy()},[(0,t.createVNode)((0,t.unref)(d),{class:`flex-shrink-0`,style:{width:`1.5rem`,height:`1.5rem`},"aria-hidden":`true`}),(0,t.unref)(y).copied?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,I,(0,t.toDisplayString)((0,t.unref)(g).copied),1)):(0,t.createCommentVNode)(``,!0)],8,F)):(0,t.createCommentVNode)(``,!0)],10,N)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`span`,{role:`status`,"aria-live":`polite`,class:(0,t.normalizeClass)((0,t.unref)(y).error?`d-block mt-2 invalid-feedback`:`visually-hidden`)},(0,t.toDisplayString)((0,t.unref)(y).error||((0,t.unref)(y).copied?(0,t.unref)(g).copied:``)),3),(0,t.createElementVNode)(`label`,{for:(0,t.unref)(f),class:`form-label visually-hidden`},(0,t.toDisplayString)((0,t.unref)(g).notation),9,L),(0,t.createElementVNode)(`div`,R,[(0,t.createElementVNode)(`input`,(0,t.mergeProps)({...e.inputAttrs,...(0,t.unref)(_)},{"aria-invalid":(0,t.unref)(p)?`true`:void 0,"aria-describedby":[e.inputAttrs[`aria-describedby`],(0,t.unref)(p)?`${(0,t.unref)(f)}-error`:null].filter(Boolean).join(` `)||void 0,type:`text`,name:`notation`,id:(0,t.unref)(f),placeholder:`e.g. ${e.notation||`4d6`}`,class:[`form-control`,(0,t.unref)(p)?`is-invalid`:``]},(0,t.toHandlers)((0,t.unref)(v),!0)),null,16,z),(0,t.createElementVNode)(`button`,{type:`button`,class:(0,t.normalizeClass)([`btn`,c.value]),disabled:!(0,t.unref)(_).value||e.inputAttrs.disabled,onClick:i[1]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e)},[(0,t.renderSlot)(n.$slots,`button`,{},()=>[(0,t.createTextVNode)((0,t.toDisplayString)(e.btnLabel),1)])],10,B)]),(0,t.unref)(p)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:1,id:`${(0,t.unref)(f)}-error`,role:`alert`,class:`d-block mt-3 invalid-feedback`},(0,t.toDisplayString)((0,t.unref)(p)),9,V)):(0,t.createCommentVNode)(``,!0)])],16,j))}}),J=(0,t.defineComponent)({__name:`DiceRollerRenderless`,props:{notation:String,labels:{type:Object,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let r=n,i=e,{currentNotation:a,error:o,output:s,roll:c,labels:u,bind:d,on:f,copy:p}=l({notation:()=>i.notation,labels:()=>i.labels,onNotationChange:e=>{r(`update:notation`,e),r(`notation:change`,e)},onRoll:(e,t)=>r(`roll`,e,t)});return(e,n)=>(0,t.renderSlot)(e.$slots,`default`,{currentNotation:(0,t.unref)(a),error:(0,t.unref)(o),output:(0,t.unref)(s),roll:(0,t.unref)(c),labels:(0,t.unref)(u),bind:(0,t.unref)(d),on:(0,t.unref)(f),copy:(0,t.unref)(p)})}});e.DiceRoller=y,e.DiceRollerBootstrap=q,e.DiceRollerRenderless=J,e.DiceRollerTailwind=A,e.useDiceRoller=l});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dice-roller/vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "Vue.js component which allows rolling dice",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@vueuse/core": "^15.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@dice-roller/rpg-dice-roller": "^
|
|
61
|
+
"@dice-roller/rpg-dice-roller": "^6.0.0-beta.1",
|
|
62
62
|
"@eslint/js": "^10.0.1",
|
|
63
63
|
"@playwright/test": "^1.65.0",
|
|
64
64
|
"@types/jsdom": "^30.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"vue-tsc": "^3.3.14"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@dice-roller/rpg-dice-roller": "^
|
|
87
|
+
"@dice-roller/rpg-dice-roller": "^6.0.0-beta.1",
|
|
88
88
|
"vue": "^3.5.45"
|
|
89
89
|
},
|
|
90
90
|
"overrides": {
|