@seamly/web-ui 23.0.0-alpha.2 → 23.0.0-alpha.3
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/dist/lib/components.js +58 -75
- package/build/dist/lib/components.js.map +1 -1
- package/build/dist/lib/components.min.js +1 -1
- package/build/dist/lib/components.min.js.map +1 -1
- package/build/dist/lib/hooks.js +55 -72
- package/build/dist/lib/hooks.js.map +1 -1
- package/build/dist/lib/hooks.min.js +1 -1
- package/build/dist/lib/hooks.min.js.map +1 -1
- package/build/dist/lib/index.debug.js +8 -8
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.map +1 -1
- package/build/dist/lib/index.js +42 -63
- package/build/dist/lib/index.js.map +1 -1
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.map +1 -1
- package/build/dist/lib/standalone.js +52 -74
- package/build/dist/lib/standalone.js.map +1 -1
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.map +1 -1
- package/build/dist/lib/style-guide.js +51 -68
- package/build/dist/lib/style-guide.js.map +1 -1
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/style-guide.min.js.map +1 -1
- package/build/dist/lib/utils.js +63 -99
- package/build/dist/lib/utils.js.map +1 -1
- package/build/dist/lib/utils.min.js +1 -1
- package/build/dist/lib/utils.min.js.map +1 -1
- package/package.json +1 -1
- package/src/javascripts/api/index.ts +2 -18
- package/src/javascripts/domains/config/actions.ts +3 -0
- package/src/javascripts/domains/config/slice.ts +3 -0
- package/src/javascripts/domains/i18n/slice.ts +1 -1
- package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx +1 -1
- package/src/javascripts/domains/translations/hooks.ts +1 -1
- package/src/javascripts/domains/translations/middleware.ts +4 -10
- package/src/javascripts/domains/translations/slice.ts +2 -2
- package/src/javascripts/style-guide/states.js +4 -0
- package/src/javascripts/style-guide/style-guide-engine.js +1 -1
package/package.json
CHANGED
|
@@ -162,7 +162,7 @@ export class API {
|
|
|
162
162
|
}) {
|
|
163
163
|
this.store = objectStore(
|
|
164
164
|
`${namespace}.connection${
|
|
165
|
-
context.
|
|
165
|
+
context.userLocale ? `.${context.userLocale}` : ''
|
|
166
166
|
}`,
|
|
167
167
|
config.storageProvider || sessionStorageProvider,
|
|
168
168
|
)
|
|
@@ -625,23 +625,7 @@ export class API {
|
|
|
625
625
|
return
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
|
|
629
|
-
const { contentLocale: _, ...restPayload } = payload
|
|
630
|
-
|
|
631
|
-
const localContentLocale = this.#config.context?.contentLocale
|
|
632
|
-
const localUserLocale = this.#config.context?.userLocale
|
|
633
|
-
|
|
634
|
-
this.send(
|
|
635
|
-
'context',
|
|
636
|
-
{
|
|
637
|
-
// Only send locale if explicitly set in the config.
|
|
638
|
-
...(localContentLocale
|
|
639
|
-
? { contentLocale: localContentLocale, userLocale: localUserLocale }
|
|
640
|
-
: {}),
|
|
641
|
-
...restPayload,
|
|
642
|
-
},
|
|
643
|
-
false,
|
|
644
|
-
)
|
|
628
|
+
this.send('context', payload, false)
|
|
645
629
|
}
|
|
646
630
|
|
|
647
631
|
getEnvironment() {
|
|
@@ -3,6 +3,7 @@ import { Config, ConfigResponse } from 'config.types'
|
|
|
3
3
|
import { ThunkAPI } from 'domains/redux/redux.types'
|
|
4
4
|
|
|
5
5
|
type InitializeConfigReturn = ConfigResponse & {
|
|
6
|
+
defaultUserLocale: ConfigResponse['defaultLocale']
|
|
6
7
|
defaultContentLocale: ConfigResponse['defaultLocale']
|
|
7
8
|
connectWhenInView: Config['connectWhenInView']
|
|
8
9
|
}
|
|
@@ -24,6 +25,7 @@ export const initializeConfig = createAsyncThunk<
|
|
|
24
25
|
startChatIcon,
|
|
25
26
|
} = await api.getConfig()
|
|
26
27
|
|
|
28
|
+
const defaultUserLocale = config?.context?.userLocale || defaultLocale
|
|
27
29
|
const defaultContentLocale =
|
|
28
30
|
config?.context?.contentLocale || defaultLocale
|
|
29
31
|
const { connectWhenInView } = config
|
|
@@ -35,6 +37,7 @@ export const initializeConfig = createAsyncThunk<
|
|
|
35
37
|
agentParticipant,
|
|
36
38
|
userParticipant,
|
|
37
39
|
startChatIcon,
|
|
40
|
+
defaultUserLocale,
|
|
38
41
|
defaultContentLocale,
|
|
39
42
|
connectWhenInView,
|
|
40
43
|
}
|
|
@@ -104,6 +104,7 @@ export const configSlice = createSlice({
|
|
|
104
104
|
agentParticipant,
|
|
105
105
|
userParticipant,
|
|
106
106
|
startChatIcon,
|
|
107
|
+
defaultUserLocale,
|
|
107
108
|
defaultContentLocale,
|
|
108
109
|
},
|
|
109
110
|
},
|
|
@@ -114,7 +115,9 @@ export const configSlice = createSlice({
|
|
|
114
115
|
payload,
|
|
115
116
|
}))
|
|
116
117
|
|
|
118
|
+
state.context.userLocale = defaultUserLocale
|
|
117
119
|
state.context.contentLocale = defaultContentLocale
|
|
120
|
+
|
|
118
121
|
state.agentParticipant = agentParticipant
|
|
119
122
|
state.userParticipant = userParticipant
|
|
120
123
|
state.startChatIcon = startChatIcon
|
|
@@ -49,7 +49,7 @@ export const i18nSlice = createSlice({
|
|
|
49
49
|
builder
|
|
50
50
|
.addCase(resetApp.pending, () => initialState)
|
|
51
51
|
.addCase(initializeConfig.fulfilled, (state, { payload }) => {
|
|
52
|
-
state.initialLocale = payload.
|
|
52
|
+
state.initialLocale = payload.defaultUserLocale
|
|
53
53
|
})
|
|
54
54
|
.addCase(setLocale.pending, (state) => {
|
|
55
55
|
state.isLoading = true
|
package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx
CHANGED
|
@@ -29,7 +29,7 @@ const TranslationOptions: FC<TranslationOptionsProps> = ({
|
|
|
29
29
|
const focusSkiplinkTarget = useSkiplinkTargetFocusing()
|
|
30
30
|
|
|
31
31
|
const handleChange = (locale: Language['locale']) => () => {
|
|
32
|
-
if (locale === currentLocale ||
|
|
32
|
+
if (locale === currentLocale || contentLocale === locale) {
|
|
33
33
|
disableTranslations()
|
|
34
34
|
} else {
|
|
35
35
|
enableTranslations(locale)
|
|
@@ -37,7 +37,7 @@ export function useTranslations() {
|
|
|
37
37
|
)
|
|
38
38
|
const disableTranslations = useCallback(() => {
|
|
39
39
|
sendContext({
|
|
40
|
-
userLocale: config.context.
|
|
40
|
+
userLocale: config.context.contentLocale,
|
|
41
41
|
})
|
|
42
42
|
dispatch(disableTranslation())
|
|
43
43
|
}, [config.context, dispatch, sendContext])
|
|
@@ -27,15 +27,15 @@ const createI18nMiddleware: Middleware<{}, RootState, any> = ({
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (initializeConfig.fulfilled.match(action)) {
|
|
30
|
-
if (action.payload.
|
|
31
|
-
dispatch(setLocale(action.payload.
|
|
30
|
+
if (action.payload.defaultUserLocale) {
|
|
31
|
+
dispatch(setLocale(action.payload.defaultUserLocale))
|
|
32
32
|
return result
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (initializeApp.fulfilled.match(action)) {
|
|
37
|
-
if (action.payload.
|
|
38
|
-
dispatch(setLocale(action.payload.
|
|
37
|
+
if (action.payload.userLocale) {
|
|
38
|
+
dispatch(setLocale(action.payload.userLocale))
|
|
39
39
|
}
|
|
40
40
|
return result
|
|
41
41
|
}
|
|
@@ -53,12 +53,6 @@ const createI18nMiddleware: Middleware<{}, RootState, any> = ({
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (disableTranslation.match(action)) {
|
|
57
|
-
const initialLocale = selectInitialLocale(getState())
|
|
58
|
-
dispatch(setLocale(initialLocale))
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
56
|
return result
|
|
63
57
|
}
|
|
64
58
|
}
|
|
@@ -102,8 +102,8 @@ export const translationSlice = createSlice({
|
|
|
102
102
|
|
|
103
103
|
state.isAvailable = feature.enabled === true
|
|
104
104
|
state.languages = [...feature.languages].sort((a, b) => {
|
|
105
|
-
if (a.locale === payload.
|
|
106
|
-
if (b.locale === payload.
|
|
105
|
+
if (a.locale === payload.defaultUserLocale) return -1
|
|
106
|
+
if (b.locale === payload.defaultUserLocale) return 1
|
|
107
107
|
|
|
108
108
|
return a.nativeName.localeCompare(b.nativeName, undefined, {
|
|
109
109
|
sensitivity: 'base',
|
|
@@ -1602,6 +1602,7 @@ const standardState = {
|
|
|
1602
1602
|
context: {
|
|
1603
1603
|
...baseState.context,
|
|
1604
1604
|
contentLocale: 'nl',
|
|
1605
|
+
userLocale: 'en',
|
|
1605
1606
|
},
|
|
1606
1607
|
},
|
|
1607
1608
|
translations: {
|
|
@@ -1663,6 +1664,7 @@ const standardState = {
|
|
|
1663
1664
|
context: {
|
|
1664
1665
|
...baseState.context,
|
|
1665
1666
|
contentLocale: 'nl',
|
|
1667
|
+
userLocale: 'en',
|
|
1666
1668
|
},
|
|
1667
1669
|
},
|
|
1668
1670
|
translations: {
|
|
@@ -1795,6 +1797,7 @@ const standardState = {
|
|
|
1795
1797
|
showDisclaimer: true,
|
|
1796
1798
|
context: {
|
|
1797
1799
|
contentLocale: 'nl-informal',
|
|
1800
|
+
userLocale: 'en-GB',
|
|
1798
1801
|
},
|
|
1799
1802
|
},
|
|
1800
1803
|
translations: {
|
|
@@ -1824,6 +1827,7 @@ const standardState = {
|
|
|
1824
1827
|
showDisclaimer: true,
|
|
1825
1828
|
context: {
|
|
1826
1829
|
contentLocale: 'nl-informal',
|
|
1830
|
+
userLocale: 'en-GB',
|
|
1827
1831
|
},
|
|
1828
1832
|
},
|
|
1829
1833
|
translations: {
|
|
@@ -24,7 +24,7 @@ class SeamlyStyleGuideInstance extends Engine {
|
|
|
24
24
|
translations: `/client/${this.config.api.key}/translations/{version}/{locale}.json`,
|
|
25
25
|
}
|
|
26
26
|
const translations = await api.getTranslations(
|
|
27
|
-
this.config.context.
|
|
27
|
+
this.config.context.userLocale || 'en-GB',
|
|
28
28
|
)
|
|
29
29
|
const { agentParticipant, userParticipant } = await api.getConfig()
|
|
30
30
|
const participants = [
|