@dice-roller/vue 2.0.0-beta.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/components/DiceRoller.vue.d.ts +12 -0
- package/dist/types/components/DiceRollerBootstrap.vue.d.ts +12 -0
- package/dist/types/components/DiceRollerRenderless.vue.d.ts +12 -0
- package/dist/types/components/DiceRollerTailwind.vue.d.ts +12 -0
- package/dist/types/composables/useDiceRoller.d.ts +1 -1
- package/dist/types/types.d.ts +4 -1
- package/dist/vue.js +58 -32
- package/dist/vue.umd.cjs +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import type { DiceRollerLabels, DiceRollerInputAttrs, DiceRollerSlots } from '../types.js';
|
|
3
|
+
import type { RollInputData } from '@dice-roller/rpg-dice-roller';
|
|
3
4
|
type __VLS_Slots = DiceRollerSlots;
|
|
4
5
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
6
|
btnLabel: {
|
|
@@ -17,6 +18,11 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
17
18
|
type: PropType<DiceRollerInputAttrs>;
|
|
18
19
|
default: () => {};
|
|
19
20
|
};
|
|
21
|
+
data: {
|
|
22
|
+
type: PropType<RollInputData>;
|
|
23
|
+
required: false;
|
|
24
|
+
default: () => {};
|
|
25
|
+
};
|
|
20
26
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
27
|
"notation:change": (notation: string) => any;
|
|
22
28
|
"update:notation": (notation: string) => any;
|
|
@@ -37,11 +43,17 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
37
43
|
type: PropType<DiceRollerInputAttrs>;
|
|
38
44
|
default: () => {};
|
|
39
45
|
};
|
|
46
|
+
data: {
|
|
47
|
+
type: PropType<RollInputData>;
|
|
48
|
+
required: false;
|
|
49
|
+
default: () => {};
|
|
50
|
+
};
|
|
40
51
|
}>> & Readonly<{
|
|
41
52
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
42
53
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
43
54
|
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
44
55
|
}>, {
|
|
56
|
+
data: RollInputData;
|
|
45
57
|
btnLabel: string;
|
|
46
58
|
className: string;
|
|
47
59
|
inputAttrs: DiceRollerInputAttrs;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import type { BootstrapVariant, BootstrapBackgroundVariant, BootstrapBorderVariant, BootstrapTextVariant, BootstrapButtonVariant } from '../types.js';
|
|
3
3
|
import type { DiceRollerLabels, DiceRollerInputAttrs, DiceRollerSlots } from '../types.js';
|
|
4
|
+
import type { RollInputData } from '@dice-roller/rpg-dice-roller';
|
|
4
5
|
declare const _default: typeof __VLS_export;
|
|
5
6
|
export default _default;
|
|
6
7
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
@@ -52,6 +53,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
|
|
|
52
53
|
type: PropType<BootstrapVariant>;
|
|
53
54
|
validator(value: string): boolean;
|
|
54
55
|
};
|
|
56
|
+
data: {
|
|
57
|
+
type: PropType<RollInputData>;
|
|
58
|
+
required: false;
|
|
59
|
+
default: () => {};
|
|
60
|
+
};
|
|
55
61
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
56
62
|
"notation:change": (notation: string) => any;
|
|
57
63
|
"update:notation": (notation: string) => any;
|
|
@@ -105,11 +111,17 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
|
|
|
105
111
|
type: PropType<BootstrapVariant>;
|
|
106
112
|
validator(value: string): boolean;
|
|
107
113
|
};
|
|
114
|
+
data: {
|
|
115
|
+
type: PropType<RollInputData>;
|
|
116
|
+
required: false;
|
|
117
|
+
default: () => {};
|
|
118
|
+
};
|
|
108
119
|
}>> & Readonly<{
|
|
109
120
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
110
121
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
111
122
|
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
112
123
|
}>, {
|
|
124
|
+
data: RollInputData;
|
|
113
125
|
btnLabel: string;
|
|
114
126
|
inputAttrs: DiceRollerInputAttrs;
|
|
115
127
|
btnVariant: BootstrapButtonVariant;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import type { DiceRollerLabels, DiceRollerSlotProps } from '../types.js';
|
|
3
|
+
import type { RollInputData } from '@dice-roller/rpg-dice-roller';
|
|
3
4
|
type __VLS_Slots = {
|
|
4
5
|
default?: (props: DiceRollerSlotProps) => import('vue').VNodeChild;
|
|
5
6
|
};
|
|
@@ -9,6 +10,11 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
9
10
|
type: PropType<Partial<DiceRollerLabels>>;
|
|
10
11
|
default: () => {};
|
|
11
12
|
};
|
|
13
|
+
data: {
|
|
14
|
+
type: PropType<RollInputData>;
|
|
15
|
+
required: false;
|
|
16
|
+
default: () => {};
|
|
17
|
+
};
|
|
12
18
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
19
|
"notation:change": (notation: string) => any;
|
|
14
20
|
"update:notation": (notation: string) => any;
|
|
@@ -19,11 +25,17 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
19
25
|
type: PropType<Partial<DiceRollerLabels>>;
|
|
20
26
|
default: () => {};
|
|
21
27
|
};
|
|
28
|
+
data: {
|
|
29
|
+
type: PropType<RollInputData>;
|
|
30
|
+
required: false;
|
|
31
|
+
default: () => {};
|
|
32
|
+
};
|
|
22
33
|
}>> & Readonly<{
|
|
23
34
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
24
35
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
25
36
|
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
26
37
|
}>, {
|
|
38
|
+
data: RollInputData;
|
|
27
39
|
labels: Partial<DiceRollerLabels>;
|
|
28
40
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
29
41
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import type { DiceRollerLabels, DiceRollerInputAttrs, DiceRollerSlots } from '../types.js';
|
|
3
|
+
import type { RollInputData } from '@dice-roller/rpg-dice-roller';
|
|
3
4
|
type __VLS_Slots = DiceRollerSlots;
|
|
4
5
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
6
|
btnLabel: {
|
|
@@ -13,6 +14,11 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
13
14
|
type: PropType<DiceRollerInputAttrs>;
|
|
14
15
|
default: () => {};
|
|
15
16
|
};
|
|
17
|
+
data: {
|
|
18
|
+
type: PropType<RollInputData>;
|
|
19
|
+
required: false;
|
|
20
|
+
default: () => {};
|
|
21
|
+
};
|
|
16
22
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
23
|
"notation:change": (notation: string) => any;
|
|
18
24
|
"update:notation": (notation: string) => any;
|
|
@@ -29,11 +35,17 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
29
35
|
type: PropType<DiceRollerInputAttrs>;
|
|
30
36
|
default: () => {};
|
|
31
37
|
};
|
|
38
|
+
data: {
|
|
39
|
+
type: PropType<RollInputData>;
|
|
40
|
+
required: false;
|
|
41
|
+
default: () => {};
|
|
42
|
+
};
|
|
32
43
|
}>> & Readonly<{
|
|
33
44
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
34
45
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
35
46
|
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any) | undefined;
|
|
36
47
|
}>, {
|
|
48
|
+
data: RollInputData;
|
|
37
49
|
btnLabel: string;
|
|
38
50
|
inputAttrs: DiceRollerInputAttrs;
|
|
39
51
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UseDiceRollerOptions, UseDiceRollerReturn } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Create an independent dice roller inside setup() or <script setup lang="ts">.
|
|
4
|
-
* notation and labels accept plain values, refs or getters.
|
|
4
|
+
* notation, data and labels accept plain values, refs or getters.
|
|
5
5
|
* Source updates are silent; local edits call onNotationChange once.
|
|
6
6
|
* onRoll receives (notation, result), including null for empty/failed rolls.
|
|
7
7
|
*/
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Roll } from '@dice-roller/rpg-dice-roller';
|
|
1
|
+
import type { Roll, RollInputData } from '@dice-roller/rpg-dice-roller';
|
|
2
2
|
import type { ComputedRef, InputHTMLAttributes, MaybeRefOrGetter, ShallowRef, VNodeChild, WritableComputedRef, Ref } from 'vue';
|
|
3
3
|
export interface DiceRollerLabels {
|
|
4
4
|
notation: string;
|
|
@@ -11,6 +11,7 @@ export interface DiceRollerLabels {
|
|
|
11
11
|
export type DiceRollerInputAttrs = Omit<InputHTMLAttributes, 'id' | 'value' | 'type' | 'name'> & Record<string, unknown>;
|
|
12
12
|
export interface UseDiceRollerOptions {
|
|
13
13
|
notation?: MaybeRefOrGetter<string | null | undefined>;
|
|
14
|
+
data?: MaybeRefOrGetter<RollInputData | undefined>;
|
|
14
15
|
labels?: MaybeRefOrGetter<Partial<DiceRollerLabels> | undefined>;
|
|
15
16
|
onNotationChange?: (notation: string) => void;
|
|
16
17
|
onRoll?: (notation: string, result: Roll | null) => void;
|
|
@@ -39,6 +40,7 @@ export interface UseDiceRollerReturn {
|
|
|
39
40
|
}>;
|
|
40
41
|
on: DiceRollerInputHandlers;
|
|
41
42
|
copy: DiceRollerClipboard;
|
|
43
|
+
data: ComputedRef<RollInputData | undefined>;
|
|
42
44
|
}
|
|
43
45
|
export type DiceRollerEmits = {
|
|
44
46
|
'notation:change': [notation: string];
|
|
@@ -59,6 +61,7 @@ export interface DiceRollerSlotProps {
|
|
|
59
61
|
};
|
|
60
62
|
on: DiceRollerInputHandlers;
|
|
61
63
|
copy: DiceRollerClipboard;
|
|
64
|
+
data: RollInputData | undefined;
|
|
62
65
|
}
|
|
63
66
|
export type BootstrapVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark';
|
|
64
67
|
export type BootstrapBackgroundVariant = BootstrapVariant | 'body' | 'white' | 'transparent';
|
package/dist/vue.js
CHANGED
|
@@ -59,58 +59,59 @@ function j(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 = y(null), o = g(null);
|
|
62
|
+
})), r = g(S(t.notation) ?? ""), i = g(null), a = y(null), o = g(null), s = e(() => S(t.data));
|
|
63
63
|
T(() => S(t.notation), (e) => {
|
|
64
64
|
r.value = e ?? "";
|
|
65
65
|
});
|
|
66
|
-
let
|
|
66
|
+
let c = () => {
|
|
67
67
|
i.value = null, o.value = null;
|
|
68
68
|
try {
|
|
69
|
-
a.value = r.value ? new E(r.value) : null;
|
|
69
|
+
a.value = r.value ? new E(r.value, { data: s.value }) : null;
|
|
70
70
|
} catch (e) {
|
|
71
71
|
let t = e;
|
|
72
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
|
}
|
|
76
|
-
},
|
|
76
|
+
}, l = (e) => {
|
|
77
77
|
r.value !== e && (r.value = e, t.onNotationChange?.(e));
|
|
78
|
-
},
|
|
78
|
+
}, u = e({
|
|
79
79
|
get: () => r.value,
|
|
80
|
-
set:
|
|
81
|
-
}),
|
|
82
|
-
e.key !== "Enter" || e.isComposing || e.keyCode === 229 || (e.preventDefault(), !e.repeat && !e.target?.disabled && r.value &&
|
|
83
|
-
},
|
|
84
|
-
|
|
80
|
+
set: l
|
|
81
|
+
}), d = (e) => {
|
|
82
|
+
e.key !== "Enter" || e.isComposing || e.keyCode === 229 || (e.preventDefault(), !e.repeat && !e.target?.disabled && r.value && c());
|
|
83
|
+
}, f = e(() => a.value ? String(a.value) : ""), p = g(""), m = g(!1), _ = /* @__PURE__ */ ne(() => typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function"), { start: v, stop: b } = ee(() => {
|
|
84
|
+
m.value = !1;
|
|
85
85
|
}, 1500, { immediate: !1 });
|
|
86
86
|
return {
|
|
87
|
-
currentNotation:
|
|
87
|
+
currentNotation: u,
|
|
88
88
|
error: i,
|
|
89
89
|
output: a,
|
|
90
|
-
roll:
|
|
90
|
+
roll: c,
|
|
91
91
|
labels: n,
|
|
92
|
-
setNotation:
|
|
93
|
-
bind: e(() => ({ value:
|
|
92
|
+
setNotation: l,
|
|
93
|
+
bind: e(() => ({ value: u.value })),
|
|
94
94
|
on: {
|
|
95
|
-
input: (e) =>
|
|
96
|
-
change: (e) =>
|
|
97
|
-
keydown:
|
|
95
|
+
input: (e) => l(e.target.value),
|
|
96
|
+
change: (e) => l(e.target.value),
|
|
97
|
+
keydown: d
|
|
98
98
|
},
|
|
99
99
|
copy: h({
|
|
100
100
|
copy: async () => {
|
|
101
|
-
if (o.value = null,
|
|
102
|
-
let e =
|
|
101
|
+
if (o.value = null, m.value = !1, b(), !a.value) return;
|
|
102
|
+
let e = f.value;
|
|
103
103
|
try {
|
|
104
|
-
await navigator.clipboard.writeText(e),
|
|
104
|
+
await navigator.clipboard.writeText(e), p.value = e, m.value = !0, v();
|
|
105
105
|
} catch {
|
|
106
106
|
o.value = n.value.copyError;
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
-
copied:
|
|
110
|
-
text:
|
|
111
|
-
isSupported:
|
|
109
|
+
copied: m,
|
|
110
|
+
text: p,
|
|
111
|
+
isSupported: _,
|
|
112
112
|
error: o
|
|
113
|
-
})
|
|
113
|
+
}),
|
|
114
|
+
data: s
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
// src/composables/idGenerator.ts
|
|
@@ -157,6 +158,11 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
157
158
|
inputAttrs: {
|
|
158
159
|
type: Object,
|
|
159
160
|
default: () => ({})
|
|
161
|
+
},
|
|
162
|
+
data: {
|
|
163
|
+
type: Object,
|
|
164
|
+
required: !1,
|
|
165
|
+
default: () => ({})
|
|
160
166
|
}
|
|
161
167
|
},
|
|
162
168
|
emits: [
|
|
@@ -168,6 +174,7 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
168
174
|
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
175
|
notation: () => c.notation,
|
|
170
176
|
labels: () => c.labels,
|
|
177
|
+
data: () => c.data,
|
|
171
178
|
onNotationChange: (e) => {
|
|
172
179
|
s("update:notation", e), s("notation:change", e);
|
|
173
180
|
},
|
|
@@ -266,6 +273,11 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
266
273
|
inputAttrs: {
|
|
267
274
|
type: Object,
|
|
268
275
|
default: () => ({})
|
|
276
|
+
},
|
|
277
|
+
data: {
|
|
278
|
+
type: Object,
|
|
279
|
+
required: !1,
|
|
280
|
+
default: () => ({})
|
|
269
281
|
}
|
|
270
282
|
},
|
|
271
283
|
emits: [
|
|
@@ -277,6 +289,7 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
277
289
|
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
290
|
notation: () => c.notation,
|
|
279
291
|
labels: () => c.labels,
|
|
292
|
+
data: () => c.data,
|
|
280
293
|
onNotationChange: (e) => {
|
|
281
294
|
s("update:notation", e), s("notation:change", e);
|
|
282
295
|
},
|
|
@@ -453,6 +466,11 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
453
466
|
validator(e) {
|
|
454
467
|
return Y.includes(e);
|
|
455
468
|
}
|
|
469
|
+
},
|
|
470
|
+
data: {
|
|
471
|
+
type: Object,
|
|
472
|
+
required: !1,
|
|
473
|
+
default: () => ({})
|
|
456
474
|
}
|
|
457
475
|
},
|
|
458
476
|
emits: [
|
|
@@ -474,6 +492,7 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
474
492
|
})), 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
493
|
notation: () => f.notation,
|
|
476
494
|
labels: () => f.labels,
|
|
495
|
+
data: () => f.data,
|
|
477
496
|
onNotationChange: (e) => {
|
|
478
497
|
c("update:notation", e), c("notation:change", e);
|
|
479
498
|
},
|
|
@@ -551,6 +570,11 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
551
570
|
labels: {
|
|
552
571
|
type: Object,
|
|
553
572
|
default: () => ({})
|
|
573
|
+
},
|
|
574
|
+
data: {
|
|
575
|
+
type: Object,
|
|
576
|
+
required: !1,
|
|
577
|
+
default: () => ({})
|
|
554
578
|
}
|
|
555
579
|
},
|
|
556
580
|
emits: [
|
|
@@ -559,9 +583,10 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
559
583
|
"roll"
|
|
560
584
|
],
|
|
561
585
|
setup(e, { emit: t }) {
|
|
562
|
-
let n = t, r = e, { currentNotation: i,
|
|
586
|
+
let n = t, r = e, { currentNotation: i, data: a, error: o, output: s, roll: c, labels: l, bind: u, on: d, copy: f } = j({
|
|
563
587
|
notation: () => r.notation,
|
|
564
588
|
labels: () => r.labels,
|
|
589
|
+
data: () => r.data,
|
|
565
590
|
onNotationChange: (e) => {
|
|
566
591
|
n("update:notation", e), n("notation:change", e);
|
|
567
592
|
},
|
|
@@ -569,13 +594,14 @@ var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
|
569
594
|
});
|
|
570
595
|
return (e, t) => _(e.$slots, "default", {
|
|
571
596
|
currentNotation: C(i),
|
|
572
|
-
error: C(
|
|
573
|
-
output: C(
|
|
574
|
-
roll: C(
|
|
575
|
-
labels: C(
|
|
576
|
-
bind: C(
|
|
577
|
-
on: C(
|
|
578
|
-
copy: C(
|
|
597
|
+
error: C(o),
|
|
598
|
+
output: C(s),
|
|
599
|
+
roll: C(c),
|
|
600
|
+
labels: C(l),
|
|
601
|
+
bind: C(u),
|
|
602
|
+
on: C(d),
|
|
603
|
+
copy: C(f),
|
|
604
|
+
data: C(a)
|
|
579
605
|
});
|
|
580
606
|
}
|
|
581
607
|
});
|
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.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});
|
|
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),u=(0,t.computed)(()=>(0,t.toValue)(e.data));(0,t.watch)(()=>(0,t.toValue)(e.notation),e=>{i.value=e??``});let d=()=>{a.value=null,l.value=null;try{s.value=i.value?new n.Roll(i.value,{data:u.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)}},f=t=>{i.value!==t&&(i.value=t,e.onNotationChange?.(t))},p=(0,t.computed)({get:()=>i.value,set:f}),m=e=>{e.key!==`Enter`||e.isComposing||e.keyCode===229||(e.preventDefault(),!e.repeat&&!e.target?.disabled&&i.value&&d())},h=(0,t.computed)(()=>s.value?String(s.value):``),g=(0,t.ref)(``),_=(0,t.ref)(!1),v=c(()=>typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`),{start:y,stop:b}=o(()=>{_.value=!1},1500,{immediate:!1});return{currentNotation:p,error:a,output:s,roll:d,labels:r,setNotation:f,bind:(0,t.computed)(()=>({value:p.value})),on:{input:e=>f(e.target.value),change:e=>f(e.target.value),keydown:m},copy:(0,t.reactive)({copy:async()=>{if(l.value=null,_.value=!1,b(),!s.value)return;let e=h.value;try{await navigator.clipboard.writeText(e),g.value=e,_.value=!0,y()}catch{l.value=r.value.copyError}},copied:_,text:g,isSupported:v,error:l}),data:u}}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:()=>({})},data:{type:Object,required:!1,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,data:()=>a.data,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:()=>({})},data:{type:Object,required:!1,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,data:()=>a.data,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)}},data:{type:Object,required:!1,default:()=>({})}},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,data:()=>a.data,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:()=>({})},data:{type:Object,required:!1,default:()=>({})}},emits:[`notation:change`,`update:notation`,`roll`],setup(e,{emit:n}){let r=n,i=e,{currentNotation:a,data:o,error:s,output:c,roll:u,labels:d,bind:f,on:p,copy:m}=l({notation:()=>i.notation,labels:()=>i.labels,data:()=>i.data,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)(s),output:(0,t.unref)(c),roll:(0,t.unref)(u),labels:(0,t.unref)(d),bind:(0,t.unref)(f),on:(0,t.unref)(p),copy:(0,t.unref)(m),data:(0,t.unref)(o)})}});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": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
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": "^6.0.0-beta.
|
|
61
|
+
"@dice-roller/rpg-dice-roller": "^6.0.0-beta.7",
|
|
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": "^6.0.0-beta.
|
|
87
|
+
"@dice-roller/rpg-dice-roller": "^6.0.0-beta.7",
|
|
88
88
|
"vue": "^3.5.45"
|
|
89
89
|
},
|
|
90
90
|
"overrides": {
|