@openreachtech/furo-vue 1.6.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -0
- package/README.md +2 -0
- package/docs/design-tokens.md +419 -0
- package/docs/furo-accordion.md +109 -0
- package/docs/furo-alert-dialog.md +107 -0
- package/docs/furo-attachment.md +133 -0
- package/docs/furo-autocomplete-field.md +719 -0
- package/docs/furo-avatar-group.md +87 -0
- package/docs/furo-avatar.md +101 -0
- package/docs/furo-badge.md +126 -0
- package/docs/furo-breadcrumb.md +89 -0
- package/docs/furo-button.md +263 -0
- package/docs/furo-checkbox.md +384 -0
- package/docs/furo-collapsible.md +104 -0
- package/docs/furo-control-block.md +102 -0
- package/docs/furo-date-picker.md +270 -0
- package/docs/furo-date-time-picker.md +110 -0
- package/docs/furo-dialog.md +88 -0
- package/docs/furo-drawer.md +122 -0
- package/docs/furo-dropdown-menu.md +298 -0
- package/docs/furo-editable-field.md +391 -0
- package/docs/furo-editor.md +304 -0
- package/docs/furo-email-field.md +93 -0
- package/docs/furo-empty-state.md +97 -0
- package/docs/furo-error-state.md +97 -0
- package/docs/furo-file-field.md +163 -0
- package/docs/furo-icon.md +288 -0
- package/docs/furo-number-field.md +397 -0
- package/docs/furo-pagination.md +101 -0
- package/docs/furo-password-field.md +75 -0
- package/docs/furo-popover.md +114 -0
- package/docs/furo-radio.md +125 -0
- package/docs/furo-scroll-area.md +112 -0
- package/docs/furo-search-field.md +94 -0
- package/docs/furo-section-header.md +135 -0
- package/docs/furo-select.md +443 -0
- package/docs/furo-separator.md +87 -0
- package/docs/furo-sidebar.md +178 -0
- package/docs/furo-skeleton.md +92 -0
- package/docs/furo-splitter.md +103 -0
- package/docs/furo-stepper.md +127 -0
- package/docs/furo-switch.md +107 -0
- package/docs/furo-table.md +233 -0
- package/docs/furo-tabs.md +173 -0
- package/docs/furo-text-field.md +249 -0
- package/docs/furo-textarea.md +214 -0
- package/docs/furo-time-field.md +276 -0
- package/docs/furo-toast.md +217 -0
- package/docs/furo-toggle-group.md +123 -0
- package/docs/furo-toggle.md +104 -0
- package/docs/furo-tool-bar.md +88 -0
- package/docs/furo-tooltip.md +107 -0
- package/lib/components/atoms/FuroButton/FuroButtonContext.js +8 -8
- package/lib/components/atoms/FuroCheckbox/FuroCheckboxContext.js +1 -1
- package/lib/components/atoms/FuroSwitch/FuroSwitchContext.js +1 -1
- package/lib/components/atoms/FuroToggle/FuroToggleContext.js +1 -1
- package/lib/components/molecules/FuroAccordion/FuroAccordionContext.js +1 -1
- package/lib/components/molecules/FuroCollapsible/FuroCollapsibleContext.js +1 -1
- package/lib/components/molecules/FuroDropdownMenu/FuroDropdownMenuContext.js +1 -2
- package/lib/components/molecules/FuroPopover/FuroPopoverContext.js +1 -1
- package/lib/components/molecules/FuroSelect/FuroSelect.vue +8 -6
- package/lib/components/molecules/FuroSelect/FuroSelectContext.js +35 -0
- package/lib/components/molecules/FuroSelect/FuroSelectOptionText.vue +40 -0
- package/lib/components/molecules/FuroSelect/FuroSelectOptionTextContext.js +275 -0
- package/lib/components/molecules/FuroSplitter/FuroSplitterContext.js +1 -1
- package/lib/components/molecules/FuroToggleGroup/FuroToggleGroupContext.js +1 -1
- package/lib/components/molecules/FuroTooltip/FuroTooltipContext.js +1 -1
- package/lib/components/organisms/FuroTable/FuroTableContext.js +3 -3
- package/lib/components/organisms/FuroToast/FuroToastContext.js +6 -2
- package/lib/components/organisms/FuroToast/ToastQueue.js +4 -4
- package/nuxt/index.js +9 -9
- package/package.json +24 -22
- package/public/furo-vue/components.json +1 -1
- package/types/generated/components/atoms/FuroAvatar/FuroAvatar.vue.d.ts +6 -15
- package/types/generated/components/atoms/FuroBadge/FuroBadge.vue.d.ts +8 -43
- package/types/generated/components/atoms/FuroButton/FuroButton.vue.d.ts +10 -45
- package/types/generated/components/atoms/FuroButton/FuroButtonContext.d.ts +4 -4
- package/types/generated/components/atoms/FuroCheckbox/FuroCheckbox.vue.d.ts +8 -20
- package/types/generated/components/atoms/FuroNumberField/FuroNumberField.vue.d.ts +12 -12
- package/types/generated/components/atoms/FuroRadio/FuroRadio.vue.d.ts +8 -24
- package/types/generated/components/atoms/FuroSwitch/FuroSwitch.vue.d.ts +0 -13
- package/types/generated/components/atoms/FuroToggle/FuroToggle.vue.d.ts +8 -19
- package/types/generated/components/molecules/FuroAccordion/FuroAccordion.vue.d.ts +14 -30
- package/types/generated/components/molecules/FuroAttachment/FuroAttachment.vue.d.ts +8 -44
- package/types/generated/components/molecules/FuroAutocompleteField/FuroAutocompleteField.vue.d.ts +74 -105
- package/types/generated/components/molecules/FuroAvatarGroup/FuroAvatarGroup.vue.d.ts +9 -18
- package/types/generated/components/molecules/FuroBreadcrumb/FuroBreadcrumb.vue.d.ts +22 -48
- package/types/generated/components/molecules/FuroCollapsible/FuroCollapsible.vue.d.ts +12 -23
- package/types/generated/components/molecules/FuroControlBlock/FuroControlBlock.vue.d.ts +6 -4
- package/types/generated/components/molecules/FuroDatePicker/FuroDatePicker.vue.d.ts +14 -16
- package/types/generated/components/molecules/FuroDropdownMenu/FuroDropdownMenu.vue.d.ts +13 -13
- package/types/generated/components/molecules/FuroDropdownMenu/FuroDropdownMenuOptionRows.vue.d.ts +34 -47
- package/types/generated/components/molecules/FuroEditableField/FuroEditableField.vue.d.ts +93 -115
- package/types/generated/components/molecules/FuroEmptyState/FuroEmptyState.vue.d.ts +8 -7
- package/types/generated/components/molecules/FuroErrorState/FuroErrorState.vue.d.ts +8 -7
- package/types/generated/components/molecules/FuroPagination/FuroPagination.vue.d.ts +14 -15
- package/types/generated/components/molecules/FuroPopover/FuroPopover.vue.d.ts +8 -7
- package/types/generated/components/molecules/FuroScrollArea/FuroScrollArea.vue.d.ts +6 -4
- package/types/generated/components/molecules/FuroSearchField/FuroSearchField.vue.d.ts +8 -22
- package/types/generated/components/molecules/FuroSectionHeader/FuroSectionHeader.vue.d.ts +10 -25
- package/types/generated/components/molecules/FuroSelect/FuroSelect.vue.d.ts +97 -108
- package/types/generated/components/molecules/FuroSelect/FuroSelectContext.d.ts +14 -0
- package/types/generated/components/molecules/FuroSelect/FuroSelectOptionText.vue.d.ts +52 -0
- package/types/generated/components/molecules/FuroSelect/FuroSelectOptionTextContext.d.ts +141 -0
- package/types/generated/components/molecules/FuroSplitter/FuroSplitter.vue.d.ts +14 -29
- package/types/generated/components/molecules/FuroTimeField/FuroTimeField.vue.d.ts +8 -7
- package/types/generated/components/molecules/FuroToggleGroup/FuroToggleGroup.vue.d.ts +9 -24
- package/types/generated/components/molecules/FuroToolBar/FuroToolBar.vue.d.ts +6 -9
- package/types/generated/components/molecules/FuroTooltip/FuroTooltip.vue.d.ts +8 -7
- package/types/generated/components/organisms/FuroAlertDialog/FuroAlertDialog.vue.d.ts +17 -19
- package/types/generated/components/organisms/FuroDialog/FuroDialog.vue.d.ts +20 -24
- package/types/generated/components/organisms/FuroDrawer/FuroDrawer.vue.d.ts +20 -24
- package/types/generated/components/organisms/FuroEditor/FuroEditor.vue.d.ts +9 -42
- package/types/generated/components/organisms/FuroSidebar/FuroSidebar.vue.d.ts +23 -62
- package/types/generated/components/organisms/FuroStepper/FuroStepper.vue.d.ts +19 -19
- package/types/generated/components/organisms/FuroTable/FuroTable.vue.d.ts +54 -71
- package/types/generated/components/organisms/FuroTable/FuroTableContext.d.ts +2 -2
- package/types/generated/components/organisms/FuroTabs/FuroTabs.vue.d.ts +17 -17
- package/types/generated/components/organisms/FuroToast/FuroToast.vue.d.ts +25 -31
|
@@ -267,7 +267,7 @@ export default class FuroAccordionContext extends BaseFuroContext {
|
|
|
267
267
|
|
|
268
268
|
const { value: attrsValue } = this.attrs ?? {}
|
|
269
269
|
|
|
270
|
-
if (attrsValue !== undefined) {
|
|
270
|
+
if (typeof attrsValue !== 'undefined') {
|
|
271
271
|
return /** @type {FuroAccordionValue} */ (attrsValue)
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -170,7 +170,6 @@ export default class FuroDropdownMenuContext extends BaseFuroContext {
|
|
|
170
170
|
*/
|
|
171
171
|
get parcel () {
|
|
172
172
|
return {
|
|
173
|
-
open: undefined,
|
|
174
173
|
disabled: false,
|
|
175
174
|
side: 'bottom',
|
|
176
175
|
align: 'start',
|
|
@@ -199,7 +198,7 @@ export default class FuroDropdownMenuContext extends BaseFuroContext {
|
|
|
199
198
|
* @returns {boolean}
|
|
200
199
|
*/
|
|
201
200
|
isOpenControlled () {
|
|
202
|
-
return this.parcel?.open !== undefined
|
|
201
|
+
return typeof this.parcel?.open !== 'undefined'
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
/**
|
|
@@ -125,7 +125,7 @@ export default class FuroPopoverContext extends BaseFuroContext {
|
|
|
125
125
|
* @returns {boolean} true when `parcel.open` is supplied.
|
|
126
126
|
*/
|
|
127
127
|
isOpenControlled () {
|
|
128
|
-
return this.parcel?.open !== undefined
|
|
128
|
+
return typeof this.parcel?.open !== 'undefined'
|
|
129
129
|
&& this.parcel?.open !== null
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import FuroIcon from '../../atoms/FuroIcon/FuroIcon.vue'
|
|
11
11
|
import FuroSelectContext from './FuroSelectContext.js'
|
|
12
|
+
import FuroSelectOptionText from './FuroSelectOptionText.vue'
|
|
12
13
|
|
|
13
14
|
export default defineComponent({
|
|
14
15
|
name: 'FuroSelect',
|
|
15
16
|
|
|
16
17
|
components: {
|
|
17
18
|
FuroIcon,
|
|
19
|
+
FuroSelectOptionText,
|
|
18
20
|
SelectRoot: RekaSelect['Root'],
|
|
19
21
|
SelectTrigger: RekaSelect['Trigger'],
|
|
20
22
|
SelectValue: RekaSelect['Value'],
|
|
@@ -168,7 +170,7 @@ export default defineComponent({
|
|
|
168
170
|
<SelectViewport class="viewport">
|
|
169
171
|
<template
|
|
170
172
|
v-for="(option, index) in context.parcel?.options"
|
|
171
|
-
:key="index"
|
|
173
|
+
:key="context.generateOptionKey({ option, index })"
|
|
172
174
|
>
|
|
173
175
|
<template v-if="context.shouldShowGroupOption({ option })">
|
|
174
176
|
<SelectGroup
|
|
@@ -192,7 +194,7 @@ export default defineComponent({
|
|
|
192
194
|
|
|
193
195
|
<template
|
|
194
196
|
v-for="(groupChildOption, groupChildIndex) in context.extractGroupOptions({ option })"
|
|
195
|
-
:key="groupChildIndex"
|
|
197
|
+
:key="context.generateOptionKey({ option: groupChildOption, index: groupChildIndex })"
|
|
196
198
|
>
|
|
197
199
|
<SelectOption
|
|
198
200
|
class="option"
|
|
@@ -206,7 +208,7 @@ export default defineComponent({
|
|
|
206
208
|
:option="groupChildOption"
|
|
207
209
|
:option-index="groupChildIndex"
|
|
208
210
|
>
|
|
209
|
-
<
|
|
211
|
+
<FuroSelectOptionText>
|
|
210
212
|
<slot
|
|
211
213
|
name="option-text"
|
|
212
214
|
:option="groupChildOption"
|
|
@@ -214,7 +216,7 @@ export default defineComponent({
|
|
|
214
216
|
>
|
|
215
217
|
{{ context.resolveOptionLabel({ option: groupChildOption }) }}
|
|
216
218
|
</slot>
|
|
217
|
-
</
|
|
219
|
+
</FuroSelectOptionText>
|
|
218
220
|
|
|
219
221
|
<SelectOptionIndicator class="select-indicator">
|
|
220
222
|
<slot
|
|
@@ -252,7 +254,7 @@ export default defineComponent({
|
|
|
252
254
|
:option="option"
|
|
253
255
|
:option-index="index"
|
|
254
256
|
>
|
|
255
|
-
<
|
|
257
|
+
<FuroSelectOptionText>
|
|
256
258
|
<slot
|
|
257
259
|
name="option-text"
|
|
258
260
|
:option="option"
|
|
@@ -260,7 +262,7 @@ export default defineComponent({
|
|
|
260
262
|
>
|
|
261
263
|
{{ context.resolveOptionLabel({ option }) }}
|
|
262
264
|
</slot>
|
|
263
|
-
</
|
|
265
|
+
</FuroSelectOptionText>
|
|
264
266
|
|
|
265
267
|
<SelectOptionIndicator class="select-indicator">
|
|
266
268
|
<slot
|
|
@@ -295,6 +295,41 @@ export default class FuroSelectContext extends BaseFuroContext {
|
|
|
295
295
|
?? null
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Build an option's render key from its value and label, so a change to either
|
|
300
|
+
* remounts the item, because the item records both only when it mounts.
|
|
301
|
+
*
|
|
302
|
+
* @param {{
|
|
303
|
+
* option: FuroSelectOption
|
|
304
|
+
* index: number
|
|
305
|
+
* }} params - Parameters of this method.
|
|
306
|
+
* @returns {string} Render key.
|
|
307
|
+
*/
|
|
308
|
+
generateOptionKey ({
|
|
309
|
+
option,
|
|
310
|
+
index,
|
|
311
|
+
}) {
|
|
312
|
+
if (this.shouldShowGroupOption({ option })) {
|
|
313
|
+
return `group-${index}`
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return JSON.stringify(
|
|
317
|
+
[
|
|
318
|
+
this.resolveOptionValue({
|
|
319
|
+
option,
|
|
320
|
+
}),
|
|
321
|
+
this.resolveOptionLabel({
|
|
322
|
+
option,
|
|
323
|
+
}),
|
|
324
|
+
],
|
|
325
|
+
(key, value) => (
|
|
326
|
+
typeof value === 'bigint'
|
|
327
|
+
? `${value}n`
|
|
328
|
+
: value
|
|
329
|
+
)
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
|
|
298
333
|
/**
|
|
299
334
|
* Setup component context.
|
|
300
335
|
*
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import {
|
|
3
|
+
defineComponent,
|
|
4
|
+
} from 'vue'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Select as RekaSelect,
|
|
8
|
+
} from 'reka-ui/namespaced'
|
|
9
|
+
|
|
10
|
+
import FuroSelectOptionTextContext from './FuroSelectOptionTextContext.js'
|
|
11
|
+
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name: 'FuroSelectOptionText',
|
|
14
|
+
|
|
15
|
+
components: {
|
|
16
|
+
SelectOptionText: RekaSelect['ItemText'],
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
setup (
|
|
20
|
+
props,
|
|
21
|
+
componentContext
|
|
22
|
+
) {
|
|
23
|
+
const context = FuroSelectOptionTextContext.create({
|
|
24
|
+
props,
|
|
25
|
+
componentContext,
|
|
26
|
+
})
|
|
27
|
+
.setupComponent()
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
context,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<SelectOptionText :ref="context.textComponentRef">
|
|
38
|
+
<slot />
|
|
39
|
+
</SelectOptionText>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onBeforeUnmount,
|
|
3
|
+
onMounted,
|
|
4
|
+
ref,
|
|
5
|
+
shallowRef,
|
|
6
|
+
} from 'vue'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
injectSelectItemContext,
|
|
10
|
+
injectSelectRootContext,
|
|
11
|
+
} from 'reka-ui'
|
|
12
|
+
|
|
13
|
+
import BaseFuroContext from '../../../contexts/BaseFuroContext.js'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Context class for the text of one FuroSelect option.
|
|
17
|
+
*
|
|
18
|
+
* @extends {BaseFuroContext<null, {}, never>}
|
|
19
|
+
*/
|
|
20
|
+
export default class FuroSelectOptionTextContext extends BaseFuroContext {
|
|
21
|
+
/**
|
|
22
|
+
* Constructor.
|
|
23
|
+
*
|
|
24
|
+
* @param {FuroSelectOptionTextContextParams} params - Parameters of this constructor.
|
|
25
|
+
*/
|
|
26
|
+
constructor ({
|
|
27
|
+
props,
|
|
28
|
+
componentContext,
|
|
29
|
+
refHash,
|
|
30
|
+
selectRootContext,
|
|
31
|
+
selectItemContext,
|
|
32
|
+
}) {
|
|
33
|
+
super({
|
|
34
|
+
props,
|
|
35
|
+
componentContext,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
this.refHash = refHash
|
|
39
|
+
this.selectRootContext = selectRootContext
|
|
40
|
+
this.selectItemContext = selectItemContext
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Factory method.
|
|
45
|
+
*
|
|
46
|
+
* @template {X extends typeof FuroSelectOptionTextContext ? X : never} T, X
|
|
47
|
+
* @override
|
|
48
|
+
* @param {FuroSelectOptionTextContextFactoryParams} params - Parameters of this factory method.
|
|
49
|
+
* @returns {InstanceType<T>} An instance of this class.
|
|
50
|
+
* @this {T}
|
|
51
|
+
*/
|
|
52
|
+
static create ({
|
|
53
|
+
props,
|
|
54
|
+
componentContext,
|
|
55
|
+
|
|
56
|
+
refHash = this.buildRefHash(),
|
|
57
|
+
selectRootContext = this.injectSelectRootContext(),
|
|
58
|
+
selectItemContext = this.injectSelectItemContext(),
|
|
59
|
+
}) {
|
|
60
|
+
return /** @type {InstanceType<T>} */ (
|
|
61
|
+
new this({
|
|
62
|
+
props,
|
|
63
|
+
componentContext,
|
|
64
|
+
|
|
65
|
+
refHash,
|
|
66
|
+
selectRootContext,
|
|
67
|
+
selectItemContext,
|
|
68
|
+
})
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Build ref hash.
|
|
74
|
+
*
|
|
75
|
+
* @override
|
|
76
|
+
* @returns {FuroSelectOptionTextContextParams['refHash']}
|
|
77
|
+
*/
|
|
78
|
+
static buildRefHash () {
|
|
79
|
+
return {
|
|
80
|
+
textComponentRef: shallowRef(null),
|
|
81
|
+
observerRef: shallowRef(null),
|
|
82
|
+
recordedTextRef: ref(null),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Inject the select root context, which holds the text the trigger shows.
|
|
88
|
+
*
|
|
89
|
+
* @returns {FuroSelectRootContext}
|
|
90
|
+
*/
|
|
91
|
+
static injectSelectRootContext () {
|
|
92
|
+
return injectSelectRootContext()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Inject the context of the option that holds this text.
|
|
97
|
+
*
|
|
98
|
+
* @returns {FuroSelectItemContext}
|
|
99
|
+
*/
|
|
100
|
+
static injectSelectItemContext () {
|
|
101
|
+
return injectSelectItemContext()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* get: Ctor
|
|
106
|
+
*
|
|
107
|
+
* @override
|
|
108
|
+
* @returns {typeof FuroSelectOptionTextContext}
|
|
109
|
+
*/
|
|
110
|
+
get Ctor () {
|
|
111
|
+
return /** @type {typeof FuroSelectOptionTextContext} */ (
|
|
112
|
+
this.constructor
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* get: textComponentRef
|
|
118
|
+
*
|
|
119
|
+
* @returns {import('vue').ShallowRef<{ $el: HTMLElement } | null>}
|
|
120
|
+
*/
|
|
121
|
+
get textComponentRef () {
|
|
122
|
+
return this.refHash.textComponentRef
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* get: observerRef
|
|
127
|
+
*
|
|
128
|
+
* @returns {import('vue').ShallowRef<MutationObserver | null>}
|
|
129
|
+
*/
|
|
130
|
+
get observerRef () {
|
|
131
|
+
return this.refHash.observerRef
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* get: recordedTextRef
|
|
136
|
+
*
|
|
137
|
+
* @returns {import('vue').Ref<string | null>}
|
|
138
|
+
*/
|
|
139
|
+
get recordedTextRef () {
|
|
140
|
+
return this.refHash.recordedTextRef
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Setup component context.
|
|
145
|
+
*
|
|
146
|
+
* @template {X extends FuroSelectOptionTextContext ? X : never} T, X
|
|
147
|
+
* @override
|
|
148
|
+
* @returns {T} - For method chaining.
|
|
149
|
+
* @this {T}
|
|
150
|
+
*/
|
|
151
|
+
setupComponent () {
|
|
152
|
+
onMounted(() => {
|
|
153
|
+
this.recordedTextRef.value = this.extractText()
|
|
154
|
+
this.observeTextElement()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
onBeforeUnmount(() => {
|
|
158
|
+
this.disconnectObserver()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
return this
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Extract the rendered text element.
|
|
166
|
+
*
|
|
167
|
+
* @returns {HTMLElement | null}
|
|
168
|
+
*/
|
|
169
|
+
extractTextElement () {
|
|
170
|
+
return this.textComponentRef.value?.$el
|
|
171
|
+
?? null
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Extract the rendered text.
|
|
176
|
+
*
|
|
177
|
+
* @returns {string | null}
|
|
178
|
+
*/
|
|
179
|
+
extractText () {
|
|
180
|
+
return this.extractTextElement()?.textContent
|
|
181
|
+
?? null
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Watch the rendered text for changes.
|
|
186
|
+
*/
|
|
187
|
+
observeTextElement () {
|
|
188
|
+
const textElement = this.extractTextElement()
|
|
189
|
+
|
|
190
|
+
if (!textElement) {
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const observer = this.Ctor.createMutationObserver({
|
|
195
|
+
handler: () => this.syncText(),
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
observer.observe(textElement, {
|
|
199
|
+
subtree: true,
|
|
200
|
+
childList: true,
|
|
201
|
+
characterData: true,
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
this.observerRef.value = observer
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Replace the recorded option text when the rendered text differs from it.
|
|
209
|
+
*/
|
|
210
|
+
syncText () {
|
|
211
|
+
const text = this.extractText()
|
|
212
|
+
|
|
213
|
+
if (text === null) {
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (text === this.recordedTextRef.value) {
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
this.recordedTextRef.value = text
|
|
222
|
+
this.selectRootContext.onOptionAdd({
|
|
223
|
+
value: this.selectItemContext.value,
|
|
224
|
+
disabled: this.selectItemContext.disabled.value,
|
|
225
|
+
textContent: text,
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Stop watching the rendered text.
|
|
231
|
+
*/
|
|
232
|
+
disconnectObserver () {
|
|
233
|
+
this.observerRef.value?.disconnect()
|
|
234
|
+
this.observerRef.value = null
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @typedef {{
|
|
240
|
+
* onOptionAdd: (option: {
|
|
241
|
+
* value: unknown
|
|
242
|
+
* disabled: boolean
|
|
243
|
+
* textContent: string
|
|
244
|
+
* }) => void
|
|
245
|
+
* }} FuroSelectRootContext
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @typedef {{
|
|
250
|
+
* value: unknown
|
|
251
|
+
* disabled: import('vue').Ref<boolean>
|
|
252
|
+
* }} FuroSelectItemContext
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @typedef {import('../../../contexts/BaseFuroContext.js').BaseFuroContextParams & {
|
|
257
|
+
* props: {}
|
|
258
|
+
* componentContext: import('vue').SetupContext
|
|
259
|
+
* refHash: {
|
|
260
|
+
* textComponentRef: import('vue').ShallowRef<{ $el: HTMLElement } | null>
|
|
261
|
+
* observerRef: import('vue').ShallowRef<MutationObserver | null>
|
|
262
|
+
* recordedTextRef: import('vue').Ref<string | null>
|
|
263
|
+
* }
|
|
264
|
+
* selectRootContext: FuroSelectRootContext
|
|
265
|
+
* selectItemContext: FuroSelectItemContext
|
|
266
|
+
* }} FuroSelectOptionTextContextParams
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* @typedef {Omit<FuroSelectOptionTextContextParams, 'refHash' | 'selectRootContext' | 'selectItemContext'> & {
|
|
271
|
+
* refHash?: FuroSelectOptionTextContextParams['refHash']
|
|
272
|
+
* selectRootContext?: FuroSelectRootContext
|
|
273
|
+
* selectItemContext?: FuroSelectItemContext
|
|
274
|
+
* }} FuroSelectOptionTextContextFactoryParams
|
|
275
|
+
*/
|
|
@@ -272,7 +272,7 @@ export default class FuroSplitterContext extends BaseFuroContext {
|
|
|
272
272
|
}) {
|
|
273
273
|
const entries = Object.entries(panel)
|
|
274
274
|
.filter(([key]) => SPLITTER_PANEL_KEYS.has(key))
|
|
275
|
-
.filter(([, value]) => value !== undefined)
|
|
275
|
+
.filter(([, value]) => typeof value !== 'undefined')
|
|
276
276
|
|
|
277
277
|
return Object.fromEntries(entries)
|
|
278
278
|
}
|
|
@@ -250,7 +250,7 @@ export default class FuroToggleGroupContext extends BaseFuroContext {
|
|
|
250
250
|
|
|
251
251
|
const { value: attrsValue } = this.attrs ?? {}
|
|
252
252
|
|
|
253
|
-
if (attrsValue !== undefined) {
|
|
253
|
+
if (typeof attrsValue !== 'undefined') {
|
|
254
254
|
return /** @type {FuroToggleGroupValue} */ (attrsValue)
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -144,7 +144,7 @@ export default class FuroTooltipContext extends BaseFuroContext {
|
|
|
144
144
|
* @returns {boolean} true when `parcel.open` is supplied.
|
|
145
145
|
*/
|
|
146
146
|
isOpenControlled () {
|
|
147
|
-
return this.parcel?.open !== undefined
|
|
147
|
+
return typeof this.parcel?.open !== 'undefined'
|
|
148
148
|
&& this.parcel?.open !== null
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -129,11 +129,11 @@ export default class FuroTableContext extends BaseFuroContext {
|
|
|
129
129
|
* Wrapped as a static hook so scroll throttling can be driven deterministically
|
|
130
130
|
* in tests (spy on this method) instead of depending on the browser global.
|
|
131
131
|
*
|
|
132
|
-
* @param {FrameRequestCallback}
|
|
132
|
+
* @param {FrameRequestCallback} frameCallback - Callback to run on the next frame.
|
|
133
133
|
* @returns {number} The frame request id.
|
|
134
134
|
*/
|
|
135
|
-
static requestFrame (
|
|
136
|
-
return globalThis.requestAnimationFrame(
|
|
135
|
+
static requestFrame (frameCallback) {
|
|
136
|
+
return globalThis.requestAnimationFrame(frameCallback)
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -61,13 +61,17 @@ const LOADING_DURATION = 1000000000
|
|
|
61
61
|
* only accent — the toast body stays neutral.
|
|
62
62
|
*/
|
|
63
63
|
const TYPE_ICON_NAME_HASH = {
|
|
64
|
-
info: 'ph:info',
|
|
65
64
|
success: 'ph:check-circle',
|
|
66
65
|
warning: 'ph:warning',
|
|
67
66
|
error: 'ph:x-circle',
|
|
68
67
|
loading: 'ph:circle-notch',
|
|
69
68
|
}
|
|
70
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Icon name of the default `info` type, which the hash above leaves out.
|
|
72
|
+
*/
|
|
73
|
+
const DEFAULT_TYPE_ICON_NAME = 'ph:info'
|
|
74
|
+
|
|
71
75
|
/**
|
|
72
76
|
* Context class for FuroToast organism.
|
|
73
77
|
*
|
|
@@ -591,7 +595,7 @@ export default class FuroToastContext extends BaseFuroContext {
|
|
|
591
595
|
type,
|
|
592
596
|
}) {
|
|
593
597
|
return TYPE_ICON_NAME_HASH[type]
|
|
594
|
-
??
|
|
598
|
+
?? DEFAULT_TYPE_ICON_NAME
|
|
595
599
|
}
|
|
596
600
|
|
|
597
601
|
/**
|
|
@@ -266,10 +266,10 @@ export default class ToastQueue {
|
|
|
266
266
|
* @param {ToastConfig} [params] - Configuration to merge.
|
|
267
267
|
*/
|
|
268
268
|
configure (params = {}) {
|
|
269
|
-
|
|
270
|
-
this.stateReactive.config,
|
|
271
|
-
params
|
|
272
|
-
|
|
269
|
+
this.stateReactive.config = {
|
|
270
|
+
...this.stateReactive.config,
|
|
271
|
+
...params,
|
|
272
|
+
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
/**
|
package/nuxt/index.js
CHANGED
|
@@ -43,14 +43,14 @@ export default defineNuxtModule({
|
|
|
43
43
|
nuxt,
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
}
|
|
46
|
+
const { appConfig } = nuxt.options
|
|
47
|
+
|
|
48
|
+
appConfig.furoVue = {
|
|
49
|
+
iconComponentName: extractIconComponentName({
|
|
50
|
+
options,
|
|
51
|
+
nuxt,
|
|
52
|
+
}),
|
|
53
|
+
}
|
|
54
54
|
|
|
55
55
|
const resolver = createResolver(import.meta.url)
|
|
56
56
|
|
|
@@ -84,7 +84,7 @@ async function ensureIconModule ({
|
|
|
84
84
|
throw new Error(`[@openreachtech/furo-vue] the Nuxt module needs \`${ICON_MODULE_NAME}\` to draw the names the icon registry lacks. Install it with \`npm install ${ICON_MODULE_NAME}\`, or drop this module and install a renderer yourself with \`furoIconRegistry.useIconRenderer()\`.`)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
await installModule(ICON_MODULE_NAME,
|
|
87
|
+
await installModule(ICON_MODULE_NAME, {}, nuxt)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|