@dice-roller/vue 1.4.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/README.md +18 -18
- package/dist/types/components/DiceRoller.vue.d.ts +14 -2
- package/dist/types/components/DiceRollerBootstrap.vue.d.ts +14 -2
- package/dist/types/components/DiceRollerRenderless.vue.d.ts +14 -2
- package/dist/types/components/DiceRollerTailwind.vue.d.ts +14 -2
- package/dist/types/composables/useDiceRoller.d.ts +1 -1
- package/dist/types/types.d.ts +9 -6
- package/dist/vue.js +128 -102
- 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`. |
|
|
@@ -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,10 +18,15 @@ 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
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
22
27
|
"notation:change": (notation: string) => any;
|
|
23
28
|
"update:notation": (notation: string) => any;
|
|
29
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
24
30
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
25
31
|
btnLabel: {
|
|
26
32
|
type: StringConstructor;
|
|
@@ -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
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
42
52
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
43
53
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
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,10 +53,15 @@ 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
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
57
62
|
"notation:change": (notation: string) => any;
|
|
58
63
|
"update:notation": (notation: string) => any;
|
|
64
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
59
65
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
60
66
|
bgVariant: {
|
|
61
67
|
type: PropType<BootstrapBackgroundVariant>;
|
|
@@ -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
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
110
120
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
111
121
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
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,21 +10,32 @@ 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
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
14
19
|
"notation:change": (notation: string) => any;
|
|
15
20
|
"update:notation": (notation: string) => any;
|
|
21
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
16
22
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
23
|
notation: StringConstructor;
|
|
18
24
|
labels: {
|
|
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
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
24
34
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
25
35
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
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,10 +14,15 @@ 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
|
-
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any;
|
|
18
23
|
"notation:change": (notation: string) => any;
|
|
19
24
|
"update:notation": (notation: string) => any;
|
|
25
|
+
roll: (notation: string, result: import("@dice-roller/rpg-dice-roller").Roll<string> | null) => any;
|
|
20
26
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
27
|
btnLabel: {
|
|
22
28
|
type: StringConstructor;
|
|
@@ -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
|
-
onRoll?: ((notation: string, result: import("@dice-roller/rpg-dice-roller").DiceRoll | null) => any) | undefined;
|
|
34
44
|
"onNotation:change"?: ((notation: string) => any) | undefined;
|
|
35
45
|
"onUpdate:notation"?: ((notation: string) => any) | undefined;
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ComputedRef, InputHTMLAttributes, MaybeRefOrGetter, VNodeChild, WritableComputedRef, Ref } from 'vue';
|
|
1
|
+
import type { Roll, RollInputData } 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;
|
|
@@ -11,9 +11,10 @@ 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
|
-
onRoll?: (notation: string, result:
|
|
17
|
+
onRoll?: (notation: string, result: Roll | null) => void;
|
|
17
18
|
}
|
|
18
19
|
export interface DiceRollerClipboard {
|
|
19
20
|
copy: () => Promise<void>;
|
|
@@ -30,7 +31,7 @@ export interface DiceRollerInputHandlers {
|
|
|
30
31
|
export interface UseDiceRollerReturn {
|
|
31
32
|
currentNotation: WritableComputedRef<string>;
|
|
32
33
|
error: Ref<string | null>;
|
|
33
|
-
output:
|
|
34
|
+
output: ShallowRef<Roll | null>;
|
|
34
35
|
roll: () => void;
|
|
35
36
|
labels: ComputedRef<DiceRollerLabels>;
|
|
36
37
|
setNotation: (notation: string) => void;
|
|
@@ -39,11 +40,12 @@ 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];
|
|
45
47
|
'update:notation': [notation: string];
|
|
46
|
-
roll: [notation: string, result:
|
|
48
|
+
roll: [notation: string, result: Roll | null];
|
|
47
49
|
};
|
|
48
50
|
export type DiceRollerSlots = {
|
|
49
51
|
button?: () => VNodeChild;
|
|
@@ -51,7 +53,7 @@ export type DiceRollerSlots = {
|
|
|
51
53
|
export interface DiceRollerSlotProps {
|
|
52
54
|
currentNotation: string;
|
|
53
55
|
error: string | null;
|
|
54
|
-
output:
|
|
56
|
+
output: Roll | null;
|
|
55
57
|
roll: () => void;
|
|
56
58
|
labels: DiceRollerLabels;
|
|
57
59
|
bind: {
|
|
@@ -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
|
@@ -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,66 +59,67 @@ 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), 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
|
-
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
|
}
|
|
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
|
|
117
|
-
function
|
|
118
|
+
function M(e = "") {
|
|
118
119
|
return { id: g(`${e}${w()}`) };
|
|
119
120
|
}
|
|
120
121
|
// node_modules/@heroicons/vue/24/outline/esm/ClipboardIcon.js
|
|
121
|
-
function
|
|
122
|
+
function N(e, t) {
|
|
122
123
|
return m(), n("svg", {
|
|
123
124
|
xmlns: "http://www.w3.org/2000/svg",
|
|
124
125
|
fill: "none",
|
|
@@ -134,12 +135,12 @@ function P(e, t) {
|
|
|
134
135
|
})]);
|
|
135
136
|
}
|
|
136
137
|
// src/components/DiceRoller.vue?vue&type=script&setup=true&lang.ts
|
|
137
|
-
var
|
|
138
|
+
var re = ["id"], ie = ["for"], ae = ["title", "aria-label"], P = ["for"], F = [
|
|
138
139
|
"aria-invalid",
|
|
139
140
|
"aria-describedby",
|
|
140
141
|
"id",
|
|
141
142
|
"placeholder"
|
|
142
|
-
],
|
|
143
|
+
], I = ["disabled"], L = ["id"], R = /* @__PURE__ */ o({
|
|
143
144
|
inheritAttrs: !1,
|
|
144
145
|
__name: "DiceRoller",
|
|
145
146
|
props: {
|
|
@@ -157,6 +158,11 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
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: [
|
|
@@ -165,9 +171,10 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
165
171
|
"roll"
|
|
166
172
|
],
|
|
167
173
|
setup(e, { emit: o }) {
|
|
168
|
-
let s = o, c = e, { id: f } =
|
|
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
|
},
|
|
@@ -181,7 +188,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
181
188
|
role: "status",
|
|
182
189
|
"aria-live": "polite",
|
|
183
190
|
"aria-atomic": "true",
|
|
184
|
-
style: d(C(
|
|
191
|
+
style: d(C(O))
|
|
185
192
|
}, b(C(h) ? String(C(h)) : ""), 5),
|
|
186
193
|
C(h) ? (m(), n("output", {
|
|
187
194
|
key: 0,
|
|
@@ -196,24 +203,24 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
196
203
|
"aria-label": C(v).copy,
|
|
197
204
|
class: u(`${e.className}-copy-button`),
|
|
198
205
|
onClick: s[0] ||= (e) => C(w).copy()
|
|
199
|
-
}, [a(C(
|
|
206
|
+
}, [a(C(N), { class: u(`${e.className}-copy-icon`) }, null, 8, ["class"]), C(w).copied ? (m(), n("span", {
|
|
200
207
|
key: 0,
|
|
201
208
|
class: u(`${e.className}-copy-label-success`)
|
|
202
209
|
}, b(C(v).copied), 3)) : (m(), n("span", {
|
|
203
210
|
key: 1,
|
|
204
211
|
class: u(`${e.className}-copy-label`)
|
|
205
|
-
}, b(C(v).copy), 3))], 10,
|
|
212
|
+
}, b(C(v).copy), 3))], 10, ae)) : t("", !0)], 10, ie)) : t("", !0),
|
|
206
213
|
r("span", {
|
|
207
214
|
role: "status",
|
|
208
215
|
"aria-live": "polite",
|
|
209
|
-
style: d(C(w).error ? void 0 : C(
|
|
216
|
+
style: d(C(w).error ? void 0 : C(O)),
|
|
210
217
|
class: u(`${e.className}-copy-status`)
|
|
211
218
|
}, b(C(w).error || (C(w).copied ? C(v).copied : "")), 7),
|
|
212
219
|
r("div", { class: u(`${e.className}-input-group`) }, [
|
|
213
220
|
r("label", {
|
|
214
221
|
for: C(f),
|
|
215
222
|
class: u(`${e.className}-label`)
|
|
216
|
-
}, b(C(v).notation), 11,
|
|
223
|
+
}, b(C(v).notation), 11, P),
|
|
217
224
|
r("input", l({
|
|
218
225
|
...e.inputAttrs,
|
|
219
226
|
...C(y)
|
|
@@ -225,34 +232,34 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
225
232
|
id: C(f),
|
|
226
233
|
placeholder: `e.g. ${e.notation || "4d6"}`,
|
|
227
234
|
class: [`${e.className}-input`, C(p) ? `${e.className}-input-invalid` : null]
|
|
228
|
-
}, x(C(S), !0)), null, 16,
|
|
235
|
+
}, x(C(S), !0)), null, 16, F),
|
|
229
236
|
r("button", {
|
|
230
237
|
type: "button",
|
|
231
238
|
class: u(`${e.className}-button`),
|
|
232
239
|
disabled: !C(y).value || e.inputAttrs.disabled,
|
|
233
240
|
onClick: s[1] ||= (...e) => C(g) && C(g)(...e)
|
|
234
|
-
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 10,
|
|
241
|
+
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 10, I)
|
|
235
242
|
], 2),
|
|
236
243
|
C(p) ? (m(), n("span", {
|
|
237
244
|
key: 1,
|
|
238
245
|
id: `${C(f)}-error`,
|
|
239
246
|
role: "alert",
|
|
240
247
|
class: u(`${e.className}-error`)
|
|
241
|
-
}, b(C(p)), 11,
|
|
242
|
-
], 16,
|
|
248
|
+
}, b(C(p)), 11, L)) : t("", !0)
|
|
249
|
+
], 16, re));
|
|
243
250
|
}
|
|
244
|
-
}),
|
|
251
|
+
}), z = ["id"], B = ["for"], V = ["title", "aria-label"], H = {
|
|
245
252
|
key: 0,
|
|
246
253
|
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
|
-
},
|
|
254
|
+
}, U = {
|
|
248
255
|
key: 1,
|
|
249
256
|
class: "sr-only"
|
|
250
|
-
},
|
|
257
|
+
}, W = { class: "flex flex-col sm:flex-row gap-y-4" }, G = ["for"], K = [
|
|
251
258
|
"aria-invalid",
|
|
252
259
|
"aria-describedby",
|
|
253
260
|
"id",
|
|
254
261
|
"placeholder"
|
|
255
|
-
],
|
|
262
|
+
], q = ["disabled"], J = ["id"], oe = /* @__PURE__ */ o({
|
|
256
263
|
inheritAttrs: !1,
|
|
257
264
|
__name: "DiceRollerTailwind",
|
|
258
265
|
props: {
|
|
@@ -266,6 +273,11 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
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: [
|
|
@@ -274,9 +286,10 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
274
286
|
"roll"
|
|
275
287
|
],
|
|
276
288
|
setup(e, { emit: o }) {
|
|
277
|
-
let s = o, c = e, { id: f } =
|
|
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
|
},
|
|
@@ -290,7 +303,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
290
303
|
role: "status",
|
|
291
304
|
"aria-live": "polite",
|
|
292
305
|
"aria-atomic": "true",
|
|
293
|
-
style: d(C(
|
|
306
|
+
style: d(C(O))
|
|
294
307
|
}, b(C(h) ? String(C(h)) : ""), 5),
|
|
295
308
|
C(h) ? (m(), n("output", {
|
|
296
309
|
key: 0,
|
|
@@ -305,17 +318,17 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
305
318
|
"aria-label": C(v).copy,
|
|
306
319
|
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
320
|
onClick: s[0] ||= (e) => C(w).copy()
|
|
308
|
-
}, [a(C(
|
|
321
|
+
}, [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
322
|
r("span", {
|
|
310
323
|
role: "status",
|
|
311
324
|
"aria-live": "polite",
|
|
312
325
|
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
326
|
}, b(C(w).error || (C(w).copied ? C(v).copied : "")), 3),
|
|
314
|
-
r("div",
|
|
327
|
+
r("div", W, [
|
|
315
328
|
r("label", {
|
|
316
329
|
for: C(f),
|
|
317
330
|
class: "sr-only"
|
|
318
|
-
}, b(C(v).notation), 9,
|
|
331
|
+
}, b(C(v).notation), 9, G),
|
|
319
332
|
r("input", l({
|
|
320
333
|
...e.inputAttrs,
|
|
321
334
|
...C(y)
|
|
@@ -327,32 +340,32 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
327
340
|
id: C(f),
|
|
328
341
|
placeholder: `e.g. ${e.notation || "4d6"}`,
|
|
329
342
|
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,
|
|
343
|
+
}, x(C(S), !0)), null, 16, K),
|
|
331
344
|
r("button", {
|
|
332
345
|
type: "button",
|
|
333
346
|
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
347
|
disabled: !C(y).value || e.inputAttrs.disabled,
|
|
335
348
|
onClick: s[1] ||= (...e) => C(g) && C(g)(...e)
|
|
336
|
-
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 8,
|
|
349
|
+
}, [_(o.$slots, "button", {}, () => [i(b(e.btnLabel), 1)])], 8, q)
|
|
337
350
|
]),
|
|
338
351
|
C(p) ? (m(), n("span", {
|
|
339
352
|
key: 1,
|
|
340
353
|
id: `${C(f)}-error`,
|
|
341
354
|
role: "alert",
|
|
342
355
|
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,
|
|
356
|
+
}, b(C(p)), 9, J)) : t("", !0)
|
|
357
|
+
], 16, z));
|
|
345
358
|
}
|
|
346
|
-
}),
|
|
359
|
+
}), se = ["id"], ce = { class: "card-body" }, le = ["for"], ue = { class: "flex-grow-1 text-break" }, de = ["title", "aria-label"], fe = {
|
|
347
360
|
key: 0,
|
|
348
361
|
"aria-hidden": "true",
|
|
349
362
|
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
|
-
},
|
|
363
|
+
}, pe = ["for"], me = { class: "input-group" }, he = [
|
|
351
364
|
"aria-invalid",
|
|
352
365
|
"aria-describedby",
|
|
353
366
|
"id",
|
|
354
367
|
"placeholder"
|
|
355
|
-
],
|
|
368
|
+
], ge = ["disabled"], _e = ["id"], Y = [
|
|
356
369
|
"primary",
|
|
357
370
|
"secondary",
|
|
358
371
|
"success",
|
|
@@ -361,20 +374,20 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
361
374
|
"info",
|
|
362
375
|
"light",
|
|
363
376
|
"dark"
|
|
364
|
-
],
|
|
365
|
-
...
|
|
377
|
+
], X = [
|
|
378
|
+
...Y,
|
|
366
379
|
"body",
|
|
367
380
|
"white",
|
|
368
381
|
"transparent"
|
|
369
|
-
],
|
|
370
|
-
...
|
|
382
|
+
], Z = [
|
|
383
|
+
...Y,
|
|
371
384
|
"body",
|
|
372
385
|
"muted",
|
|
373
386
|
"white",
|
|
374
387
|
"black-50",
|
|
375
388
|
"white-50"
|
|
376
|
-
],
|
|
377
|
-
...
|
|
389
|
+
], Q = [
|
|
390
|
+
...Y,
|
|
378
391
|
"link",
|
|
379
392
|
"outline-primary",
|
|
380
393
|
"outline-secondary",
|
|
@@ -384,14 +397,14 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
384
397
|
"outline-info",
|
|
385
398
|
"outline-light",
|
|
386
399
|
"outline-dark"
|
|
387
|
-
], $ = [...
|
|
400
|
+
], $ = [...Y, "white"], ve = /* @__PURE__ */ o({
|
|
388
401
|
inheritAttrs: !1,
|
|
389
402
|
__name: "DiceRollerBootstrap",
|
|
390
403
|
props: {
|
|
391
404
|
bgVariant: {
|
|
392
405
|
type: String,
|
|
393
406
|
validator(e) {
|
|
394
|
-
return
|
|
407
|
+
return X.includes(e);
|
|
395
408
|
}
|
|
396
409
|
},
|
|
397
410
|
borderVariant: {
|
|
@@ -408,7 +421,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
408
421
|
type: String,
|
|
409
422
|
default: "primary",
|
|
410
423
|
validator(e) {
|
|
411
|
-
return
|
|
424
|
+
return Q.includes(e);
|
|
412
425
|
}
|
|
413
426
|
},
|
|
414
427
|
id: String,
|
|
@@ -421,7 +434,7 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
421
434
|
outputBgVariant: {
|
|
422
435
|
type: String,
|
|
423
436
|
validator(e) {
|
|
424
|
-
return
|
|
437
|
+
return X.includes(e);
|
|
425
438
|
}
|
|
426
439
|
},
|
|
427
440
|
outputBorderVariant: {
|
|
@@ -433,26 +446,31 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
433
446
|
outputTextVariant: {
|
|
434
447
|
type: String,
|
|
435
448
|
validator(e) {
|
|
436
|
-
return
|
|
449
|
+
return Z.includes(e);
|
|
437
450
|
}
|
|
438
451
|
},
|
|
439
452
|
outputVariant: {
|
|
440
453
|
type: String,
|
|
441
454
|
validator(e) {
|
|
442
|
-
return
|
|
455
|
+
return Y.includes(e);
|
|
443
456
|
}
|
|
444
457
|
},
|
|
445
458
|
textVariant: {
|
|
446
459
|
type: String,
|
|
447
460
|
validator(e) {
|
|
448
|
-
return
|
|
461
|
+
return Z.includes(e);
|
|
449
462
|
}
|
|
450
463
|
},
|
|
451
464
|
variant: {
|
|
452
465
|
type: String,
|
|
453
466
|
validator(e) {
|
|
454
|
-
return
|
|
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: [
|
|
@@ -471,9 +489,10 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
471
489
|
[`bg-${f.outputBgVariant}`]: f.outputBgVariant,
|
|
472
490
|
[`text-${f.outputTextVariant}`]: f.outputTextVariant,
|
|
473
491
|
[`border-${f.outputBorderVariant}`]: f.outputBorderVariant
|
|
474
|
-
})), g = e(() => `btn-${f.btnVariant || "primary"}`), { id: v } =
|
|
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
|
},
|
|
@@ -482,12 +501,12 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
482
501
|
return (e, s) => (m(), n("div", l(e.$attrs, {
|
|
483
502
|
id: o.id,
|
|
484
503
|
class: ["dice-roller card", p.value]
|
|
485
|
-
}), [r("div",
|
|
504
|
+
}), [r("div", ce, [
|
|
486
505
|
r("span", {
|
|
487
506
|
role: "status",
|
|
488
507
|
"aria-live": "polite",
|
|
489
508
|
"aria-atomic": "true",
|
|
490
|
-
style: d(C(
|
|
509
|
+
style: d(C(O))
|
|
491
510
|
}, b(C(S) ? String(C(S)) : ""), 5),
|
|
492
511
|
C(S) ? (m(), n("output", {
|
|
493
512
|
key: 0,
|
|
@@ -495,21 +514,21 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
495
514
|
"aria-live": "off",
|
|
496
515
|
for: C(v),
|
|
497
516
|
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",
|
|
517
|
+
}, [r("span", ue, b(C(S)), 1), C(k).isSupported ? (m(), n("button", {
|
|
499
518
|
key: 0,
|
|
500
519
|
type: "button",
|
|
501
520
|
title: C(T).copy,
|
|
502
521
|
"aria-label": C(T).copy,
|
|
503
522
|
class: "btn btn-link link-body-emphasis text-decoration-none p-2 d-inline-flex align-items-center flex-shrink-0 position-relative",
|
|
504
523
|
onClick: s[0] ||= (e) => C(k).copy()
|
|
505
|
-
}, [a(C(
|
|
524
|
+
}, [a(C(N), {
|
|
506
525
|
class: "flex-shrink-0",
|
|
507
526
|
style: {
|
|
508
527
|
width: "1.5rem",
|
|
509
528
|
height: "1.5rem"
|
|
510
529
|
},
|
|
511
530
|
"aria-hidden": "true"
|
|
512
|
-
}), C(k).copied ? (m(), n("span",
|
|
531
|
+
}), C(k).copied ? (m(), n("span", fe, b(C(T).copied), 1)) : t("", !0)], 8, de)) : t("", !0)], 10, le)) : t("", !0),
|
|
513
532
|
r("span", {
|
|
514
533
|
role: "status",
|
|
515
534
|
"aria-live": "polite",
|
|
@@ -518,8 +537,8 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
518
537
|
r("label", {
|
|
519
538
|
for: C(v),
|
|
520
539
|
class: "form-label visually-hidden"
|
|
521
|
-
}, b(C(T).notation), 9,
|
|
522
|
-
r("div",
|
|
540
|
+
}, b(C(T).notation), 9, pe),
|
|
541
|
+
r("div", me, [r("input", l({
|
|
523
542
|
...o.inputAttrs,
|
|
524
543
|
...C(E)
|
|
525
544
|
}, {
|
|
@@ -530,27 +549,32 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
530
549
|
id: C(v),
|
|
531
550
|
placeholder: `e.g. ${o.notation || "4d6"}`,
|
|
532
551
|
class: ["form-control", C(y) ? "is-invalid" : ""]
|
|
533
|
-
}, x(C(
|
|
552
|
+
}, x(C(D), !0)), null, 16, he), r("button", {
|
|
534
553
|
type: "button",
|
|
535
554
|
class: u(["btn", g.value]),
|
|
536
555
|
disabled: !C(E).value || o.inputAttrs.disabled,
|
|
537
556
|
onClick: s[1] ||= (...e) => C(w) && C(w)(...e)
|
|
538
|
-
}, [_(e.$slots, "button", {}, () => [i(b(o.btnLabel), 1)])], 10,
|
|
557
|
+
}, [_(e.$slots, "button", {}, () => [i(b(o.btnLabel), 1)])], 10, ge)]),
|
|
539
558
|
C(y) ? (m(), n("span", {
|
|
540
559
|
key: 1,
|
|
541
560
|
id: `${C(v)}-error`,
|
|
542
561
|
role: "alert",
|
|
543
562
|
class: "d-block mt-3 invalid-feedback"
|
|
544
|
-
}, b(C(y)), 9,
|
|
545
|
-
])], 16,
|
|
563
|
+
}, b(C(y)), 9, _e)) : t("", !0)
|
|
564
|
+
])], 16, se));
|
|
546
565
|
}
|
|
547
|
-
}),
|
|
566
|
+
}), ye = /* @__PURE__ */ o({
|
|
548
567
|
__name: "DiceRollerRenderless",
|
|
549
568
|
props: {
|
|
550
569
|
notation: String,
|
|
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 te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
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,14 +594,15 @@ var te = ["id"], ne = ["for"], re = ["title", "aria-label"], F = ["for"], I = [
|
|
|
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
|
});
|
|
582
|
-
export {
|
|
608
|
+
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),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": "
|
|
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": "^
|
|
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": "^
|
|
87
|
+
"@dice-roller/rpg-dice-roller": "^6.0.0-beta.7",
|
|
88
88
|
"vue": "^3.5.45"
|
|
89
89
|
},
|
|
90
90
|
"overrides": {
|