@transferwise/components 0.0.0-experimental-49c6983 → 0.0.0-experimental-7636184
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/build/Provider/Provider.js +4 -1
- package/build/Provider/Provider.js.map +1 -1
- package/build/Provider/Provider.mjs +4 -1
- package/build/Provider/Provider.mjs.map +1 -1
- package/build/Snackbar/Snackbar.js +136 -105
- package/build/Snackbar/Snackbar.js.map +1 -1
- package/build/Snackbar/Snackbar.mjs +137 -103
- package/build/Snackbar/Snackbar.mjs.map +1 -1
- package/build/Snackbar/SnackbarContext.js.map +1 -1
- package/build/Snackbar/SnackbarContext.mjs.map +1 -1
- package/build/Snackbar/SnackbarPortal.js +12 -0
- package/build/Snackbar/SnackbarPortal.js.map +1 -0
- package/build/Snackbar/SnackbarPortal.mjs +8 -0
- package/build/Snackbar/SnackbarPortal.mjs.map +1 -0
- package/build/Snackbar/SnackbarProvider.js +24 -28
- package/build/Snackbar/SnackbarProvider.js.map +1 -1
- package/build/Snackbar/SnackbarProvider.mjs +25 -29
- package/build/Snackbar/SnackbarProvider.mjs.map +1 -1
- package/build/Snackbar/constants.js +14 -0
- package/build/Snackbar/constants.js.map +1 -0
- package/build/Snackbar/constants.mjs +9 -0
- package/build/Snackbar/constants.mjs.map +1 -0
- package/build/Snackbar/useSnackbarAutoDismiss.js +64 -0
- package/build/Snackbar/useSnackbarAutoDismiss.js.map +1 -0
- package/build/Snackbar/useSnackbarAutoDismiss.mjs +60 -0
- package/build/Snackbar/useSnackbarAutoDismiss.mjs.map +1 -0
- package/build/Snackbar/useSnackbarManager.js +144 -0
- package/build/Snackbar/useSnackbarManager.js.map +1 -0
- package/build/Snackbar/useSnackbarManager.mjs +140 -0
- package/build/Snackbar/useSnackbarManager.mjs.map +1 -0
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +5 -5
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +5 -5
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/main.css +131 -61
- package/build/styles/Snackbar/Snackbar.css +105 -54
- package/build/styles/Typeahead/Typeahead.css +27 -8
- package/build/styles/main.css +131 -61
- package/build/types/Provider/Provider.d.ts.map +1 -1
- package/build/types/Snackbar/Snackbar.d.ts +48 -9
- package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
- package/build/types/Snackbar/Snackbar.types.d.ts +12 -0
- package/build/types/Snackbar/Snackbar.types.d.ts.map +1 -0
- package/build/types/Snackbar/SnackbarContext.d.ts +2 -2
- package/build/types/Snackbar/SnackbarContext.d.ts.map +1 -1
- package/build/types/Snackbar/SnackbarPortal.d.ts +4 -0
- package/build/types/Snackbar/SnackbarPortal.d.ts.map +1 -0
- package/build/types/Snackbar/SnackbarProvider.d.ts +10 -0
- package/build/types/Snackbar/SnackbarProvider.d.ts.map +1 -1
- package/build/types/Snackbar/constants.d.ts +7 -0
- package/build/types/Snackbar/constants.d.ts.map +1 -0
- package/build/types/Snackbar/index.d.ts +1 -1
- package/build/types/Snackbar/index.d.ts.map +1 -1
- package/build/types/Snackbar/useSnackbar.d.ts +1 -1
- package/build/types/Snackbar/useSnackbar.d.ts.map +1 -1
- package/build/types/Snackbar/useSnackbarAutoDismiss.d.ts +12 -0
- package/build/types/Snackbar/useSnackbarAutoDismiss.d.ts.map +1 -0
- package/build/types/Snackbar/useSnackbarManager.d.ts +20 -0
- package/build/types/Snackbar/useSnackbarManager.d.ts.map +1 -0
- package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ListItem/_stories/ListItem.scenarios.story.tsx +13 -16
- package/src/Provider/Provider.tsx +2 -1
- package/src/Snackbar/Snackbar.css +105 -54
- package/src/Snackbar/Snackbar.less +124 -60
- package/src/Snackbar/Snackbar.test.tsx +540 -120
- package/src/Snackbar/Snackbar.tsx +159 -99
- package/src/Snackbar/Snackbar.types.ts +17 -0
- package/src/Snackbar/SnackbarContext.ts +2 -2
- package/src/Snackbar/SnackbarPortal.tsx +8 -0
- package/src/Snackbar/SnackbarProvider.test.tsx +577 -0
- package/src/Snackbar/SnackbarProvider.tsx +32 -19
- package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +13 -10
- package/src/Snackbar/_stories/Snackbar.story.tsx +132 -39
- package/src/Snackbar/_stories/Snackbar.test.story.tsx +101 -35
- package/src/Snackbar/constants.ts +7 -0
- package/src/Snackbar/index.ts +1 -1
- package/src/Snackbar/useSnackbarAutoDismiss.ts +72 -0
- package/src/Snackbar/useSnackbarManager.ts +159 -0
- package/src/Typeahead/Typeahead.css +27 -8
- package/src/Typeahead/Typeahead.less +32 -9
- package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +5 -5
- package/src/Typeahead/_stories/Typeahead.test.story.tsx +0 -65
- package/src/index.ts +1 -1
- package/src/main.css +131 -61
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const emptyState = {
|
|
8
|
+
active: null,
|
|
9
|
+
activeHasRendered: false,
|
|
10
|
+
announcementKey: 0,
|
|
11
|
+
pending: null,
|
|
12
|
+
visible: false
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Coalesces creates before the first commit, then keeps active content until its exit finishes.
|
|
16
|
+
* Only the latest pending replacement is retained. Exited promotes pending or returns to idle.
|
|
17
|
+
* Instance IDs prevent stale exit callbacks from affecting a newer Snackbar.
|
|
18
|
+
*/
|
|
19
|
+
const snackbarManagerReducer = (state, action) => {
|
|
20
|
+
switch (action.type) {
|
|
21
|
+
case 'show':
|
|
22
|
+
if (!state.active || !state.activeHasRendered) {
|
|
23
|
+
// Batched creates collapse to the latest instance before anything has entered.
|
|
24
|
+
return {
|
|
25
|
+
active: action.instance,
|
|
26
|
+
activeHasRendered: false,
|
|
27
|
+
announcementKey: state.announcementKey + 1,
|
|
28
|
+
pending: null,
|
|
29
|
+
visible: true
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Keep the active content until it exits; newer creates replace only the pending instance.
|
|
33
|
+
return {
|
|
34
|
+
...state,
|
|
35
|
+
pending: action.instance,
|
|
36
|
+
visible: false
|
|
37
|
+
};
|
|
38
|
+
case 'rendered':
|
|
39
|
+
if (state.active?.id !== action.instanceId || state.activeHasRendered) {
|
|
40
|
+
return state;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
...state,
|
|
44
|
+
activeHasRendered: true
|
|
45
|
+
};
|
|
46
|
+
case 'dismiss':
|
|
47
|
+
case 'clear':
|
|
48
|
+
if (!state.active) {
|
|
49
|
+
return state;
|
|
50
|
+
}
|
|
51
|
+
if (!state.activeHasRendered) {
|
|
52
|
+
return {
|
|
53
|
+
...emptyState,
|
|
54
|
+
announcementKey: state.announcementKey
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Dismissal lets a queued replacement show next; clearing cancels it as well.
|
|
58
|
+
return {
|
|
59
|
+
...state,
|
|
60
|
+
pending: action.type === 'clear' ? null : state.pending,
|
|
61
|
+
visible: false
|
|
62
|
+
};
|
|
63
|
+
case 'exited':
|
|
64
|
+
// Ignore callbacks from an instance that has already been replaced.
|
|
65
|
+
if (state.active?.id !== action.instanceId) {
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
if (state.pending) {
|
|
69
|
+
return {
|
|
70
|
+
active: state.pending,
|
|
71
|
+
activeHasRendered: false,
|
|
72
|
+
announcementKey: state.announcementKey + 1,
|
|
73
|
+
pending: null,
|
|
74
|
+
visible: true
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...emptyState,
|
|
79
|
+
announcementKey: state.announcementKey
|
|
80
|
+
};
|
|
81
|
+
default:
|
|
82
|
+
return state;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Owns latest-wins replacement through reducer actions, separate from rendering and animation.
|
|
87
|
+
* Stable create/dismiss callbacks request state changes; the surface's onExited callback completes
|
|
88
|
+
* dismissal. The provider uses this state to mount/unmount the portal without a notification queue.
|
|
89
|
+
*/
|
|
90
|
+
const useSnackbarManager = () => {
|
|
91
|
+
const [state, dispatch] = React.useReducer(snackbarManagerReducer, emptyState);
|
|
92
|
+
const nextInstanceId = React.useRef(0);
|
|
93
|
+
const createSnackbar = React.useCallback(props => {
|
|
94
|
+
const {
|
|
95
|
+
text
|
|
96
|
+
} = props;
|
|
97
|
+
if (text == null || typeof text === 'boolean' || typeof text === 'string' && text.trim() === '') {
|
|
98
|
+
// A clear request must dismiss active and cancel pending, never create a blank replacement.
|
|
99
|
+
dispatch({
|
|
100
|
+
type: 'clear'
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
nextInstanceId.current += 1;
|
|
105
|
+
dispatch({
|
|
106
|
+
type: 'show',
|
|
107
|
+
instance: {
|
|
108
|
+
id: nextInstanceId.current,
|
|
109
|
+
props
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}, []);
|
|
113
|
+
const dismissSnackbar = React.useCallback(() => dispatch({
|
|
114
|
+
type: 'dismiss'
|
|
115
|
+
}), []);
|
|
116
|
+
const handleExited = React.useCallback(() => {
|
|
117
|
+
if (state.active) {
|
|
118
|
+
dispatch({
|
|
119
|
+
type: 'exited',
|
|
120
|
+
instanceId: state.active.id
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}, [state.active]);
|
|
124
|
+
React.useEffect(() => {
|
|
125
|
+
if (state.active && state.visible && !state.activeHasRendered) {
|
|
126
|
+
// Later creates can now wait for this instance's exit instead of coalescing before render.
|
|
127
|
+
dispatch({
|
|
128
|
+
type: 'rendered',
|
|
129
|
+
instanceId: state.active.id
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}, [state.active, state.activeHasRendered, state.visible]);
|
|
133
|
+
return {
|
|
134
|
+
active: state.active,
|
|
135
|
+
announcementKey: state.announcementKey,
|
|
136
|
+
createSnackbar,
|
|
137
|
+
dismissSnackbar,
|
|
138
|
+
handleExited,
|
|
139
|
+
visible: state.visible
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
exports.default = useSnackbarManager;
|
|
144
|
+
//# sourceMappingURL=useSnackbarManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSnackbarManager.js","sources":["../../src/Snackbar/useSnackbarManager.ts"],"sourcesContent":["import { useCallback, useEffect, useReducer, useRef } from 'react';\n\nimport type { SnackbarCreationProps } from './Snackbar.types';\n\ntype SnackbarInstance = {\n id: number;\n props: SnackbarCreationProps;\n};\n\ntype SnackbarManagerState = {\n /** The instance currently entering, visible or exiting. `null` means the provider is idle. */\n active: SnackbarInstance | null;\n /** Marks the active provider render as committed, not its entry animation as finished. */\n activeHasRendered: boolean;\n /** Changes when a new instance becomes active so repeated message text can be announced. */\n announcementKey: number;\n /** The latest replacement waiting for active to exit. `null` means no replacement is waiting. */\n pending: SnackbarInstance | null;\n /** Whether active should enter/stay visible; false requests its exit or indicates idle state. */\n visible: boolean;\n};\n\ntype SnackbarManagerAction =\n | { type: 'show'; instance: SnackbarInstance }\n | {\n /** Ends pre-render coalescing; subsequent creates must wait for the committed instance to exit. */\n type: 'rendered';\n instanceId: number;\n }\n | { type: 'dismiss' }\n | {\n /** Like `dismiss`, but also cancels a queued replacement. Sent when `createSnackbar` gets empty text. */\n type: 'clear';\n }\n | { type: 'exited'; instanceId: number };\n\nconst emptyState: SnackbarManagerState = {\n active: null,\n activeHasRendered: false,\n announcementKey: 0,\n pending: null,\n visible: false,\n};\n\n/**\n * Coalesces creates before the first commit, then keeps active content until its exit finishes.\n * Only the latest pending replacement is retained. Exited promotes pending or returns to idle.\n * Instance IDs prevent stale exit callbacks from affecting a newer Snackbar.\n */\nconst snackbarManagerReducer = (\n state: SnackbarManagerState,\n action: SnackbarManagerAction,\n): SnackbarManagerState => {\n switch (action.type) {\n case 'show':\n if (!state.active || !state.activeHasRendered) {\n // Batched creates collapse to the latest instance before anything has entered.\n return {\n active: action.instance,\n activeHasRendered: false,\n announcementKey: state.announcementKey + 1,\n pending: null,\n visible: true,\n };\n }\n\n // Keep the active content until it exits; newer creates replace only the pending instance.\n return { ...state, pending: action.instance, visible: false };\n case 'rendered':\n if (state.active?.id !== action.instanceId || state.activeHasRendered) {\n return state;\n }\n\n return { ...state, activeHasRendered: true };\n case 'dismiss':\n case 'clear':\n if (!state.active) {\n return state;\n }\n\n if (!state.activeHasRendered) {\n return { ...emptyState, announcementKey: state.announcementKey };\n }\n\n // Dismissal lets a queued replacement show next; clearing cancels it as well.\n return { ...state, pending: action.type === 'clear' ? null : state.pending, visible: false };\n case 'exited':\n // Ignore callbacks from an instance that has already been replaced.\n if (state.active?.id !== action.instanceId) {\n return state;\n }\n\n if (state.pending) {\n return {\n active: state.pending,\n activeHasRendered: false,\n announcementKey: state.announcementKey + 1,\n pending: null,\n visible: true,\n };\n }\n\n return { ...emptyState, announcementKey: state.announcementKey };\n default:\n return state;\n }\n};\n\n/**\n * Owns latest-wins replacement through reducer actions, separate from rendering and animation.\n * Stable create/dismiss callbacks request state changes; the surface's onExited callback completes\n * dismissal. The provider uses this state to mount/unmount the portal without a notification queue.\n */\nconst useSnackbarManager = () => {\n const [state, dispatch] = useReducer(snackbarManagerReducer, emptyState);\n const nextInstanceId = useRef(0);\n\n const createSnackbar = useCallback((props: SnackbarCreationProps) => {\n const { text } = props;\n if (\n text == null ||\n typeof text === 'boolean' ||\n (typeof text === 'string' && text.trim() === '')\n ) {\n // A clear request must dismiss active and cancel pending, never create a blank replacement.\n dispatch({ type: 'clear' });\n return;\n }\n\n nextInstanceId.current += 1;\n dispatch({ type: 'show', instance: { id: nextInstanceId.current, props } });\n }, []);\n\n const dismissSnackbar = useCallback(() => dispatch({ type: 'dismiss' }), []);\n\n const handleExited = useCallback(() => {\n if (state.active) {\n dispatch({ type: 'exited', instanceId: state.active.id });\n }\n }, [state.active]);\n\n useEffect(() => {\n if (state.active && state.visible && !state.activeHasRendered) {\n // Later creates can now wait for this instance's exit instead of coalescing before render.\n dispatch({ type: 'rendered', instanceId: state.active.id });\n }\n }, [state.active, state.activeHasRendered, state.visible]);\n\n return {\n active: state.active,\n announcementKey: state.announcementKey,\n createSnackbar,\n dismissSnackbar,\n handleExited,\n visible: state.visible,\n };\n};\n\nexport default useSnackbarManager;\n"],"names":["emptyState","active","activeHasRendered","announcementKey","pending","visible","snackbarManagerReducer","state","action","type","instance","id","instanceId","useSnackbarManager","dispatch","useReducer","nextInstanceId","useRef","createSnackbar","useCallback","props","text","trim","current","dismissSnackbar","handleExited","useEffect"],"mappings":";;;;;;AAoCA,MAAMA,UAAU,GAAyB;AACvCC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,iBAAiB,EAAE,KAAK;AACxBC,EAAAA,eAAe,EAAE,CAAC;AAClBC,EAAAA,OAAO,EAAE,IAAI;AACbC,EAAAA,OAAO,EAAE;CACV;AAED;;;;AAIG;AACH,MAAMC,sBAAsB,GAAGA,CAC7BC,KAA2B,EAC3BC,MAA6B,KACL;EACxB,QAAQA,MAAM,CAACC,IAAI;AACjB,IAAA,KAAK,MAAM;MACT,IAAI,CAACF,KAAK,CAACN,MAAM,IAAI,CAACM,KAAK,CAACL,iBAAiB,EAAE;AAC7C;QACA,OAAO;UACLD,MAAM,EAAEO,MAAM,CAACE,QAAQ;AACvBR,UAAAA,iBAAiB,EAAE,KAAK;AACxBC,UAAAA,eAAe,EAAEI,KAAK,CAACJ,eAAe,GAAG,CAAC;AAC1CC,UAAAA,OAAO,EAAE,IAAI;AACbC,UAAAA,OAAO,EAAE;SACV;AACH,MAAA;AAEA;MACA,OAAO;AAAE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,EAAE,CAACJ,KAAK,CAACN,MAAM,CAAC,CAAC;AAElByB,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAInB,KAAK,CAACN,MAAM,IAAIM,KAAK,CAACF,OAAO,IAAI,CAACE,KAAK,CAACL,iBAAiB,EAAE;AAC7D;AACAY,MAAAA,QAAQ,CAAC;AAAEL,QAAAA,IAAI,EAAE,UAAU;AAAEG,QAAAA,UAAU,EAAEL,KAAK,CAACN,MAAM,CAACU;AAAE,OAAE,CAAC;AAC7D,IAAA;AACF,EAAA,CAAC,EAAE,CAACJ,KAAK,CAACN,MAAM,EAAEM,KAAK,CAACL,iBAAiB,EAAEK,KAAK,CAACF,OAAO,CAAC,CAAC;EAE1D,OAAO;IACLJ,MAAM,EAAEM,KAAK,CAACN,MAAM;IACpBE,eAAe,EAAEI,KAAK,CAACJ,eAAe;IACtCe,cAAc;IACdM,eAAe;IACfC,YAAY;IACZpB,OAAO,EAAEE,KAAK,CAACF;GAChB;AACH;;"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useReducer, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const emptyState = {
|
|
4
|
+
active: null,
|
|
5
|
+
activeHasRendered: false,
|
|
6
|
+
announcementKey: 0,
|
|
7
|
+
pending: null,
|
|
8
|
+
visible: false
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Coalesces creates before the first commit, then keeps active content until its exit finishes.
|
|
12
|
+
* Only the latest pending replacement is retained. Exited promotes pending or returns to idle.
|
|
13
|
+
* Instance IDs prevent stale exit callbacks from affecting a newer Snackbar.
|
|
14
|
+
*/
|
|
15
|
+
const snackbarManagerReducer = (state, action) => {
|
|
16
|
+
switch (action.type) {
|
|
17
|
+
case 'show':
|
|
18
|
+
if (!state.active || !state.activeHasRendered) {
|
|
19
|
+
// Batched creates collapse to the latest instance before anything has entered.
|
|
20
|
+
return {
|
|
21
|
+
active: action.instance,
|
|
22
|
+
activeHasRendered: false,
|
|
23
|
+
announcementKey: state.announcementKey + 1,
|
|
24
|
+
pending: null,
|
|
25
|
+
visible: true
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Keep the active content until it exits; newer creates replace only the pending instance.
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
pending: action.instance,
|
|
32
|
+
visible: false
|
|
33
|
+
};
|
|
34
|
+
case 'rendered':
|
|
35
|
+
if (state.active?.id !== action.instanceId || state.activeHasRendered) {
|
|
36
|
+
return state;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
activeHasRendered: true
|
|
41
|
+
};
|
|
42
|
+
case 'dismiss':
|
|
43
|
+
case 'clear':
|
|
44
|
+
if (!state.active) {
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
if (!state.activeHasRendered) {
|
|
48
|
+
return {
|
|
49
|
+
...emptyState,
|
|
50
|
+
announcementKey: state.announcementKey
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Dismissal lets a queued replacement show next; clearing cancels it as well.
|
|
54
|
+
return {
|
|
55
|
+
...state,
|
|
56
|
+
pending: action.type === 'clear' ? null : state.pending,
|
|
57
|
+
visible: false
|
|
58
|
+
};
|
|
59
|
+
case 'exited':
|
|
60
|
+
// Ignore callbacks from an instance that has already been replaced.
|
|
61
|
+
if (state.active?.id !== action.instanceId) {
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
if (state.pending) {
|
|
65
|
+
return {
|
|
66
|
+
active: state.pending,
|
|
67
|
+
activeHasRendered: false,
|
|
68
|
+
announcementKey: state.announcementKey + 1,
|
|
69
|
+
pending: null,
|
|
70
|
+
visible: true
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
...emptyState,
|
|
75
|
+
announcementKey: state.announcementKey
|
|
76
|
+
};
|
|
77
|
+
default:
|
|
78
|
+
return state;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Owns latest-wins replacement through reducer actions, separate from rendering and animation.
|
|
83
|
+
* Stable create/dismiss callbacks request state changes; the surface's onExited callback completes
|
|
84
|
+
* dismissal. The provider uses this state to mount/unmount the portal without a notification queue.
|
|
85
|
+
*/
|
|
86
|
+
const useSnackbarManager = () => {
|
|
87
|
+
const [state, dispatch] = useReducer(snackbarManagerReducer, emptyState);
|
|
88
|
+
const nextInstanceId = useRef(0);
|
|
89
|
+
const createSnackbar = useCallback(props => {
|
|
90
|
+
const {
|
|
91
|
+
text
|
|
92
|
+
} = props;
|
|
93
|
+
if (text == null || typeof text === 'boolean' || typeof text === 'string' && text.trim() === '') {
|
|
94
|
+
// A clear request must dismiss active and cancel pending, never create a blank replacement.
|
|
95
|
+
dispatch({
|
|
96
|
+
type: 'clear'
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
nextInstanceId.current += 1;
|
|
101
|
+
dispatch({
|
|
102
|
+
type: 'show',
|
|
103
|
+
instance: {
|
|
104
|
+
id: nextInstanceId.current,
|
|
105
|
+
props
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}, []);
|
|
109
|
+
const dismissSnackbar = useCallback(() => dispatch({
|
|
110
|
+
type: 'dismiss'
|
|
111
|
+
}), []);
|
|
112
|
+
const handleExited = useCallback(() => {
|
|
113
|
+
if (state.active) {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: 'exited',
|
|
116
|
+
instanceId: state.active.id
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}, [state.active]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (state.active && state.visible && !state.activeHasRendered) {
|
|
122
|
+
// Later creates can now wait for this instance's exit instead of coalescing before render.
|
|
123
|
+
dispatch({
|
|
124
|
+
type: 'rendered',
|
|
125
|
+
instanceId: state.active.id
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}, [state.active, state.activeHasRendered, state.visible]);
|
|
129
|
+
return {
|
|
130
|
+
active: state.active,
|
|
131
|
+
announcementKey: state.announcementKey,
|
|
132
|
+
createSnackbar,
|
|
133
|
+
dismissSnackbar,
|
|
134
|
+
handleExited,
|
|
135
|
+
visible: state.visible
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { useSnackbarManager as default };
|
|
140
|
+
//# sourceMappingURL=useSnackbarManager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSnackbarManager.mjs","sources":["../../src/Snackbar/useSnackbarManager.ts"],"sourcesContent":["import { useCallback, useEffect, useReducer, useRef } from 'react';\n\nimport type { SnackbarCreationProps } from './Snackbar.types';\n\ntype SnackbarInstance = {\n id: number;\n props: SnackbarCreationProps;\n};\n\ntype SnackbarManagerState = {\n /** The instance currently entering, visible or exiting. `null` means the provider is idle. */\n active: SnackbarInstance | null;\n /** Marks the active provider render as committed, not its entry animation as finished. */\n activeHasRendered: boolean;\n /** Changes when a new instance becomes active so repeated message text can be announced. */\n announcementKey: number;\n /** The latest replacement waiting for active to exit. `null` means no replacement is waiting. */\n pending: SnackbarInstance | null;\n /** Whether active should enter/stay visible; false requests its exit or indicates idle state. */\n visible: boolean;\n};\n\ntype SnackbarManagerAction =\n | { type: 'show'; instance: SnackbarInstance }\n | {\n /** Ends pre-render coalescing; subsequent creates must wait for the committed instance to exit. */\n type: 'rendered';\n instanceId: number;\n }\n | { type: 'dismiss' }\n | {\n /** Like `dismiss`, but also cancels a queued replacement. Sent when `createSnackbar` gets empty text. */\n type: 'clear';\n }\n | { type: 'exited'; instanceId: number };\n\nconst emptyState: SnackbarManagerState = {\n active: null,\n activeHasRendered: false,\n announcementKey: 0,\n pending: null,\n visible: false,\n};\n\n/**\n * Coalesces creates before the first commit, then keeps active content until its exit finishes.\n * Only the latest pending replacement is retained. Exited promotes pending or returns to idle.\n * Instance IDs prevent stale exit callbacks from affecting a newer Snackbar.\n */\nconst snackbarManagerReducer = (\n state: SnackbarManagerState,\n action: SnackbarManagerAction,\n): SnackbarManagerState => {\n switch (action.type) {\n case 'show':\n if (!state.active || !state.activeHasRendered) {\n // Batched creates collapse to the latest instance before anything has entered.\n return {\n active: action.instance,\n activeHasRendered: false,\n announcementKey: state.announcementKey + 1,\n pending: null,\n visible: true,\n };\n }\n\n // Keep the active content until it exits; newer creates replace only the pending instance.\n return { ...state, pending: action.instance, visible: false };\n case 'rendered':\n if (state.active?.id !== action.instanceId || state.activeHasRendered) {\n return state;\n }\n\n return { ...state, activeHasRendered: true };\n case 'dismiss':\n case 'clear':\n if (!state.active) {\n return state;\n }\n\n if (!state.activeHasRendered) {\n return { ...emptyState, announcementKey: state.announcementKey };\n }\n\n // Dismissal lets a queued replacement show next; clearing cancels it as well.\n return { ...state, pending: action.type === 'clear' ? null : state.pending, visible: false };\n case 'exited':\n // Ignore callbacks from an instance that has already been replaced.\n if (state.active?.id !== action.instanceId) {\n return state;\n }\n\n if (state.pending) {\n return {\n active: state.pending,\n activeHasRendered: false,\n announcementKey: state.announcementKey + 1,\n pending: null,\n visible: true,\n };\n }\n\n return { ...emptyState, announcementKey: state.announcementKey };\n default:\n return state;\n }\n};\n\n/**\n * Owns latest-wins replacement through reducer actions, separate from rendering and animation.\n * Stable create/dismiss callbacks request state changes; the surface's onExited callback completes\n * dismissal. The provider uses this state to mount/unmount the portal without a notification queue.\n */\nconst useSnackbarManager = () => {\n const [state, dispatch] = useReducer(snackbarManagerReducer, emptyState);\n const nextInstanceId = useRef(0);\n\n const createSnackbar = useCallback((props: SnackbarCreationProps) => {\n const { text } = props;\n if (\n text == null ||\n typeof text === 'boolean' ||\n (typeof text === 'string' && text.trim() === '')\n ) {\n // A clear request must dismiss active and cancel pending, never create a blank replacement.\n dispatch({ type: 'clear' });\n return;\n }\n\n nextInstanceId.current += 1;\n dispatch({ type: 'show', instance: { id: nextInstanceId.current, props } });\n }, []);\n\n const dismissSnackbar = useCallback(() => dispatch({ type: 'dismiss' }), []);\n\n const handleExited = useCallback(() => {\n if (state.active) {\n dispatch({ type: 'exited', instanceId: state.active.id });\n }\n }, [state.active]);\n\n useEffect(() => {\n if (state.active && state.visible && !state.activeHasRendered) {\n // Later creates can now wait for this instance's exit instead of coalescing before render.\n dispatch({ type: 'rendered', instanceId: state.active.id });\n }\n }, [state.active, state.activeHasRendered, state.visible]);\n\n return {\n active: state.active,\n announcementKey: state.announcementKey,\n createSnackbar,\n dismissSnackbar,\n handleExited,\n visible: state.visible,\n };\n};\n\nexport default useSnackbarManager;\n"],"names":["emptyState","active","activeHasRendered","announcementKey","pending","visible","snackbarManagerReducer","state","action","type","instance","id","instanceId","useSnackbarManager","dispatch","useReducer","nextInstanceId","useRef","createSnackbar","useCallback","props","text","trim","current","dismissSnackbar","handleExited","useEffect"],"mappings":";;AAoCA,MAAMA,UAAU,GAAyB;AACvCC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,iBAAiB,EAAE,KAAK;AACxBC,EAAAA,eAAe,EAAE,CAAC;AAClBC,EAAAA,OAAO,EAAE,IAAI;AACbC,EAAAA,OAAO,EAAE;CACV;AAED;;;;AAIG;AACH,MAAMC,sBAAsB,GAAGA,CAC7BC,KAA2B,EAC3BC,MAA6B,KACL;EACxB,QAAQA,MAAM,CAACC,IAAI;AACjB,IAAA,KAAK,MAAM;MACT,IAAI,CAACF,KAAK,CAACN,MAAM,IAAI,CAACM,KAAK,CAACL,iBAAiB,EAAE;AAC7C;QACA,OAAO;UACLD,MAAM,EAAEO,MAAM,CAACE,QAAQ;AACvBR,UAAAA,iBAAiB,EAAE,KAAK;AACxBC,UAAAA,eAAe,EAAEI,KAAK,CAACJ,eAAe,GAAG,CAAC;AAC1CC,UAAAA,OAAO,EAAE,IAAI;AACbC,UAAAA,OAAO,EAAE;SACV;AACH,MAAA;AAEA;MACA,OAAO;AAAE,QAAA,GAAGE,KAAK;QAAEH,OAAO,EAAEI,MAAM,CAACE,QAAQ;AAAEL,QAAAA,OAAO,EAAE;OAAO;AAC/D,I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,MAAM,IAAIM,KAAK,CAACF,OAAO,IAAI,CAACE,KAAK,CAACL,iBAAiB,EAAE;AAC7D;AACAY,MAAAA,QAAQ,CAAC;AAAEL,QAAAA,IAAI,EAAE,UAAU;AAAEG,QAAAA,UAAU,EAAEL,KAAK,CAACN,MAAM,CAACU;AAAE,OAAE,CAAC;AAC7D,IAAA;AACF,EAAA,CAAC,EAAE,CAACJ,KAAK,CAACN,MAAM,EAAEM,KAAK,CAACL,iBAAiB,EAAEK,KAAK,CAACF,OAAO,CAAC,CAAC;EAE1D,OAAO;IACLJ,MAAM,EAAEM,KAAK,CAACN,MAAM;IACpBE,eAAe,EAAEI,KAAK,CAACJ,eAAe;IACtCe,cAAc;IACdM,eAAe;IACfC,YAAY;IACZpB,OAAO,EAAEE,KAAK,CAACF;GAChB;AACH;;"}
|
|
@@ -62,8 +62,10 @@ class TypeaheadInput extends React.Component {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
recalculateWidth = () => {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
requestAnimationFrame(() => {
|
|
66
|
+
this.setState({
|
|
67
|
+
inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10)
|
|
68
|
+
});
|
|
67
69
|
});
|
|
68
70
|
};
|
|
69
71
|
renderInput = isRTL => {
|
|
@@ -127,9 +129,7 @@ class TypeaheadInput extends React.Component {
|
|
|
127
129
|
children: direction$1 => {
|
|
128
130
|
const isRTL = direction$1 === direction.Direction.RTL;
|
|
129
131
|
return multiple ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
130
|
-
className:
|
|
131
|
-
'typeahead__input-container--scrollable': maxHeight != null
|
|
132
|
-
}),
|
|
132
|
+
className: "form-control typeahead__input-container",
|
|
133
133
|
style: {
|
|
134
134
|
maxHeight
|
|
135
135
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeaheadInput.js","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\nimport { Direction } from '../../common';\nimport { DirectionContext } from '../../Provider/Direction';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<\n TypeaheadProps<T>,\n 'id' | 'name' | 'autoFocus' | 'disabled' | 'multiple' | 'placeholder' | 'maxHeight'\n>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n this.setState({\n
|
|
1
|
+
{"version":3,"file":"TypeaheadInput.js","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\nimport { Direction } from '../../common';\nimport { DirectionContext } from '../../Provider/Direction';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<\n TypeaheadProps<T>,\n 'id' | 'name' | 'autoFocus' | 'disabled' | 'multiple' | 'placeholder' | 'maxHeight'\n>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n requestAnimationFrame(() => {\n this.setState({\n inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10),\n });\n });\n };\n\n renderInput = (isRTL: boolean) => {\n const {\n typeaheadId,\n autoFocus,\n disabled,\n multiple,\n name,\n dropdownOpen,\n placeholder,\n selected,\n value,\n onChange,\n onKeyDown,\n onFocus,\n onPaste,\n autoComplete,\n ariaActivedescendant,\n } = this.props;\n const { inputWidth } = this.state;\n\n const hasPlaceholder = !multiple || selected.length === 0;\n return (\n <Input\n ref={this.inputRef}\n dir={isRTL ? 'rtl' : 'auto'}\n className={clsx(multiple && 'typeahead__input')}\n name={name}\n id={`input-${typeaheadId}`}\n aria-activedescendant={ariaActivedescendant}\n autoFocus={autoFocus}\n disabled={disabled}\n placeholder={hasPlaceholder ? placeholder : ''}\n aria-autocomplete=\"list\"\n aria-expanded={dropdownOpen}\n aria-haspopup=\"listbox\"\n aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}\n autoComplete={autoComplete}\n role=\"combobox\"\n value={value}\n style={multiple && selected.length > 0 ? { width: inputWidth } : {}}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onClick={onFocus}\n onFocus={onFocus}\n onPaste={onPaste}\n />\n );\n };\n\n render() {\n const { multiple, selected, value, maxHeight, renderChip } = this.props;\n\n return (\n <DirectionContext.Consumer>\n {(direction) => {\n const isRTL = direction === Direction.RTL;\n\n return multiple ? (\n <div\n className=\"form-control typeahead__input-container\"\n style={{ maxHeight }}\n onClick={() => {\n this.inputRef.current?.focus();\n }}\n >\n <div className=\"typeahead__input-wrapper\">\n {selected && selected.map((chip, idx) => renderChip(chip, idx))}\n\n {this.renderInput(isRTL)}\n <div className=\"typeahead__input-aligner\" />\n </div>\n <div ref={this.sizerRef} className=\"sizer form-control typeahead__input\">\n {value}\n </div>\n </div>\n ) : (\n this.renderInput(isRTL)\n );\n }}\n </DirectionContext.Consumer>\n );\n }\n}\n"],"names":["DEFAULT_INPUT_MIN_WIDTH","TypeaheadInput","Component","inputRef","createRef","sizerRef","constructor","props","state","inputWidth","keyboardFocusedOptionIndex","componentDidMount","autoFocus","setTimeout","current","focus","componentDidUpdate","previousProps","value","multiple","recalculateWidth","requestAnimationFrame","setState","Math","max","scrollWidth","renderInput","isRTL","typeaheadId","disabled","name","dropdownOpen","placeholder","selected","onChange","onKeyDown","onFocus","onPaste","autoComplete","ariaActivedescendant","hasPlaceholder","length","_jsx","Input","ref","dir","className","clsx","id","undefined","role","style","width","onClick","render","maxHeight","renderChip","DirectionContext","Consumer","children","direction","Direction","RTL","_jsxs","map","chip","idx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AASA,MAAMA,uBAAuB,GAAG,EAAE;AAwBpB,MAAOC,cAAkB,SAAQC,eAG9C,CAAA;EACCC,QAAQ,gBAAGC,eAAS,EAAoB;EACxCC,QAAQ,gBAAGD,eAAS,EAAkB;EAEtCE,WAAAA,CAAYC,KAA6B,EAAA;IACvC,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;AACXC,MAAAA,UAAU,EAAET,uBAAuB;AACnCU,MAAAA,0BAA0B,EAAE;KAC7B;AACH,EAAA;AAEAC,EAAAA,iBAAiBA,GAAA;IACf,MAAM;AAAEC,MAAAA;KAAW,GAAG,IAAI,CAACL,KAAK;AAChC,IAAA,IAAIK,SAAS,EAAE;AACb;AACAC,MAAAA,UAAU,CAAC,MAAK;AACd,QAAA,IAAI,CAACV,QAAQ,CAACW,OAAO,EAAEC,KAAK,EAAE;AAChC,MAAA,CAAC,CAAC;AACJ,IAAA;AACF,EAAA;EAEAC,kBAAkBA,CAACC,aAAqC,EAAA;AACtD,IAAA,IAAIA,aAAa,CAACC,KAAK,KAAK,IAAI,CAACX,KAAK,CAACW,KAAK,IAAI,IAAI,CAACX,KAA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,0BAA0B;YAAAa,QAAA,EAAA,CACtC1B,QAAQ,IAAIA,QAAQ,CAAC+B,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAKV,UAAU,CAACS,IAAI,EAAEC,GAAG,CAAC,CAAC,EAE9D,IAAI,CAACxC,WAAW,CAACC,KAAK,CAAC,eACxBe,cAAA,CAAA,KAAA,EAAA;AAAKI,cAAAA,SAAS,EAAC;AAA0B,aAAA,CAC3C;WAAK,CACL,eAAAJ,cAAA,CAAA,KAAA,EAAA;YAAKE,GAAG,EAAE,IAAI,CAACvC,QAAS;AAACyC,YAAAA,SAAS,EAAC,qCAAqC;AAAAa,YAAAA,QAAA,EACrEzC;AAAK,WACH,CACP;AAAA,SAAK,CAAC,GAEN,IAAI,CAACQ,WAAW,CAACC,KAAK,CACvB;AACH,MAAA;AAAC,KACwB,CAAC;AAEhC,EAAA;AACD;;"}
|
|
@@ -58,8 +58,10 @@ class TypeaheadInput extends Component {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
recalculateWidth = () => {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
requestAnimationFrame(() => {
|
|
62
|
+
this.setState({
|
|
63
|
+
inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10)
|
|
64
|
+
});
|
|
63
65
|
});
|
|
64
66
|
};
|
|
65
67
|
renderInput = isRTL => {
|
|
@@ -123,9 +125,7 @@ class TypeaheadInput extends Component {
|
|
|
123
125
|
children: direction => {
|
|
124
126
|
const isRTL = direction === Direction.RTL;
|
|
125
127
|
return multiple ? /*#__PURE__*/jsxs("div", {
|
|
126
|
-
className:
|
|
127
|
-
'typeahead__input-container--scrollable': maxHeight != null
|
|
128
|
-
}),
|
|
128
|
+
className: "form-control typeahead__input-container",
|
|
129
129
|
style: {
|
|
130
130
|
maxHeight
|
|
131
131
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeaheadInput.mjs","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\nimport { Direction } from '../../common';\nimport { DirectionContext } from '../../Provider/Direction';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<\n TypeaheadProps<T>,\n 'id' | 'name' | 'autoFocus' | 'disabled' | 'multiple' | 'placeholder' | 'maxHeight'\n>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n this.setState({\n
|
|
1
|
+
{"version":3,"file":"TypeaheadInput.mjs","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\nimport { Direction } from '../../common';\nimport { DirectionContext } from '../../Provider/Direction';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<\n TypeaheadProps<T>,\n 'id' | 'name' | 'autoFocus' | 'disabled' | 'multiple' | 'placeholder' | 'maxHeight'\n>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n requestAnimationFrame(() => {\n this.setState({\n inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10),\n });\n });\n };\n\n renderInput = (isRTL: boolean) => {\n const {\n typeaheadId,\n autoFocus,\n disabled,\n multiple,\n name,\n dropdownOpen,\n placeholder,\n selected,\n value,\n onChange,\n onKeyDown,\n onFocus,\n onPaste,\n autoComplete,\n ariaActivedescendant,\n } = this.props;\n const { inputWidth } = this.state;\n\n const hasPlaceholder = !multiple || selected.length === 0;\n return (\n <Input\n ref={this.inputRef}\n dir={isRTL ? 'rtl' : 'auto'}\n className={clsx(multiple && 'typeahead__input')}\n name={name}\n id={`input-${typeaheadId}`}\n aria-activedescendant={ariaActivedescendant}\n autoFocus={autoFocus}\n disabled={disabled}\n placeholder={hasPlaceholder ? placeholder : ''}\n aria-autocomplete=\"list\"\n aria-expanded={dropdownOpen}\n aria-haspopup=\"listbox\"\n aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}\n autoComplete={autoComplete}\n role=\"combobox\"\n value={value}\n style={multiple && selected.length > 0 ? { width: inputWidth } : {}}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onClick={onFocus}\n onFocus={onFocus}\n onPaste={onPaste}\n />\n );\n };\n\n render() {\n const { multiple, selected, value, maxHeight, renderChip } = this.props;\n\n return (\n <DirectionContext.Consumer>\n {(direction) => {\n const isRTL = direction === Direction.RTL;\n\n return multiple ? (\n <div\n className=\"form-control typeahead__input-container\"\n style={{ maxHeight }}\n onClick={() => {\n this.inputRef.current?.focus();\n }}\n >\n <div className=\"typeahead__input-wrapper\">\n {selected && selected.map((chip, idx) => renderChip(chip, idx))}\n\n {this.renderInput(isRTL)}\n <div className=\"typeahead__input-aligner\" />\n </div>\n <div ref={this.sizerRef} className=\"sizer form-control typeahead__input\">\n {value}\n </div>\n </div>\n ) : (\n this.renderInput(isRTL)\n );\n }}\n </DirectionContext.Consumer>\n );\n }\n}\n"],"names":["DEFAULT_INPUT_MIN_WIDTH","TypeaheadInput","Component","inputRef","createRef","sizerRef","constructor","props","state","inputWidth","keyboardFocusedOptionIndex","componentDidMount","autoFocus","setTimeout","current","focus","componentDidUpdate","previousProps","value","multiple","recalculateWidth","requestAnimationFrame","setState","Math","max","scrollWidth","renderInput","isRTL","typeaheadId","disabled","name","dropdownOpen","placeholder","selected","onChange","onKeyDown","onFocus","onPaste","autoComplete","ariaActivedescendant","hasPlaceholder","length","_jsx","Input","ref","dir","className","clsx","id","undefined","role","style","width","onClick","render","maxHeight","renderChip","DirectionContext","Consumer","children","direction","Direction","RTL","_jsxs","map","chip","idx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AASA,MAAMA,uBAAuB,GAAG,EAAE;AAwBpB,MAAOC,cAAkB,SAAQC,SAG9C,CAAA;EACCC,QAAQ,gBAAGC,SAAS,EAAoB;EACxCC,QAAQ,gBAAGD,SAAS,EAAkB;EAEtCE,WAAAA,CAAYC,KAA6B,EAAA;IACvC,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;AACXC,MAAAA,UAAU,EAAET,uBAAuB;AACnCU,MAAAA,0BAA0B,EAAE;KAC7B;AACH,EAAA;AAEAC,EAAAA,iBAAiBA,GAAA;IACf,MAAM;AAAEC,MAAAA;KAAW,GAAG,IAAI,CAACL,KAAK;AAChC,IAAA,IAAIK,SAAS,EAAE;AACb;AACAC,MAAAA,UAAU,CAAC,MAAK;AACd,QAAA,IAAI,CAACV,QAAQ,CAACW,OAAO,EAAEC,KAAK,EAAE;AAChC,MAAA,CAAC,CAAC;AACJ,IAAA;AACF,EAAA;EAEAC,kBAAkBA,CAACC,aAAqC,EAAA;AACtD,IAAA,IAAIA,aAAa,CAACC,KAAK,KAAK,IAAI,CAACX,KAAK,CAACW,KAAK,IAAI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