@campfire-interactive/shell-header 0.3.3 → 0.4.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/dist/index.js +190 -122
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ function styleInject(css, { insertAt } = {}) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// src/styles.css
|
|
27
|
-
styleInject(".cfi-sh-header {\n display: flex;\n align-items: center;\n height: var(--cfi-shell-header-height, 48px);\n padding: 0 var(--cfi-spacing-md, 1rem);\n background: white;\n color: var(--cfi-color-gray-900, #111827);\n font-family: var(--cfi-font-family, system-ui, sans-serif);\n font-size: var(--cfi-font-size-sm, 0.875rem);\n border-bottom: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n position: relative;\n z-index: 1000;\n}\n.cfi-sh-left {\n display: flex;\n align-items: center;\n flex: 1;\n gap: var(--cfi-spacing-md, 1rem);\n overflow: hidden;\n}\n.cfi-sh-app-brand {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-sm, 0.5rem);\n flex-shrink: 0;\n}\n.cfi-sh-app-badge {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n color: white;\n font-size: 14px;\n font-weight: 700;\n font-family: inherit;\n border-radius: var(--cfi-radius-md, 0.375rem);\n flex-shrink: 0;\n}\n.cfi-sh-app-title {\n font-weight: 600;\n font-size: var(--cfi-font-size-base, 1rem);\n color: var(--cfi-color-gray-900, #111827);\n white-space: nowrap;\n}\n.cfi-sh-right {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-xs, 0.25rem);\n flex-shrink: 0;\n}\n.cfi-sh-icon-btn {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n background: transparent;\n border: none;\n border-radius: 50%;\n color: var(--cfi-color-gray-600, #4b5563);\n cursor: pointer;\n transition: background 150ms;\n}\n.cfi-sh-icon-btn:hover {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-badge {\n position: absolute;\n top: 2px;\n right: 2px;\n min-width: 16px;\n height: 16px;\n padding: 0 4px;\n background: var(--cfi-color-error, #ef4444);\n color: white;\n font-size: 10px;\n font-weight: 600;\n line-height: 16px;\n text-align: center;\n border-radius: 99px;\n}\n.cfi-sh-app-switcher {\n position: relative;\n}\n.cfi-sh-app-grid {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: var(--cfi-spacing-xs, 0.25rem);\n padding: var(--cfi-spacing-sm, 0.5rem);\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n min-width: 280px;\n}\n.cfi-sh-app-grid-item {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cfi-spacing-xs, 0.25rem);\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-xs, 0.25rem);\n border-radius: var(--cfi-radius-md, 0.375rem);\n color: var(--cfi-color-gray-700, #374151);\n text-decoration: none;\n cursor: pointer;\n transition: background 100ms;\n font-family: inherit;\n}\n.cfi-sh-app-grid-item:hover {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-app-grid-item-active {\n background: var(--cfi-color-primary-50, #fff7ed);\n color: var(--cfi-color-primary-700, #c2410c);\n}\n.cfi-sh-app-grid-item-active:hover {\n background: var(--cfi-color-primary-100, #ffedd5);\n}\n.cfi-sh-app-grid-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 50%;\n}\n.cfi-sh-app-grid-label {\n font-size: var(--cfi-font-size-xs, 0.75rem);\n text-align: center;\n line-height: 1.2;\n max-width: 80px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cfi-sh-user-menu {\n position: relative;\n}\n.cfi-sh-avatar-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n background: var(--cfi-color-primary-600, #ea580c);\n border: none;\n border-radius: 50%;\n cursor: pointer;\n transition: opacity 150ms;\n}\n.cfi-sh-avatar-btn:hover {\n opacity: 0.85;\n}\n.cfi-sh-avatar-img {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n object-fit: cover;\n}\n.cfi-sh-avatar-initials {\n color: white;\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-weight: 600;\n font-family: inherit;\n}\n.cfi-sh-user-dropdown {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n min-width: 200px;\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n}\n.cfi-sh-user-header {\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n display: flex;\n flex-direction: column;\n}\n.cfi-sh-user-name {\n font-weight: 500;\n color: var(--cfi-color-gray-900, #111827);\n font-size: var(--cfi-font-size-sm, 0.875rem);\n}\n.cfi-sh-user-email {\n color: var(--cfi-color-gray-500, #6b7280);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n}\n.cfi-sh-divider {\n height: 1px;\n background: var(--cfi-color-gray-200, #e5e7eb);\n}\n.cfi-sh-menu-item {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-sm, 0.5rem);\n width: 100%;\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n background: none;\n border: none;\n color: var(--cfi-color-gray-700, #374151);\n cursor: pointer;\n font-size: var(--cfi-font-size-sm, 0.875rem);\n font-family: inherit;\n transition: background 100ms;\n}\n.cfi-sh-menu-item:hover {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-menu-item:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.cfi-sh-locale-switcher {\n position: relative;\n}\n.cfi-sh-locale-btn {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-xs, 0.25rem);\n height: 32px;\n padding: 0 var(--cfi-spacing-sm, 0.5rem);\n background: transparent;\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n border-radius: var(--cfi-radius-md, 0.375rem);\n color: var(--cfi-color-gray-700, #374151);\n cursor: pointer;\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-weight: 600;\n font-family: inherit;\n transition: background 100ms;\n}\n.cfi-sh-locale-btn:hover:not(:disabled) {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-locale-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.cfi-sh-locale-label {\n letter-spacing: 0.02em;\n}\n.cfi-sh-locale-dropdown {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n min-width: 180px;\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n padding: var(--cfi-spacing-xs, 0.25rem) 0;\n}\n.cfi-sh-locale-dropdown .cfi-sh-menu-item {\n justify-content: space-between;\n}\n.cfi-sh-locale-item-active {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-locale-item-label {\n flex: 1;\n text-align: left;\n}\n.cfi-sh-locale-item-code {\n color: var(--cfi-color-gray-400, #9ca3af);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-weight: 600;\n letter-spacing: 0.02em;\n}\n.cfi-sh-notif {\n position: relative;\n}\n.cfi-sh-notif-dropdown {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n width: 360px;\n max-height: 480px;\n display: flex;\n flex-direction: column;\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n overflow: hidden;\n}\n.cfi-sh-notif-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n border-bottom: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n flex-shrink: 0;\n}\n.cfi-sh-notif-title {\n font-weight: 600;\n color: var(--cfi-color-gray-900, #111827);\n}\n.cfi-sh-notif-mark-all {\n background: none;\n border: none;\n color: var(--cfi-color-primary-600, #ea580c);\n cursor: pointer;\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-family: inherit;\n padding: 0;\n}\n.cfi-sh-notif-mark-all:hover {\n text-decoration: underline;\n}\n.cfi-sh-notif-list {\n overflow-y: auto;\n flex: 1;\n}\n.cfi-sh-notif-empty {\n padding: var(--cfi-spacing-lg, 1.5rem) var(--cfi-spacing-md, 1rem);\n color: var(--cfi-color-gray-500, #6b7280);\n text-align: center;\n font-size: var(--cfi-font-size-sm, 0.875rem);\n}\n.cfi-sh-notif-item {\n display: flex;\n align-items: flex-start;\n gap: var(--cfi-spacing-sm, 0.5rem);\n width: 100%;\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n background: none;\n border: none;\n border-bottom: 1px solid var(--cfi-color-gray-100, #f3f4f6);\n text-align: left;\n cursor: pointer;\n font-family: inherit;\n transition: background 100ms;\n}\n.cfi-sh-notif-item:hover {\n background: var(--cfi-color-gray-50, #f9fafb);\n}\n.cfi-sh-notif-item:last-child {\n border-bottom: none;\n}\n.cfi-sh-notif-dot {\n flex-shrink: 0;\n width: 8px;\n height: 8px;\n margin-top: 6px;\n background: var(--cfi-color-primary-600, #ea580c);\n border-radius: 50%;\n}\n.cfi-sh-notif-dot-placeholder {\n flex-shrink: 0;\n width: 8px;\n height: 8px;\n margin-top: 6px;\n}\n.cfi-sh-notif-content {\n flex: 1;\n min-width: 0;\n}\n.cfi-sh-notif-item-title {\n font-weight: 500;\n color: var(--cfi-color-gray-900, #111827);\n font-size: var(--cfi-font-size-sm, 0.875rem);\n margin-bottom: 2px;\n}\n.cfi-sh-notif-item-unread .cfi-sh-notif-item-title {\n font-weight: 600;\n}\n.cfi-sh-notif-item-body {\n color: var(--cfi-color-gray-600, #4b5563);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n line-height: 1.4;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.cfi-sh-notif-item-time {\n color: var(--cfi-color-gray-400, #9ca3af);\n font-size: 11px;\n margin-top: 4px;\n}\n");
|
|
27
|
+
styleInject(".cfi-sh-header {\n display: flex;\n align-items: center;\n height: var(--cfi-shell-header-height, 48px);\n padding: 0 var(--cfi-spacing-md, 1rem);\n background: white;\n color: var(--cfi-color-gray-900, #111827);\n font-family: var(--cfi-font-family, system-ui, sans-serif);\n font-size: var(--cfi-font-size-sm, 0.875rem);\n border-bottom: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n position: relative;\n z-index: 1000;\n}\n.cfi-sh-left {\n display: flex;\n align-items: center;\n flex: 1;\n gap: var(--cfi-spacing-md, 1rem);\n overflow: hidden;\n}\n.cfi-sh-app-brand {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-sm, 0.5rem);\n flex-shrink: 0;\n}\n.cfi-sh-app-badge {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n color: white;\n font-size: 14px;\n font-weight: 700;\n font-family: inherit;\n border-radius: var(--cfi-radius-md, 0.375rem);\n flex-shrink: 0;\n}\n.cfi-sh-app-title {\n font-weight: 600;\n font-size: var(--cfi-font-size-base, 1rem);\n color: var(--cfi-color-gray-900, #111827);\n white-space: nowrap;\n}\n.cfi-sh-right {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-xs, 0.25rem);\n flex-shrink: 0;\n}\n.cfi-sh-icon-btn {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n background: transparent;\n border: none;\n border-radius: 50%;\n color: var(--cfi-color-gray-600, #4b5563);\n cursor: pointer;\n transition: background 150ms;\n}\n.cfi-sh-icon-btn:hover {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-badge {\n position: absolute;\n top: 2px;\n right: 2px;\n min-width: 16px;\n height: 16px;\n padding: 0 4px;\n background: var(--cfi-color-error, #ef4444);\n color: white;\n font-size: 10px;\n font-weight: 600;\n line-height: 16px;\n text-align: center;\n border-radius: 99px;\n}\n.cfi-sh-app-switcher {\n position: relative;\n}\n.cfi-sh-app-grid {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: var(--cfi-spacing-xs, 0.25rem);\n padding: var(--cfi-spacing-sm, 0.5rem);\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n min-width: 280px;\n}\n.cfi-sh-app-grid-item {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--cfi-spacing-xs, 0.25rem);\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-xs, 0.25rem);\n border-radius: var(--cfi-radius-md, 0.375rem);\n color: var(--cfi-color-gray-700, #374151);\n text-decoration: none;\n cursor: pointer;\n transition: background 100ms;\n font-family: inherit;\n}\n.cfi-sh-app-grid-item:hover {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-app-grid-item-active {\n background: var(--cfi-color-primary-50, #fff7ed);\n color: var(--cfi-color-primary-700, #c2410c);\n}\n.cfi-sh-app-grid-item-active:hover {\n background: var(--cfi-color-primary-100, #ffedd5);\n}\n.cfi-sh-app-grid-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 50%;\n}\n.cfi-sh-app-grid-label {\n font-size: var(--cfi-font-size-xs, 0.75rem);\n text-align: center;\n line-height: 1.2;\n max-width: 80px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cfi-sh-user-menu {\n position: relative;\n}\n.cfi-sh-avatar-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n background: var(--cfi-color-primary-600, #ea580c);\n border: none;\n border-radius: 50%;\n cursor: pointer;\n transition: opacity 150ms;\n}\n.cfi-sh-avatar-btn:hover {\n opacity: 0.85;\n}\n.cfi-sh-avatar-img {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n object-fit: cover;\n}\n.cfi-sh-avatar-initials {\n color: white;\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-weight: 600;\n font-family: inherit;\n}\n.cfi-sh-user-dropdown {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n min-width: 200px;\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n}\n.cfi-sh-user-header {\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n display: flex;\n flex-direction: column;\n}\n.cfi-sh-user-name {\n font-weight: 500;\n color: var(--cfi-color-gray-900, #111827);\n font-size: var(--cfi-font-size-sm, 0.875rem);\n}\n.cfi-sh-user-email {\n color: var(--cfi-color-gray-500, #6b7280);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n}\n.cfi-sh-divider {\n height: 1px;\n background: var(--cfi-color-gray-200, #e5e7eb);\n}\n.cfi-sh-menu-item {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-sm, 0.5rem);\n width: 100%;\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n background: none;\n border: none;\n color: var(--cfi-color-gray-700, #374151);\n cursor: pointer;\n font-size: var(--cfi-font-size-sm, 0.875rem);\n font-family: inherit;\n transition: background 100ms;\n}\n.cfi-sh-menu-item:hover {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-menu-item:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.cfi-sh-locale-switcher {\n position: relative;\n}\n.cfi-sh-locale-btn {\n display: flex;\n align-items: center;\n gap: var(--cfi-spacing-xs, 0.25rem);\n height: 32px;\n padding: 0 var(--cfi-spacing-sm, 0.5rem);\n background: transparent;\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n border-radius: var(--cfi-radius-md, 0.375rem);\n color: var(--cfi-color-gray-700, #374151);\n cursor: pointer;\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-weight: 600;\n font-family: inherit;\n transition: background 100ms;\n}\n.cfi-sh-locale-btn:hover:not(:disabled) {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-locale-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.cfi-sh-locale-label {\n letter-spacing: 0.02em;\n}\n.cfi-sh-locale-dropdown {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n min-width: 180px;\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n padding: var(--cfi-spacing-xs, 0.25rem) 0;\n}\n.cfi-sh-locale-dropdown .cfi-sh-menu-item {\n justify-content: space-between;\n}\n.cfi-sh-locale-item-active {\n background: var(--cfi-color-gray-100, #f3f4f6);\n}\n.cfi-sh-locale-item-label {\n flex: 1;\n text-align: left;\n}\n.cfi-sh-locale-item-code {\n color: var(--cfi-color-gray-400, #9ca3af);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-weight: 600;\n letter-spacing: 0.02em;\n}\n.cfi-sh-locale-row {\n justify-content: flex-start;\n}\n.cfi-sh-locale-row-label {\n flex: 1;\n text-align: left;\n}\n.cfi-sh-locale-row-current {\n color: var(--cfi-color-gray-500, #6b7280);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n margin-right: var(--cfi-spacing-xs, 0.25rem);\n}\n.cfi-sh-locale-chevron {\n transition: transform 150ms ease;\n flex-shrink: 0;\n}\n.cfi-sh-locale-chevron-open {\n transform: rotate(180deg);\n}\n.cfi-sh-locale-sublist {\n border-top: 1px solid var(--cfi-color-gray-100, #f3f4f6);\n background: var(--cfi-color-gray-50, #f9fafb);\n}\n.cfi-sh-locale-sub-item {\n padding-left: calc(var(--cfi-spacing-md, 1rem) + var(--cfi-spacing-md, 1rem));\n justify-content: space-between;\n}\n.cfi-sh-notif {\n position: relative;\n}\n.cfi-sh-notif-dropdown {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n width: 360px;\n max-height: 480px;\n display: flex;\n flex-direction: column;\n background: white;\n border-radius: var(--cfi-radius-lg, 0.5rem);\n box-shadow: var(--cfi-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));\n border: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n z-index: 1001;\n overflow: hidden;\n}\n.cfi-sh-notif-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n border-bottom: 1px solid var(--cfi-color-gray-200, #e5e7eb);\n flex-shrink: 0;\n}\n.cfi-sh-notif-title {\n font-weight: 600;\n color: var(--cfi-color-gray-900, #111827);\n}\n.cfi-sh-notif-mark-all {\n background: none;\n border: none;\n color: var(--cfi-color-primary-600, #ea580c);\n cursor: pointer;\n font-size: var(--cfi-font-size-xs, 0.75rem);\n font-family: inherit;\n padding: 0;\n}\n.cfi-sh-notif-mark-all:hover {\n text-decoration: underline;\n}\n.cfi-sh-notif-list {\n overflow-y: auto;\n flex: 1;\n}\n.cfi-sh-notif-empty {\n padding: var(--cfi-spacing-lg, 1.5rem) var(--cfi-spacing-md, 1rem);\n color: var(--cfi-color-gray-500, #6b7280);\n text-align: center;\n font-size: var(--cfi-font-size-sm, 0.875rem);\n}\n.cfi-sh-notif-item {\n display: flex;\n align-items: flex-start;\n gap: var(--cfi-spacing-sm, 0.5rem);\n width: 100%;\n padding: var(--cfi-spacing-sm, 0.5rem) var(--cfi-spacing-md, 1rem);\n background: none;\n border: none;\n border-bottom: 1px solid var(--cfi-color-gray-100, #f3f4f6);\n text-align: left;\n cursor: pointer;\n font-family: inherit;\n transition: background 100ms;\n}\n.cfi-sh-notif-item:hover {\n background: var(--cfi-color-gray-50, #f9fafb);\n}\n.cfi-sh-notif-item:last-child {\n border-bottom: none;\n}\n.cfi-sh-notif-dot {\n flex-shrink: 0;\n width: 8px;\n height: 8px;\n margin-top: 6px;\n background: var(--cfi-color-primary-600, #ea580c);\n border-radius: 50%;\n}\n.cfi-sh-notif-dot-placeholder {\n flex-shrink: 0;\n width: 8px;\n height: 8px;\n margin-top: 6px;\n}\n.cfi-sh-notif-content {\n flex: 1;\n min-width: 0;\n}\n.cfi-sh-notif-item-title {\n font-weight: 500;\n color: var(--cfi-color-gray-900, #111827);\n font-size: var(--cfi-font-size-sm, 0.875rem);\n margin-bottom: 2px;\n}\n.cfi-sh-notif-item-unread .cfi-sh-notif-item-title {\n font-weight: 600;\n}\n.cfi-sh-notif-item-body {\n color: var(--cfi-color-gray-600, #4b5563);\n font-size: var(--cfi-font-size-xs, 0.75rem);\n line-height: 1.4;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.cfi-sh-notif-item-time {\n color: var(--cfi-color-gray-400, #9ca3af);\n font-size: 11px;\n margin-top: 4px;\n}\n");
|
|
28
28
|
|
|
29
29
|
// src/appCatalog.ts
|
|
30
30
|
var appCatalog = [
|
|
@@ -64,7 +64,8 @@ import {
|
|
|
64
64
|
GripHorizontal,
|
|
65
65
|
Bell,
|
|
66
66
|
LogOut,
|
|
67
|
-
Globe
|
|
67
|
+
Globe,
|
|
68
|
+
ChevronDown
|
|
68
69
|
} from "lucide-react";
|
|
69
70
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
70
71
|
var iconMap = {
|
|
@@ -143,73 +144,9 @@ function AppSwitcher({ currentAppId, authorizedApps }) {
|
|
|
143
144
|
] });
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
// src/LocaleSwitcher.tsx
|
|
147
|
-
import { useState as useState2, useRef as useRef2, useEffect as useEffect2 } from "react";
|
|
148
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
149
|
-
function LocaleSwitcher({ currentLocale, supportedLocales, onLocaleChange }) {
|
|
150
|
-
const [open, setOpen] = useState2(false);
|
|
151
|
-
const [updating, setUpdating] = useState2(false);
|
|
152
|
-
const ref = useRef2(null);
|
|
153
|
-
useEffect2(() => {
|
|
154
|
-
function handleClickOutside(e) {
|
|
155
|
-
if (ref.current && !ref.current.contains(e.target)) {
|
|
156
|
-
setOpen(false);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (open) document.addEventListener("mousedown", handleClickOutside);
|
|
160
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
161
|
-
}, [open]);
|
|
162
|
-
const current = supportedLocales.find((l) => l.code === currentLocale);
|
|
163
|
-
const buttonLabel = (current?.code ?? currentLocale).toUpperCase();
|
|
164
|
-
async function handleSelect(code) {
|
|
165
|
-
if (code === currentLocale) {
|
|
166
|
-
setOpen(false);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
setUpdating(true);
|
|
170
|
-
try {
|
|
171
|
-
await onLocaleChange(code);
|
|
172
|
-
} finally {
|
|
173
|
-
setUpdating(false);
|
|
174
|
-
setOpen(false);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return /* @__PURE__ */ jsxs3("div", { className: "cfi-sh-locale-switcher", ref, children: [
|
|
178
|
-
/* @__PURE__ */ jsxs3(
|
|
179
|
-
"button",
|
|
180
|
-
{
|
|
181
|
-
className: "cfi-sh-locale-btn",
|
|
182
|
-
onClick: () => setOpen(!open),
|
|
183
|
-
"aria-expanded": open,
|
|
184
|
-
"aria-haspopup": "true",
|
|
185
|
-
"aria-label": `Language: ${current?.label ?? currentLocale}`,
|
|
186
|
-
disabled: updating,
|
|
187
|
-
title: current?.label ?? currentLocale,
|
|
188
|
-
children: [
|
|
189
|
-
/* @__PURE__ */ jsx3(Globe, { size: 16 }),
|
|
190
|
-
/* @__PURE__ */ jsx3("span", { className: "cfi-sh-locale-label", children: buttonLabel })
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
),
|
|
194
|
-
open && /* @__PURE__ */ jsx3("div", { className: "cfi-sh-locale-dropdown", children: supportedLocales.map((loc) => /* @__PURE__ */ jsxs3(
|
|
195
|
-
"button",
|
|
196
|
-
{
|
|
197
|
-
className: loc.code === currentLocale ? "cfi-sh-menu-item cfi-sh-locale-item-active" : "cfi-sh-menu-item",
|
|
198
|
-
onClick: () => handleSelect(loc.code),
|
|
199
|
-
disabled: updating,
|
|
200
|
-
children: [
|
|
201
|
-
/* @__PURE__ */ jsx3("span", { className: "cfi-sh-locale-item-label", children: loc.label }),
|
|
202
|
-
/* @__PURE__ */ jsx3("span", { className: "cfi-sh-locale-item-code", children: loc.code.toUpperCase() })
|
|
203
|
-
]
|
|
204
|
-
},
|
|
205
|
-
loc.code
|
|
206
|
-
)) })
|
|
207
|
-
] });
|
|
208
|
-
}
|
|
209
|
-
|
|
210
147
|
// src/NotificationBell.tsx
|
|
211
|
-
import { useEffect as
|
|
212
|
-
import { jsx as
|
|
148
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
149
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
213
150
|
function NotificationBell({
|
|
214
151
|
count = 0,
|
|
215
152
|
onClick,
|
|
@@ -219,9 +156,9 @@ function NotificationBell({
|
|
|
219
156
|
onItemClick
|
|
220
157
|
}) {
|
|
221
158
|
const hasDropdown = items !== void 0;
|
|
222
|
-
const [open, setOpen] =
|
|
223
|
-
const ref =
|
|
224
|
-
|
|
159
|
+
const [open, setOpen] = useState2(false);
|
|
160
|
+
const ref = useRef2(null);
|
|
161
|
+
useEffect2(() => {
|
|
225
162
|
function handleClickOutside(e) {
|
|
226
163
|
if (ref.current && !ref.current.contains(e.target)) {
|
|
227
164
|
setOpen(false);
|
|
@@ -230,7 +167,7 @@ function NotificationBell({
|
|
|
230
167
|
if (open) document.addEventListener("mousedown", handleClickOutside);
|
|
231
168
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
232
169
|
}, [open]);
|
|
233
|
-
|
|
170
|
+
useEffect2(() => {
|
|
234
171
|
function handleEsc(e) {
|
|
235
172
|
if (e.key === "Escape") setOpen(false);
|
|
236
173
|
}
|
|
@@ -250,8 +187,8 @@ function NotificationBell({
|
|
|
250
187
|
setOpen(false);
|
|
251
188
|
};
|
|
252
189
|
const hasUnread = items?.some((i) => i.readAt === null) ?? false;
|
|
253
|
-
return /* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsxs3("div", { className: "cfi-sh-notif", ref, children: [
|
|
191
|
+
/* @__PURE__ */ jsxs3(
|
|
255
192
|
"button",
|
|
256
193
|
{
|
|
257
194
|
className: "cfi-sh-icon-btn",
|
|
@@ -260,15 +197,15 @@ function NotificationBell({
|
|
|
260
197
|
"aria-haspopup": hasDropdown ? "true" : void 0,
|
|
261
198
|
"aria-label": "Notifications",
|
|
262
199
|
children: [
|
|
263
|
-
/* @__PURE__ */
|
|
264
|
-
count > 0 && /* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ jsx3(Bell, { size: 18 }),
|
|
201
|
+
count > 0 && /* @__PURE__ */ jsx3("span", { className: "cfi-sh-badge", children: count > 99 ? "99+" : count })
|
|
265
202
|
]
|
|
266
203
|
}
|
|
267
204
|
),
|
|
268
|
-
hasDropdown && open && /* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
hasUnread && onMarkAllRead && /* @__PURE__ */
|
|
205
|
+
hasDropdown && open && /* @__PURE__ */ jsxs3("div", { className: "cfi-sh-notif-dropdown", role: "dialog", "aria-label": "Notifications", children: [
|
|
206
|
+
/* @__PURE__ */ jsxs3("div", { className: "cfi-sh-notif-header", children: [
|
|
207
|
+
/* @__PURE__ */ jsx3("span", { className: "cfi-sh-notif-title", children: "Notifications" }),
|
|
208
|
+
hasUnread && onMarkAllRead && /* @__PURE__ */ jsx3(
|
|
272
209
|
"button",
|
|
273
210
|
{
|
|
274
211
|
className: "cfi-sh-notif-mark-all",
|
|
@@ -278,18 +215,18 @@ function NotificationBell({
|
|
|
278
215
|
}
|
|
279
216
|
)
|
|
280
217
|
] }),
|
|
281
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ jsx3("div", { className: "cfi-sh-notif-list", children: items.length === 0 ? /* @__PURE__ */ jsx3("div", { className: "cfi-sh-notif-empty", children: "No notifications yet." }) : items.map((n) => /* @__PURE__ */ jsxs3(
|
|
282
219
|
"button",
|
|
283
220
|
{
|
|
284
221
|
className: `cfi-sh-notif-item ${n.readAt === null ? "cfi-sh-notif-item-unread" : ""}`,
|
|
285
222
|
onClick: () => handleItemClick(n),
|
|
286
223
|
type: "button",
|
|
287
224
|
children: [
|
|
288
|
-
n.readAt === null ? /* @__PURE__ */
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
291
|
-
/* @__PURE__ */
|
|
292
|
-
/* @__PURE__ */
|
|
225
|
+
n.readAt === null ? /* @__PURE__ */ jsx3("span", { className: "cfi-sh-notif-dot", "aria-hidden": "true" }) : /* @__PURE__ */ jsx3("span", { className: "cfi-sh-notif-dot-placeholder", "aria-hidden": "true" }),
|
|
226
|
+
/* @__PURE__ */ jsxs3("div", { className: "cfi-sh-notif-content", children: [
|
|
227
|
+
/* @__PURE__ */ jsx3("div", { className: "cfi-sh-notif-item-title", children: n.title }),
|
|
228
|
+
/* @__PURE__ */ jsx3("div", { className: "cfi-sh-notif-item-body", children: n.body }),
|
|
229
|
+
/* @__PURE__ */ jsx3("div", { className: "cfi-sh-notif-item-time", children: formatRelative(n.createdAt) })
|
|
293
230
|
] })
|
|
294
231
|
]
|
|
295
232
|
},
|
|
@@ -313,23 +250,52 @@ function formatRelative(iso) {
|
|
|
313
250
|
}
|
|
314
251
|
|
|
315
252
|
// src/UserMenu.tsx
|
|
316
|
-
import { useState as
|
|
317
|
-
import { jsx as
|
|
318
|
-
function UserMenu({
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
253
|
+
import { useState as useState3, useRef as useRef3, useEffect as useEffect3 } from "react";
|
|
254
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
255
|
+
function UserMenu({
|
|
256
|
+
user,
|
|
257
|
+
onLogout,
|
|
258
|
+
color,
|
|
259
|
+
locale,
|
|
260
|
+
supportedLocales,
|
|
261
|
+
onLocaleChange
|
|
262
|
+
}) {
|
|
263
|
+
const [open, setOpen] = useState3(false);
|
|
264
|
+
const [langExpanded, setLangExpanded] = useState3(false);
|
|
265
|
+
const [updating, setUpdating] = useState3(false);
|
|
266
|
+
const ref = useRef3(null);
|
|
267
|
+
useEffect3(() => {
|
|
322
268
|
function handleClickOutside(e) {
|
|
323
269
|
if (ref.current && !ref.current.contains(e.target)) {
|
|
324
270
|
setOpen(false);
|
|
271
|
+
setLangExpanded(false);
|
|
325
272
|
}
|
|
326
273
|
}
|
|
327
274
|
if (open) document.addEventListener("mousedown", handleClickOutside);
|
|
328
275
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
329
276
|
}, [open]);
|
|
277
|
+
useEffect3(() => {
|
|
278
|
+
if (!open) setLangExpanded(false);
|
|
279
|
+
}, [open]);
|
|
330
280
|
const initials = user.name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
331
|
-
|
|
332
|
-
|
|
281
|
+
const showLocale = locale !== void 0 && supportedLocales !== void 0 && supportedLocales.length > 0 && onLocaleChange !== void 0;
|
|
282
|
+
const currentLocale = showLocale ? supportedLocales.find((l) => l.code === locale) : void 0;
|
|
283
|
+
async function handleLocaleSelect(code) {
|
|
284
|
+
if (code === locale || !onLocaleChange) {
|
|
285
|
+
setLangExpanded(false);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setUpdating(true);
|
|
289
|
+
try {
|
|
290
|
+
await onLocaleChange(code);
|
|
291
|
+
} finally {
|
|
292
|
+
setUpdating(false);
|
|
293
|
+
setLangExpanded(false);
|
|
294
|
+
setOpen(false);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return /* @__PURE__ */ jsxs4("div", { className: "cfi-sh-user-menu", ref, children: [
|
|
298
|
+
/* @__PURE__ */ jsx4(
|
|
333
299
|
"button",
|
|
334
300
|
{
|
|
335
301
|
className: "cfi-sh-avatar-btn",
|
|
@@ -337,16 +303,53 @@ function UserMenu({ user, onLogout, color }) {
|
|
|
337
303
|
onClick: () => setOpen(!open),
|
|
338
304
|
"aria-expanded": open,
|
|
339
305
|
"aria-haspopup": "true",
|
|
340
|
-
children: user.avatarUrl ? /* @__PURE__ */
|
|
306
|
+
children: user.avatarUrl ? /* @__PURE__ */ jsx4("img", { src: user.avatarUrl, alt: user.name, className: "cfi-sh-avatar-img" }) : /* @__PURE__ */ jsx4("span", { className: "cfi-sh-avatar-initials", children: initials })
|
|
341
307
|
}
|
|
342
308
|
),
|
|
343
|
-
open && /* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
309
|
+
open && /* @__PURE__ */ jsxs4("div", { className: "cfi-sh-user-dropdown", children: [
|
|
310
|
+
/* @__PURE__ */ jsxs4("div", { className: "cfi-sh-user-header", children: [
|
|
311
|
+
/* @__PURE__ */ jsx4("span", { className: "cfi-sh-user-name", children: user.name }),
|
|
312
|
+
/* @__PURE__ */ jsx4("span", { className: "cfi-sh-user-email", children: user.email })
|
|
347
313
|
] }),
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
|
|
314
|
+
showLocale && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
315
|
+
/* @__PURE__ */ jsx4("div", { className: "cfi-sh-divider" }),
|
|
316
|
+
/* @__PURE__ */ jsxs4(
|
|
317
|
+
"button",
|
|
318
|
+
{
|
|
319
|
+
className: "cfi-sh-menu-item cfi-sh-locale-row",
|
|
320
|
+
onClick: () => setLangExpanded(!langExpanded),
|
|
321
|
+
"aria-expanded": langExpanded,
|
|
322
|
+
disabled: updating,
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ jsx4(Globe, { size: 14 }),
|
|
325
|
+
/* @__PURE__ */ jsx4("span", { className: "cfi-sh-locale-row-label", children: "Language" }),
|
|
326
|
+
/* @__PURE__ */ jsx4("span", { className: "cfi-sh-locale-row-current", children: currentLocale?.label ?? locale }),
|
|
327
|
+
/* @__PURE__ */ jsx4(
|
|
328
|
+
ChevronDown,
|
|
329
|
+
{
|
|
330
|
+
size: 14,
|
|
331
|
+
className: langExpanded ? "cfi-sh-locale-chevron cfi-sh-locale-chevron-open" : "cfi-sh-locale-chevron"
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
langExpanded && /* @__PURE__ */ jsx4("div", { className: "cfi-sh-locale-sublist", children: supportedLocales.map((loc) => /* @__PURE__ */ jsxs4(
|
|
338
|
+
"button",
|
|
339
|
+
{
|
|
340
|
+
className: loc.code === locale ? "cfi-sh-menu-item cfi-sh-locale-sub-item cfi-sh-locale-item-active" : "cfi-sh-menu-item cfi-sh-locale-sub-item",
|
|
341
|
+
onClick: () => handleLocaleSelect(loc.code),
|
|
342
|
+
disabled: updating,
|
|
343
|
+
children: [
|
|
344
|
+
/* @__PURE__ */ jsx4("span", { className: "cfi-sh-locale-item-label", children: loc.label }),
|
|
345
|
+
/* @__PURE__ */ jsx4("span", { className: "cfi-sh-locale-item-code", children: loc.code.toUpperCase() })
|
|
346
|
+
]
|
|
347
|
+
},
|
|
348
|
+
loc.code
|
|
349
|
+
)) })
|
|
350
|
+
] }),
|
|
351
|
+
/* @__PURE__ */ jsx4("div", { className: "cfi-sh-divider" }),
|
|
352
|
+
/* @__PURE__ */ jsxs4(
|
|
350
353
|
"button",
|
|
351
354
|
{
|
|
352
355
|
className: "cfi-sh-menu-item",
|
|
@@ -355,8 +358,8 @@ function UserMenu({ user, onLogout, color }) {
|
|
|
355
358
|
onLogout?.();
|
|
356
359
|
},
|
|
357
360
|
children: [
|
|
358
|
-
/* @__PURE__ */
|
|
359
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ jsx4(LogOut, { size: 14 }),
|
|
362
|
+
/* @__PURE__ */ jsx4("span", { children: "Sign out" })
|
|
360
363
|
]
|
|
361
364
|
}
|
|
362
365
|
)
|
|
@@ -365,7 +368,7 @@ function UserMenu({ user, onLogout, color }) {
|
|
|
365
368
|
}
|
|
366
369
|
|
|
367
370
|
// src/ShellHeader.tsx
|
|
368
|
-
import { jsx as
|
|
371
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
369
372
|
function ShellHeader({
|
|
370
373
|
appId,
|
|
371
374
|
user,
|
|
@@ -385,25 +388,16 @@ function ShellHeader({
|
|
|
385
388
|
}) {
|
|
386
389
|
const currentApp = appCatalog.find((a) => a.id === appId);
|
|
387
390
|
const brandStyle = brandWidth ? { width: `${brandWidth}px`, flexShrink: 0, boxSizing: "border-box" } : void 0;
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
/* @__PURE__ */ jsx6("span", { className: "cfi-sh-app-title", children: currentApp?.name || appId })
|
|
391
|
+
return /* @__PURE__ */ jsxs5("header", { className: "cfi-sh-header", children: [
|
|
392
|
+
/* @__PURE__ */ jsxs5("div", { className: "cfi-sh-left", children: [
|
|
393
|
+
/* @__PURE__ */ jsxs5("div", { className: "cfi-sh-app-brand", style: brandStyle, children: [
|
|
394
|
+
currentApp && /* @__PURE__ */ jsx5("span", { className: "cfi-sh-app-badge", style: { background: currentApp.color }, children: currentApp.letter }),
|
|
395
|
+
/* @__PURE__ */ jsx5("span", { className: "cfi-sh-app-title", children: currentApp?.name || appId })
|
|
394
396
|
] }),
|
|
395
397
|
children
|
|
396
398
|
] }),
|
|
397
|
-
/* @__PURE__ */
|
|
398
|
-
|
|
399
|
-
LocaleSwitcher,
|
|
400
|
-
{
|
|
401
|
-
currentLocale: locale,
|
|
402
|
-
supportedLocales,
|
|
403
|
-
onLocaleChange
|
|
404
|
-
}
|
|
405
|
-
),
|
|
406
|
-
/* @__PURE__ */ jsx6(
|
|
399
|
+
/* @__PURE__ */ jsxs5("div", { className: "cfi-sh-right", children: [
|
|
400
|
+
/* @__PURE__ */ jsx5(
|
|
407
401
|
NotificationBell,
|
|
408
402
|
{
|
|
409
403
|
count: notificationCount,
|
|
@@ -414,11 +408,85 @@ function ShellHeader({
|
|
|
414
408
|
onItemClick: onNotificationItemClick
|
|
415
409
|
}
|
|
416
410
|
),
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ jsx5(AppSwitcher, { currentAppId: appId, authorizedApps }),
|
|
412
|
+
/* @__PURE__ */ jsx5(
|
|
413
|
+
UserMenu,
|
|
414
|
+
{
|
|
415
|
+
user,
|
|
416
|
+
onLogout,
|
|
417
|
+
color: currentApp?.color,
|
|
418
|
+
locale,
|
|
419
|
+
supportedLocales,
|
|
420
|
+
onLocaleChange
|
|
421
|
+
}
|
|
422
|
+
)
|
|
419
423
|
] })
|
|
420
424
|
] });
|
|
421
425
|
}
|
|
426
|
+
|
|
427
|
+
// src/LocaleSwitcher.tsx
|
|
428
|
+
import { useState as useState4, useRef as useRef4, useEffect as useEffect4 } from "react";
|
|
429
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
430
|
+
function LocaleSwitcher({ currentLocale, supportedLocales, onLocaleChange }) {
|
|
431
|
+
const [open, setOpen] = useState4(false);
|
|
432
|
+
const [updating, setUpdating] = useState4(false);
|
|
433
|
+
const ref = useRef4(null);
|
|
434
|
+
useEffect4(() => {
|
|
435
|
+
function handleClickOutside(e) {
|
|
436
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
437
|
+
setOpen(false);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (open) document.addEventListener("mousedown", handleClickOutside);
|
|
441
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
442
|
+
}, [open]);
|
|
443
|
+
const current = supportedLocales.find((l) => l.code === currentLocale);
|
|
444
|
+
const buttonLabel = (current?.code ?? currentLocale).toUpperCase();
|
|
445
|
+
async function handleSelect(code) {
|
|
446
|
+
if (code === currentLocale) {
|
|
447
|
+
setOpen(false);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
setUpdating(true);
|
|
451
|
+
try {
|
|
452
|
+
await onLocaleChange(code);
|
|
453
|
+
} finally {
|
|
454
|
+
setUpdating(false);
|
|
455
|
+
setOpen(false);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return /* @__PURE__ */ jsxs6("div", { className: "cfi-sh-locale-switcher", ref, children: [
|
|
459
|
+
/* @__PURE__ */ jsxs6(
|
|
460
|
+
"button",
|
|
461
|
+
{
|
|
462
|
+
className: "cfi-sh-locale-btn",
|
|
463
|
+
onClick: () => setOpen(!open),
|
|
464
|
+
"aria-expanded": open,
|
|
465
|
+
"aria-haspopup": "true",
|
|
466
|
+
"aria-label": `Language: ${current?.label ?? currentLocale}`,
|
|
467
|
+
disabled: updating,
|
|
468
|
+
title: current?.label ?? currentLocale,
|
|
469
|
+
children: [
|
|
470
|
+
/* @__PURE__ */ jsx6(Globe, { size: 16 }),
|
|
471
|
+
/* @__PURE__ */ jsx6("span", { className: "cfi-sh-locale-label", children: buttonLabel })
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
open && /* @__PURE__ */ jsx6("div", { className: "cfi-sh-locale-dropdown", children: supportedLocales.map((loc) => /* @__PURE__ */ jsxs6(
|
|
476
|
+
"button",
|
|
477
|
+
{
|
|
478
|
+
className: loc.code === currentLocale ? "cfi-sh-menu-item cfi-sh-locale-item-active" : "cfi-sh-menu-item",
|
|
479
|
+
onClick: () => handleSelect(loc.code),
|
|
480
|
+
disabled: updating,
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ jsx6("span", { className: "cfi-sh-locale-item-label", children: loc.label }),
|
|
483
|
+
/* @__PURE__ */ jsx6("span", { className: "cfi-sh-locale-item-code", children: loc.code.toUpperCase() })
|
|
484
|
+
]
|
|
485
|
+
},
|
|
486
|
+
loc.code
|
|
487
|
+
)) })
|
|
488
|
+
] });
|
|
489
|
+
}
|
|
422
490
|
export {
|
|
423
491
|
LocaleSwitcher,
|
|
424
492
|
ShellHeader,
|