@segmentify/ui 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,26 +72,21 @@ Package-owned portaled content establishes `ui-lib-root` automatically. Consumer
72
72
  - `pnpm build-storybook`: Build the Storybook documentation.
73
73
  - `pnpm lint`: Run ESLint to check for code quality issues.
74
74
  - `pnpm format`: Format the codebase using Prettier.
75
- - `pnpm release`: Publish the package using Changesets.
75
+ - `pnpm release`: Publish the package using Changesets (run by the `Release` workflow).
76
76
 
77
77
  ## Releasing
78
78
 
79
- This project uses Changesets for versioning and releases.
79
+ This project uses Changesets for versioning and releases. Publishing runs in the `Release` GitHub Actions workflow on our own build runner (`job-runner-02`), so no npm token is needed on your machine.
80
80
 
81
81
  ### Configuration
82
82
 
83
- To publish new releases, you must have an `.npmrc` file in the root of the project with a valid npm authToken:
84
-
85
- ```text
86
- @segmentify:registry=https://registry.npmjs.org/
87
- //registry.npmjs.org/:_authToken=YOUR_NPM_AUTH_TOKEN
88
- ```
83
+ The workflow publishes with the `NPM_TOKEN` secret (an npm automation token with publish access to `@segmentify/ui`). npm trusted publishing (OIDC) is not used because npm accepts it only from GitHub-hosted runners. The package's publishing access must allow tokens. The workflow can also be started by hand (Actions → Release → Run workflow).
89
84
 
90
85
  ### Process
91
86
 
92
87
  1. **Create a Changeset**: Run `pnpm changeset` and follow the prompts to document your changes.
93
- 2. **Version Packages**: Run `pnpm version-packages` to update versions and the changelog.
94
- 3. **Publish**: Run `pnpm release` to publish the new version to npm.
88
+ 2. **Version Packages**: Run `pnpm version-packages` to update versions and the changelog, then merge the change to `main`.
89
+ 3. **Publish**: On every push to `main`, the `Release` workflow builds the package and runs `pnpm release`, which publishes any version that is not yet on npm.
95
90
 
96
91
  ## License
97
92
 
@@ -0,0 +1,6 @@
1
+ import type { UiMessageId } from '../../lib/ui-messages';
2
+ /** Renders a built-in library text in the host's language (see `useUiTranslation`). */
3
+ declare function UiText({ id }: {
4
+ id: UiMessageId;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ export { UiText };
@@ -12,4 +12,4 @@ export type AsyncComboboxProps = {
12
12
  disabled?: boolean;
13
13
  align?: 'start' | 'center' | 'end';
14
14
  };
15
- export declare function AsyncCombobox({ selectedItem, fetchItems: fetchItemsProp, searchPlaceholder, placeholder, className, disabled, align, onSelect, }: AsyncComboboxProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function AsyncCombobox({ selectedItem, fetchItems: fetchItemsProp, searchPlaceholder: searchPlaceholderProp, placeholder: placeholderProp, className, disabled, align, onSelect, }: AsyncComboboxProps): import("react/jsx-runtime").JSX.Element;
@@ -28,5 +28,5 @@ type Props = {
28
28
  renderPopupTrigger?: (valueElement: React.ReactNode, selectedValues: ComboboxFieldItem[]) => React.ReactElement;
29
29
  onInputChange?: (value: string) => void;
30
30
  };
31
- export declare const ComboboxField: ({ id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, items, label, multiple, hasClearButton, disabled, placeholder, containerClassName, emptyMessage, hasAllOption, allOptionLabel, inputMode, renderPopupTrigger, onInputChange, value, onValueChange, }: Props) => import("react/jsx-runtime").JSX.Element;
31
+ export declare const ComboboxField: ({ id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, items, label, multiple, hasClearButton, disabled, placeholder: placeholderProp, containerClassName, emptyMessage: emptyMessageProp, hasAllOption, allOptionLabel: allOptionLabelProp, inputMode, renderPopupTrigger, onInputChange, value, onValueChange, }: Props) => import("react/jsx-runtime").JSX.Element;
32
32
  export {};
@@ -15,5 +15,5 @@ type Props = {
15
15
  disabledCondition?: boolean | ((date: Date) => boolean);
16
16
  dateLocale?: Locale;
17
17
  };
18
- export declare const DateRangePicker: ({ id, start, end, onConfirm, className, triggerButtonClassName, popoverContentClassName, label, placeholder, confirmLabel, disabledCondition, dateLocale, }: Props) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const DateRangePicker: ({ id, start, end, onConfirm, className, triggerButtonClassName, popoverContentClassName, label, placeholder, confirmLabel: confirmLabelProp, disabledCondition, dateLocale, }: Props) => import("react/jsx-runtime").JSX.Element;
19
19
  export {};
@@ -8,5 +8,5 @@ type LogicalOperatorToggleProps = {
8
8
  andLabel?: string;
9
9
  orLabel?: string;
10
10
  };
11
- declare function LogicalOperatorToggle({ value, onValueChange, size, className, disabled, andLabel, orLabel, }: LogicalOperatorToggleProps): import("react/jsx-runtime").JSX.Element;
11
+ declare function LogicalOperatorToggle({ value, onValueChange, size, className, disabled, andLabel: andLabelProp, orLabel: orLabelProp, }: LogicalOperatorToggleProps): import("react/jsx-runtime").JSX.Element;
12
12
  export { LogicalOperatorToggle };
@@ -10,4 +10,4 @@ export interface ActionsProps {
10
10
  actions: ActionItem[];
11
11
  menuTriggerLabel?: string;
12
12
  }
13
- export declare const Actions: ({ actions, menuTriggerLabel }: ActionsProps) => import("react/jsx-runtime").JSX.Element | null;
13
+ export declare const Actions: ({ actions, menuTriggerLabel: menuTriggerLabelProp }: ActionsProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -3,5 +3,5 @@ interface ColumnVisibilityProps {
3
3
  allOptionLabel?: string;
4
4
  triggerLabel?: string;
5
5
  }
6
- export declare function ColumnVisibility({ emptyMessage, allOptionLabel, triggerLabel, }: ColumnVisibilityProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ColumnVisibility({ emptyMessage: emptyMessageProp, allOptionLabel: allOptionLabelProp, triggerLabel: triggerLabelProp, }: ColumnVisibilityProps): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -12,6 +12,6 @@ export declare const DataTable: {
12
12
  Search: typeof Search;
13
13
  ColumnVisibility: typeof ColumnVisibility;
14
14
  Content: typeof Content;
15
- Pagination: ({ showSelectedCount, showPaginationInfo, className, showPerPageLabel, selectPlaceholder, selectedCountText, paginationInfoText, }: import("./pagination").PaginationProps) => import("react/jsx-runtime").JSX.Element;
16
- Actions: ({ actions, menuTriggerLabel }: import("./actions").ActionsProps) => import("react/jsx-runtime").JSX.Element | null;
15
+ Pagination: ({ showSelectedCount, showPaginationInfo, className, showPerPageLabel: showPerPageLabelProp, selectPlaceholder: selectPlaceholderProp, selectedCountText: selectedCountTextProp, paginationInfoText: paginationInfoTextProp, }: import("./pagination").PaginationProps) => import("react/jsx-runtime").JSX.Element;
16
+ Actions: ({ actions, menuTriggerLabel: menuTriggerLabelProp }: import("./actions").ActionsProps) => import("react/jsx-runtime").JSX.Element | null;
17
17
  };
@@ -7,4 +7,4 @@ export interface PaginationProps {
7
7
  selectedCountText?: (selected: number, total: number) => string;
8
8
  paginationInfoText?: (start: number, end: number, total: number) => string;
9
9
  }
10
- export declare const Pagination: ({ showSelectedCount, showPaginationInfo, className, showPerPageLabel, selectPlaceholder, selectedCountText, paginationInfoText, }: PaginationProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const Pagination: ({ showSelectedCount, showPaginationInfo, className, showPerPageLabel: showPerPageLabelProp, selectPlaceholder: selectPlaceholderProp, selectedCountText: selectedCountTextProp, paginationInfoText: paginationInfoTextProp, }: PaginationProps) => import("react/jsx-runtime").JSX.Element;
@@ -5,5 +5,5 @@ interface SearchProps {
5
5
  label?: string;
6
6
  autoFocus?: boolean;
7
7
  }
8
- export declare function Search({ placeholder, filterColumn, className, label, autoFocus }: SearchProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Search({ placeholder: placeholderProp, filterColumn, className, label, autoFocus, }: SearchProps): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -8,4 +8,4 @@ export interface DatePresetProps {
8
8
  disabledCondition?: boolean | ((date: Date) => boolean);
9
9
  dateLocale?: Locale;
10
10
  }
11
- export declare function DatePreset({ presets, className, confirmLabel, placeholder, disabledCondition, dateLocale, }: DatePresetProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function DatePreset({ presets, className, confirmLabel: confirmLabelProp, placeholder: placeholderProp, disabledCondition, dateLocale, }: DatePresetProps): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import type { UiMessageId } from '../../../lib/ui-messages';
1
2
  export interface DateRange {
2
3
  from: Date;
3
4
  to: Date;
@@ -9,6 +10,8 @@ export interface DateRangeOptional {
9
10
  export interface DatePresetItem {
10
11
  key: string;
11
12
  label: string;
13
+ /** Built-in presets: id of the label in the library catalogue; the label is shown in the host's language. */
14
+ labelId?: UiMessageId;
12
15
  getRange: () => DateRange;
13
16
  }
14
17
  export declare const DATE_PRESETS: Record<string, DatePresetItem>;
@@ -17,5 +17,5 @@ type FormComboboxProps<TFieldValues extends FieldValues = FieldValues> = {
17
17
  control?: Control<TFieldValues>;
18
18
  inputMode?: 'input' | 'popup';
19
19
  };
20
- export declare const FormCombobox: <TFieldValues extends FieldValues = FieldValues>({ name, label, placeholder, items, description, multiple, emptyMessage, containerClassName, hasClearButton, hasAllOption, allOptionLabel, disabled, tooltipContent, control, inputMode, }: FormComboboxProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const FormCombobox: <TFieldValues extends FieldValues = FieldValues>({ name, label, placeholder, items, description, multiple, emptyMessage: emptyMessageProp, containerClassName, hasClearButton, hasAllOption, allOptionLabel: allOptionLabelProp, disabled, tooltipContent, control, inputMode, }: FormComboboxProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
21
21
  export {};
@@ -18,7 +18,7 @@ type FormFileUploadProps<TFieldValues extends FieldValues = FieldValues> = {
18
18
  onUpload?: (file: File) => Promise<string>;
19
19
  };
20
20
  export declare const FormFileUpload: {
21
- <TFieldValues extends FieldValues = FieldValues>({ name, control, label, uploadButtonLabel, uploadingLabel, uploadFailedMessage, removeFileButtonLabel, description, accept, disabled, multiple, containerClassName, tooltipContent, hasRequiredIndicator, onUpload, }: FormFileUploadProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
21
+ <TFieldValues extends FieldValues = FieldValues>({ name, control, label, uploadButtonLabel: uploadButtonLabelProp, uploadingLabel: uploadingLabelProp, uploadFailedMessage: uploadFailedMessageProp, removeFileButtonLabel: removeFileButtonLabelProp, description, accept, disabled, multiple, containerClassName, tooltipContent, hasRequiredIndicator, onUpload, }: FormFileUploadProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
22
22
  displayName: string;
23
23
  };
24
24
  export {};
@@ -12,5 +12,5 @@ type Props<TFieldValues extends FieldValues = FieldValues> = {
12
12
  showPasswordLabel?: string;
13
13
  hidePasswordLabel?: string;
14
14
  };
15
- export declare const FormPassword: <TFieldValues extends FieldValues = FieldValues>({ label, name, containerClassName, description, placeholder, tooltipContent, control, hasRequiredIndicator, showPasswordLabel, hidePasswordLabel, ...props }: Props<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const FormPassword: <TFieldValues extends FieldValues = FieldValues>({ label, name, containerClassName, description, placeholder, tooltipContent, control, hasRequiredIndicator, showPasswordLabel: showPasswordLabelProp, hidePasswordLabel: hidePasswordLabelProp, ...props }: Props<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
16
16
  export {};
@@ -0,0 +1,16 @@
1
+ import { type UiMessageId } from '../lib/ui-messages';
2
+ type Values = Record<string, string | number | boolean | null | undefined | Date>;
3
+ /** "tr-TR", "TR" → "tr"; empty → "en". */
4
+ export declare const normalizeUiLocale: (locale?: string | null) => string;
5
+ /**
6
+ * Translates the library's built-in texts with react-intl.
7
+ *
8
+ * - Language: the locale of the host's `IntlProvider` (English without one).
9
+ * - A host message with the same `ui.*` id wins over the built-in text. Add such an
10
+ * id in every language the host supports: hosts usually merge English under the
11
+ * other languages, so an id only in English would also replace the Turkish text.
12
+ * - Text props a component takes (`placeholder`, `label`, …) win over both.
13
+ * - Otherwise the library's own message for that language, then English.
14
+ */
15
+ export declare function useUiTranslation(): (id: UiMessageId, values?: Values) => string;
16
+ export {};
package/dist/index.d.ts CHANGED
@@ -107,3 +107,6 @@ export type { DatePresetProviderProps } from './components/organisms/date-preset
107
107
  export type { DatePresetContextValue } from './components/organisms/date-preset/context';
108
108
  export { useDataTable, type UseDataTableOptions, type UseDataTableReturn, type FetcherParams, type FetcherResponse, } from './hooks/use-data-table';
109
109
  export { cn, formatDate } from './lib/utils';
110
+ export { useUiTranslation, normalizeUiLocale } from './hooks/use-ui-translation';
111
+ export { uiMessages, UI_DEFAULT_LOCALE, type UiLocale, type UiMessageId } from './lib/ui-messages';
112
+ export { UiText } from './components/atoms/ui-text';
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Built-in texts of @segmentify/ui, in every language the library ships.
3
+ *
4
+ * Components read them through react-intl (see `useUiTranslation`): the host's
5
+ * `IntlProvider` locale picks the language, and a host can override any
6
+ * `ui.*` id by putting it in its own catalogue. Text props a component already
7
+ * takes (`placeholder`, `emptyMessage`, …) still win when they are passed.
8
+ */
9
+ declare const en: {
10
+ readonly 'ui.common.all': "All";
11
+ readonly 'ui.common.apply': "Apply";
12
+ readonly 'ui.common.close': "Close";
13
+ readonly 'ui.common.confirm': "Confirm";
14
+ readonly 'ui.common.loading': "Loading...";
15
+ readonly 'ui.common.loadingLabel': "Loading";
16
+ readonly 'ui.common.more': "More";
17
+ readonly 'ui.common.noResults': "No results.";
18
+ readonly 'ui.common.noResultsFound': "No results found.";
19
+ readonly 'ui.common.noResultsFoundShort': "No results found";
20
+ readonly 'ui.common.save': "Save";
21
+ readonly 'ui.common.search': "Search...";
22
+ readonly 'ui.common.select': "Select";
23
+ readonly 'ui.common.selectEllipsis': "Select...";
24
+ readonly 'ui.common.selectItem': "Select an item";
25
+ readonly 'ui.carousel.previousSlide': "Previous slide";
26
+ readonly 'ui.carousel.nextSlide': "Next slide";
27
+ readonly 'ui.command.title': "Command Palette";
28
+ readonly 'ui.command.description': "Search for a command to run...";
29
+ readonly 'ui.dataTable.allColumns': "All columns";
30
+ readonly 'ui.dataTable.manageColumns': "Manage visible columns";
31
+ readonly 'ui.dataTable.moreActions': "More actions";
32
+ readonly 'ui.dataTable.noColumns': "No columns found.";
33
+ readonly 'ui.dataTable.showPerPage': "Show Per Page";
34
+ readonly 'ui.dataTable.selectedCount': "{selected} of {total} row(s) selected.";
35
+ readonly 'ui.dataTable.paginationInfo': "{start} - {end} of {total}";
36
+ readonly 'ui.datePreset.placeholder': "Pick a date range";
37
+ readonly 'ui.datePreset.today': "Today";
38
+ readonly 'ui.datePreset.thisWeek': "This Week";
39
+ readonly 'ui.datePreset.last7Days': "Last 7 Days";
40
+ readonly 'ui.datePreset.thisMonth': "This Month";
41
+ readonly 'ui.datePreset.lastMonth': "Last Month";
42
+ readonly 'ui.datePreset.last30Days': "Last 30 Days";
43
+ readonly 'ui.fileUpload.upload': "Upload File";
44
+ readonly 'ui.fileUpload.uploading': "Uploading...";
45
+ readonly 'ui.fileUpload.failed': "Upload failed";
46
+ readonly 'ui.fileUpload.remove': "Remove file";
47
+ readonly 'ui.icon.label': "{name} icon";
48
+ readonly 'ui.logicalOperator.label': "Logical operator";
49
+ readonly 'ui.logicalOperator.and': "AND";
50
+ readonly 'ui.logicalOperator.or': "OR";
51
+ readonly 'ui.pagination.previous': "Previous";
52
+ readonly 'ui.pagination.next': "Next";
53
+ readonly 'ui.pagination.previousPage': "Go to previous page";
54
+ readonly 'ui.pagination.nextPage': "Go to next page";
55
+ readonly 'ui.pagination.firstPage': "Go to first page";
56
+ readonly 'ui.pagination.lastPage': "Go to last page";
57
+ readonly 'ui.pagination.morePages': "More pages";
58
+ readonly 'ui.pagination.currentPage': "Current page";
59
+ readonly 'ui.password.show': "Show password";
60
+ readonly 'ui.password.hide': "Hide password";
61
+ readonly 'ui.phone.searchCountry': "Search country...";
62
+ readonly 'ui.phone.noCountry': "No country found.";
63
+ readonly 'ui.recommendation.noAlgorithms': "No algorithms selected. Add one using the buttons above.";
64
+ readonly 'ui.recommendation.noValue': "No value";
65
+ readonly 'ui.recommendation.title': "Recommendation";
66
+ readonly 'ui.recommendation.description': "Manage your recommendation settings";
67
+ readonly 'ui.recommendation.shuffleProducts': "Shuffle Products";
68
+ readonly 'ui.recommendation.recommendOtherCategories': "Recommend Other Categories";
69
+ readonly 'ui.recommendation.shufflePromotions': "Shuffle Promotions";
70
+ readonly 'ui.recommendation.exclusionFilters': "Exclusion Filters";
71
+ readonly 'ui.recommendation.inclusionFilters': "Inclusion Filters";
72
+ readonly 'ui.recommendation.unknownAlgorithm': "Unknown Algorithm";
73
+ readonly 'ui.previewRichMedia.headerImageAlt': "Header";
74
+ readonly 'ui.sidebar.title': "Sidebar";
75
+ readonly 'ui.sidebar.description': "Displays the mobile sidebar.";
76
+ readonly 'ui.sidebar.toggle': "Toggle Sidebar";
77
+ readonly 'ui.sortable.dragToReorder': "Drag to reorder";
78
+ };
79
+ export type UiMessageId = keyof typeof en;
80
+ /** Languages the library ships texts for. */
81
+ export type UiLocale = 'en' | 'tr';
82
+ export declare const UI_DEFAULT_LOCALE: UiLocale;
83
+ export declare const uiMessages: Record<UiLocale, Record<UiMessageId, string>>;
84
+ export {};