@tastic/profile 0.14.0 → 0.15.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/dist/index.d.mts CHANGED
@@ -1,8 +1,54 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, RefObject, Ref } from 'react';
3
- import { SeedColor } from '@rific/auto-paper';
2
+ import { RefObject, ReactNode, Ref } from 'react';
4
3
  import { PopoverHost, PopoverRotation } from '@tastic/hud';
5
4
  import { View, StyleProp, ViewStyle } from 'react-native';
5
+ import { SeedColor } from '@rific/auto-paper';
6
+
7
+ interface ProfilePickerColorSection {
8
+ value: string;
9
+ onChange: (hex: string) => void;
10
+ previewValue?: (hex: string) => string;
11
+ swatches?: SeedColor[];
12
+ label?: string;
13
+ caption?: string;
14
+ takenValue?: string;
15
+ allowSwapTaken?: boolean;
16
+ }
17
+ interface ProfilePickerAlignResult {
18
+ align: 'left' | 'right' | 'center';
19
+ verticalAlign: 'below' | 'above';
20
+ maxHeight: number;
21
+ measured: boolean;
22
+ triggerRef: RefObject<View | null>;
23
+ }
24
+ interface ProfilePickerContentSize {
25
+ width: number;
26
+ height: number;
27
+ }
28
+
29
+ interface OptionPickerOption<T extends string> {
30
+ value: T;
31
+ label: string;
32
+ icon?: string;
33
+ }
34
+ declare function getOptionPickerContentSize(optionCount: number, colorSection?: Pick<ProfilePickerColorSection, 'swatches' | 'caption'>): ProfilePickerContentSize;
35
+ interface OptionPickerProps<T extends string> {
36
+ id: string;
37
+ host: PopoverHost;
38
+ options: OptionPickerOption<T>[];
39
+ value: T;
40
+ onChange: (value: T) => void;
41
+ color: string;
42
+ dark: boolean;
43
+ icon: string;
44
+ rowIcon?: string;
45
+ colorSection?: ProfilePickerColorSection;
46
+ align?: 'left' | 'right' | 'center';
47
+ alignOverride?: ProfilePickerAlignResult;
48
+ rotation?: PopoverRotation;
49
+ triggerStyle?: StyleProp<ViewStyle>;
50
+ }
51
+ declare function OptionPicker<T extends string>({ id, host, options, value, onChange, color, dark, icon, rowIcon, colorSection, align, alignOverride, rotation, triggerStyle }: OptionPickerProps<T>): react.JSX.Element;
6
52
 
7
53
  interface Profile {
8
54
  id: string;
@@ -28,25 +74,6 @@ declare function ProfileColorProvider({ preview, children }: ProfileColorProvide
28
74
  declare function useProfileColorPreview(): ((hex: string) => string) | undefined;
29
75
  declare function useProfileDisplayColor(hex: string): string;
30
76
 
31
- interface ProfilePickerColorSection {
32
- value: string;
33
- onChange: (hex: string) => void;
34
- previewValue?: (hex: string) => string;
35
- swatches?: SeedColor[];
36
- label?: string;
37
- caption?: string;
38
- }
39
- interface ProfilePickerAlignResult {
40
- align: 'left' | 'right' | 'center';
41
- verticalAlign: 'below' | 'above';
42
- maxHeight: number;
43
- measured: boolean;
44
- triggerRef: RefObject<View | null>;
45
- }
46
- interface ProfilePickerContentSize {
47
- width: number;
48
- height: number;
49
- }
50
77
  declare function getProfilePickerContentSize(profileCount: number, hasManageRow?: boolean, colorSection?: Pick<ProfilePickerColorSection, 'swatches' | 'caption'>): ProfilePickerContentSize;
51
78
  interface ProfilePickerProps<P extends Profile> {
52
79
  idPrefix: string;
@@ -67,7 +94,7 @@ interface ProfilePickerProps<P extends Profile> {
67
94
  colorSection?: ProfilePickerColorSection;
68
95
  triggerStyle?: StyleProp<ViewStyle>;
69
96
  }
70
- declare function ProfilePicker<P extends Profile>({ idPrefix, host, profiles, selectedId, takenId, color, dark, align: forcedAlign, alignOverride, rotation, guestLabel, nullLabel, nullIcon, onSelect, onManage, colorSection, triggerStyle }: ProfilePickerProps<P>): react.JSX.Element;
97
+ declare function ProfilePicker<P extends Profile>({ idPrefix, host, profiles, selectedId, takenId, color, dark, align, alignOverride, rotation, guestLabel, nullLabel, nullIcon, onSelect, onManage, colorSection, triggerStyle }: ProfilePickerProps<P>): react.JSX.Element;
71
98
 
72
99
  type MD3TextVariant$1 = 'displayLarge' | 'displayMedium' | 'displaySmall' | 'headlineLarge' | 'headlineMedium' | 'headlineSmall' | 'titleLarge' | 'titleMedium' | 'titleSmall' | 'labelLarge' | 'labelMedium' | 'labelSmall' | 'bodyLarge' | 'bodyMedium' | 'bodySmall';
73
100
  interface ProfileEditPatch {
@@ -189,19 +216,23 @@ interface SetLastGuestColorPayload<TSeat> {
189
216
  color: string;
190
217
  seat: TSeat;
191
218
  }
192
- interface SetProfileOverridePayload<TSeat> {
219
+ interface ProfileColorPick {
220
+ color: string;
221
+ profileColor: string;
222
+ }
223
+ interface SetProfileColorPayload {
224
+ profile: Pick<Profile, 'id' | 'color'>;
193
225
  color: string | null;
194
- seat: TSeat;
195
226
  }
196
227
  interface SeatColorsActions<TSeat> {
197
228
  setLastCpuColor: ActionCreator<string>;
198
229
  setLastGuestColor: ActionCreator<SetLastGuestColorPayload<TSeat>>;
199
- setProfileOverride: ActionCreator<SetProfileOverridePayload<TSeat>>;
230
+ setProfileColor: ActionCreator<SetProfileColorPayload>;
200
231
  }
201
232
  type SeatColorsState<TSeat extends string | number> = {
202
233
  lastCpuColor: string;
203
234
  lastGuestColor: Record<TSeat, string>;
204
- profileOverride: Record<TSeat, string | null>;
235
+ profileColors: Record<string, ProfileColorPick>;
205
236
  };
206
237
  interface SeatColorsSlice<TSeat extends string | number> {
207
238
  actions: SeatColorsActions<TSeat>;
@@ -210,6 +241,7 @@ interface SeatColorsSlice<TSeat extends string | number> {
210
241
  payload?: unknown;
211
242
  }) => SeatColorsState<TSeat>;
212
243
  }
244
+ declare function profileSeatColor(profile: Pick<Profile, 'id' | 'color'>, profileColors: Record<string, ProfileColorPick>): string;
213
245
  declare function createSeatColorsSlice<TSeat extends string | number>(namespace: string, defaultState: SeatColorsState<TSeat>, mountKey?: string): SeatColorsSlice<TSeat>;
214
246
 
215
247
  interface UseSharedProfilesSyncOptions {
@@ -228,4 +260,4 @@ declare function readSharedProfiles(groupId: string): Promise<Profile[] | null>;
228
260
  declare function loadSharedProfiles(groupId: string): Promise<Profile[]>;
229
261
  declare function saveSharedProfiles(groupId: string, profiles: Profile[]): Promise<void>;
230
262
 
231
- export { type CreateProfileInput, MAX_PROFILE_NAME_LENGTH, MAX_TAG_LENGTH, type Profile, ProfileChip, ProfileColorProvider, type ProfileEditPatch, type ProfileExtensionActions, type ProfileExtensionSlice, type ProfileExtensionState, ProfilePicker, type ProfilePickerAlignResult, type ProfilePickerColorSection, type ProfilePickerContentSize, type ProfileSelectionActions, type ProfileSelectionSlice, type ProfileSelectionState, ProfilesManager, type ProfilesManagerHandle, type ProfilesManagerProps, ProfilesScreen, type ProfilesScreenProps, type SeatColorsActions, type SeatColorsSlice, type SeatColorsState, type SelectProfilePayload, type SetLastGuestColorPayload, type SetProfileExtensionPayload, type SetProfileOverridePayload, type UpdateProfilePayload, type UseSharedProfilesSyncOptions, type UseSharedProfilesSyncResult, avoidSeatColorClash, createProfileExtensionSlice, createProfileRecord, createProfileSelectionSlice, createSeatColorsSlice, getProfilePickerContentSize, isSharedProfileStoreAvailable, isValidProfile, isValidTag, loadSharedProfiles, profilesActions, profilesReducer, readSharedProfiles, resolveInitialProfiles, saveSharedProfiles, useProfileColorPreview, useProfileDisplayColor, useSharedProfilesSync };
263
+ export { type CreateProfileInput, MAX_PROFILE_NAME_LENGTH, MAX_TAG_LENGTH, OptionPicker, type OptionPickerOption, type Profile, ProfileChip, type ProfileColorPick, ProfileColorProvider, type ProfileEditPatch, type ProfileExtensionActions, type ProfileExtensionSlice, type ProfileExtensionState, ProfilePicker, type ProfilePickerAlignResult, type ProfilePickerColorSection, type ProfilePickerContentSize, type ProfileSelectionActions, type ProfileSelectionSlice, type ProfileSelectionState, ProfilesManager, type ProfilesManagerHandle, type ProfilesManagerProps, ProfilesScreen, type ProfilesScreenProps, type SeatColorsActions, type SeatColorsSlice, type SeatColorsState, type SelectProfilePayload, type SetLastGuestColorPayload, type SetProfileColorPayload, type SetProfileExtensionPayload, type UpdateProfilePayload, type UseSharedProfilesSyncOptions, type UseSharedProfilesSyncResult, avoidSeatColorClash, createProfileExtensionSlice, createProfileRecord, createProfileSelectionSlice, createSeatColorsSlice, getOptionPickerContentSize, getProfilePickerContentSize, isSharedProfileStoreAvailable, isValidProfile, isValidTag, loadSharedProfiles, profileSeatColor, profilesActions, profilesReducer, readSharedProfiles, resolveInitialProfiles, saveSharedProfiles, useProfileColorPreview, useProfileDisplayColor, useSharedProfilesSync };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,54 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, RefObject, Ref } from 'react';
3
- import { SeedColor } from '@rific/auto-paper';
2
+ import { RefObject, ReactNode, Ref } from 'react';
4
3
  import { PopoverHost, PopoverRotation } from '@tastic/hud';
5
4
  import { View, StyleProp, ViewStyle } from 'react-native';
5
+ import { SeedColor } from '@rific/auto-paper';
6
+
7
+ interface ProfilePickerColorSection {
8
+ value: string;
9
+ onChange: (hex: string) => void;
10
+ previewValue?: (hex: string) => string;
11
+ swatches?: SeedColor[];
12
+ label?: string;
13
+ caption?: string;
14
+ takenValue?: string;
15
+ allowSwapTaken?: boolean;
16
+ }
17
+ interface ProfilePickerAlignResult {
18
+ align: 'left' | 'right' | 'center';
19
+ verticalAlign: 'below' | 'above';
20
+ maxHeight: number;
21
+ measured: boolean;
22
+ triggerRef: RefObject<View | null>;
23
+ }
24
+ interface ProfilePickerContentSize {
25
+ width: number;
26
+ height: number;
27
+ }
28
+
29
+ interface OptionPickerOption<T extends string> {
30
+ value: T;
31
+ label: string;
32
+ icon?: string;
33
+ }
34
+ declare function getOptionPickerContentSize(optionCount: number, colorSection?: Pick<ProfilePickerColorSection, 'swatches' | 'caption'>): ProfilePickerContentSize;
35
+ interface OptionPickerProps<T extends string> {
36
+ id: string;
37
+ host: PopoverHost;
38
+ options: OptionPickerOption<T>[];
39
+ value: T;
40
+ onChange: (value: T) => void;
41
+ color: string;
42
+ dark: boolean;
43
+ icon: string;
44
+ rowIcon?: string;
45
+ colorSection?: ProfilePickerColorSection;
46
+ align?: 'left' | 'right' | 'center';
47
+ alignOverride?: ProfilePickerAlignResult;
48
+ rotation?: PopoverRotation;
49
+ triggerStyle?: StyleProp<ViewStyle>;
50
+ }
51
+ declare function OptionPicker<T extends string>({ id, host, options, value, onChange, color, dark, icon, rowIcon, colorSection, align, alignOverride, rotation, triggerStyle }: OptionPickerProps<T>): react.JSX.Element;
6
52
 
7
53
  interface Profile {
8
54
  id: string;
@@ -28,25 +74,6 @@ declare function ProfileColorProvider({ preview, children }: ProfileColorProvide
28
74
  declare function useProfileColorPreview(): ((hex: string) => string) | undefined;
29
75
  declare function useProfileDisplayColor(hex: string): string;
30
76
 
31
- interface ProfilePickerColorSection {
32
- value: string;
33
- onChange: (hex: string) => void;
34
- previewValue?: (hex: string) => string;
35
- swatches?: SeedColor[];
36
- label?: string;
37
- caption?: string;
38
- }
39
- interface ProfilePickerAlignResult {
40
- align: 'left' | 'right' | 'center';
41
- verticalAlign: 'below' | 'above';
42
- maxHeight: number;
43
- measured: boolean;
44
- triggerRef: RefObject<View | null>;
45
- }
46
- interface ProfilePickerContentSize {
47
- width: number;
48
- height: number;
49
- }
50
77
  declare function getProfilePickerContentSize(profileCount: number, hasManageRow?: boolean, colorSection?: Pick<ProfilePickerColorSection, 'swatches' | 'caption'>): ProfilePickerContentSize;
51
78
  interface ProfilePickerProps<P extends Profile> {
52
79
  idPrefix: string;
@@ -67,7 +94,7 @@ interface ProfilePickerProps<P extends Profile> {
67
94
  colorSection?: ProfilePickerColorSection;
68
95
  triggerStyle?: StyleProp<ViewStyle>;
69
96
  }
70
- declare function ProfilePicker<P extends Profile>({ idPrefix, host, profiles, selectedId, takenId, color, dark, align: forcedAlign, alignOverride, rotation, guestLabel, nullLabel, nullIcon, onSelect, onManage, colorSection, triggerStyle }: ProfilePickerProps<P>): react.JSX.Element;
97
+ declare function ProfilePicker<P extends Profile>({ idPrefix, host, profiles, selectedId, takenId, color, dark, align, alignOverride, rotation, guestLabel, nullLabel, nullIcon, onSelect, onManage, colorSection, triggerStyle }: ProfilePickerProps<P>): react.JSX.Element;
71
98
 
72
99
  type MD3TextVariant$1 = 'displayLarge' | 'displayMedium' | 'displaySmall' | 'headlineLarge' | 'headlineMedium' | 'headlineSmall' | 'titleLarge' | 'titleMedium' | 'titleSmall' | 'labelLarge' | 'labelMedium' | 'labelSmall' | 'bodyLarge' | 'bodyMedium' | 'bodySmall';
73
100
  interface ProfileEditPatch {
@@ -189,19 +216,23 @@ interface SetLastGuestColorPayload<TSeat> {
189
216
  color: string;
190
217
  seat: TSeat;
191
218
  }
192
- interface SetProfileOverridePayload<TSeat> {
219
+ interface ProfileColorPick {
220
+ color: string;
221
+ profileColor: string;
222
+ }
223
+ interface SetProfileColorPayload {
224
+ profile: Pick<Profile, 'id' | 'color'>;
193
225
  color: string | null;
194
- seat: TSeat;
195
226
  }
196
227
  interface SeatColorsActions<TSeat> {
197
228
  setLastCpuColor: ActionCreator<string>;
198
229
  setLastGuestColor: ActionCreator<SetLastGuestColorPayload<TSeat>>;
199
- setProfileOverride: ActionCreator<SetProfileOverridePayload<TSeat>>;
230
+ setProfileColor: ActionCreator<SetProfileColorPayload>;
200
231
  }
201
232
  type SeatColorsState<TSeat extends string | number> = {
202
233
  lastCpuColor: string;
203
234
  lastGuestColor: Record<TSeat, string>;
204
- profileOverride: Record<TSeat, string | null>;
235
+ profileColors: Record<string, ProfileColorPick>;
205
236
  };
206
237
  interface SeatColorsSlice<TSeat extends string | number> {
207
238
  actions: SeatColorsActions<TSeat>;
@@ -210,6 +241,7 @@ interface SeatColorsSlice<TSeat extends string | number> {
210
241
  payload?: unknown;
211
242
  }) => SeatColorsState<TSeat>;
212
243
  }
244
+ declare function profileSeatColor(profile: Pick<Profile, 'id' | 'color'>, profileColors: Record<string, ProfileColorPick>): string;
213
245
  declare function createSeatColorsSlice<TSeat extends string | number>(namespace: string, defaultState: SeatColorsState<TSeat>, mountKey?: string): SeatColorsSlice<TSeat>;
214
246
 
215
247
  interface UseSharedProfilesSyncOptions {
@@ -228,4 +260,4 @@ declare function readSharedProfiles(groupId: string): Promise<Profile[] | null>;
228
260
  declare function loadSharedProfiles(groupId: string): Promise<Profile[]>;
229
261
  declare function saveSharedProfiles(groupId: string, profiles: Profile[]): Promise<void>;
230
262
 
231
- export { type CreateProfileInput, MAX_PROFILE_NAME_LENGTH, MAX_TAG_LENGTH, type Profile, ProfileChip, ProfileColorProvider, type ProfileEditPatch, type ProfileExtensionActions, type ProfileExtensionSlice, type ProfileExtensionState, ProfilePicker, type ProfilePickerAlignResult, type ProfilePickerColorSection, type ProfilePickerContentSize, type ProfileSelectionActions, type ProfileSelectionSlice, type ProfileSelectionState, ProfilesManager, type ProfilesManagerHandle, type ProfilesManagerProps, ProfilesScreen, type ProfilesScreenProps, type SeatColorsActions, type SeatColorsSlice, type SeatColorsState, type SelectProfilePayload, type SetLastGuestColorPayload, type SetProfileExtensionPayload, type SetProfileOverridePayload, type UpdateProfilePayload, type UseSharedProfilesSyncOptions, type UseSharedProfilesSyncResult, avoidSeatColorClash, createProfileExtensionSlice, createProfileRecord, createProfileSelectionSlice, createSeatColorsSlice, getProfilePickerContentSize, isSharedProfileStoreAvailable, isValidProfile, isValidTag, loadSharedProfiles, profilesActions, profilesReducer, readSharedProfiles, resolveInitialProfiles, saveSharedProfiles, useProfileColorPreview, useProfileDisplayColor, useSharedProfilesSync };
263
+ export { type CreateProfileInput, MAX_PROFILE_NAME_LENGTH, MAX_TAG_LENGTH, OptionPicker, type OptionPickerOption, type Profile, ProfileChip, type ProfileColorPick, ProfileColorProvider, type ProfileEditPatch, type ProfileExtensionActions, type ProfileExtensionSlice, type ProfileExtensionState, ProfilePicker, type ProfilePickerAlignResult, type ProfilePickerColorSection, type ProfilePickerContentSize, type ProfileSelectionActions, type ProfileSelectionSlice, type ProfileSelectionState, ProfilesManager, type ProfilesManagerHandle, type ProfilesManagerProps, ProfilesScreen, type ProfilesScreenProps, type SeatColorsActions, type SeatColorsSlice, type SeatColorsState, type SelectProfilePayload, type SetLastGuestColorPayload, type SetProfileColorPayload, type SetProfileExtensionPayload, type UpdateProfilePayload, type UseSharedProfilesSyncOptions, type UseSharedProfilesSyncResult, avoidSeatColorClash, createProfileExtensionSlice, createProfileRecord, createProfileSelectionSlice, createSeatColorsSlice, getOptionPickerContentSize, getProfilePickerContentSize, isSharedProfileStoreAvailable, isValidProfile, isValidTag, loadSharedProfiles, profileSeatColor, profilesActions, profilesReducer, readSharedProfiles, resolveInitialProfiles, saveSharedProfiles, useProfileColorPreview, useProfileDisplayColor, useSharedProfilesSync };