diff --git a/.changeset/free-eggs-fold.md b/.changeset/free-eggs-fold.md new file mode 100644 index 0000000..d05dbb6 --- /dev/null +++ b/.changeset/free-eggs-fold.md @@ -0,0 +1,5 @@ +--- +'dropin-template': patch +--- + +Fixes the Provider to merge user-provided langDefinitions with the drop-in's default definitions, enabling label/placeholder overrides via the initializer API. diff --git a/.github/workflows/pr-check-changeset.yaml b/.github/workflows/pr-check-changeset.yaml index 19ddf30..5fdf6f4 100644 --- a/.github/workflows/pr-check-changeset.yaml +++ b/.github/workflows/pr-check-changeset.yaml @@ -6,7 +6,6 @@ on: jobs: check-changeset: - name: Check Changeset runs-on: ubuntu-latest if: | !github.event.pull_request.draft && diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a1a9e95..6c8d2a9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,6 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: - name: Release runs-on: ubuntu-latest permissions: contents: write @@ -43,15 +42,18 @@ jobs: echo "has_changes=true" >> "$GITHUB_OUTPUT" fi - - name: Commit and push + - name: Commit if: steps.check.outputs.has_changes == 'true' run: | git add -A git commit -m "chore: bump version" - git push origin HEAD - name: Run changeset tag + if: steps.check.outputs.has_changes == 'true' run: npx changeset tag - - name: Push tags - run: git push --tags + - name: Push commit and tags + if: steps.check.outputs.has_changes == 'true' + run: | + git push origin HEAD + git push --tags diff --git a/src/render/Provider.tsx b/src/render/Provider.tsx index a69c26b..0db09db 100644 --- a/src/render/Provider.tsx +++ b/src/render/Provider.tsx @@ -3,6 +3,8 @@ import { useState, useEffect } from 'preact/hooks'; import { UIProvider } from '@adobe-commerce/elsie/components'; import { Lang } from '@adobe-commerce/elsie/i18n'; import { events } from '@adobe-commerce/event-bus'; +import { deepmerge } from '@adobe-commerce/elsie/lib'; +import { config } from '@/dropin-name/api'; import en_US from '../i18n/en_US.json'; @@ -11,11 +13,11 @@ const langDefinitions = { default: en_US, }; -interface CartProviderProps { +interface ProviderProps { children?: any; } -export const Provider: FunctionComponent = ({ +export const Provider: FunctionComponent = ({ children, }) => { const [lang, setLang] = useState('en_US'); @@ -34,8 +36,12 @@ export const Provider: FunctionComponent = ({ }; }, []); + const userLangDefinitions = config.getConfig()?.langDefinitions; + + const definitions = deepmerge(langDefinitions, userLangDefinitions ?? {}); + return ( - + {children} ); diff --git a/tsconfig.json b/tsconfig.json index b311de0..6995d6b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "dist", "baseUrl": ".", "paths": { - "@adobe-commerce/elsie/*": ["./node_modules/@adobe-commerce/elsie/src/*"] + "@adobe-commerce/elsie/*": ["./node_modules/@adobe-commerce/elsie/src/*"], + "@/dropin-name/*": ["./src/*"] } }, "include": ["src"],