@flipdish/ui-library 0.40.0 → 0.41.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/components/atoms/FlipdishLogo/FlipdishLogo.styles.cjs +44 -0
- package/dist/components/atoms/FlipdishLogo/FlipdishLogo.styles.cjs.map +1 -0
- package/dist/components/atoms/FlipdishLogo/FlipdishLogo.styles.d.ts +71 -0
- package/dist/components/atoms/FlipdishLogo/FlipdishLogo.styles.d.ts.map +1 -0
- package/dist/components/atoms/FlipdishLogo/FlipdishLogo.styles.js +42 -0
- package/dist/components/atoms/FlipdishLogo/FlipdishLogo.styles.js.map +1 -0
- package/dist/components/atoms/FlipdishLogo/index.cjs +3 -24
- package/dist/components/atoms/FlipdishLogo/index.cjs.map +1 -1
- package/dist/components/atoms/FlipdishLogo/index.d.ts +5 -37
- package/dist/components/atoms/FlipdishLogo/index.d.ts.map +1 -1
- package/dist/components/atoms/FlipdishLogo/index.js +3 -24
- package/dist/components/atoms/FlipdishLogo/index.js.map +1 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.cjs +54 -0
- package/dist/components/organisms/CommandMenu/commandMenu.utils.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.d.ts +62 -0
- package/dist/components/organisms/CommandMenu/commandMenu.utils.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.js +53 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.js.map +1 -1
- package/dist/components/organisms/CommandMenu/hooks/useCommandItemHotkeys.cjs +43 -0
- package/dist/components/organisms/CommandMenu/hooks/useCommandItemHotkeys.cjs.map +1 -0
- package/dist/components/organisms/CommandMenu/hooks/useCommandItemHotkeys.d.ts +19 -0
- package/dist/components/organisms/CommandMenu/hooks/useCommandItemHotkeys.d.ts.map +1 -0
- package/dist/components/organisms/CommandMenu/hooks/useCommandItemHotkeys.js +41 -0
- package/dist/components/organisms/CommandMenu/hooks/useCommandItemHotkeys.js.map +1 -0
- package/dist/components/organisms/CommandMenu/index.cjs +2 -47
- package/dist/components/organisms/CommandMenu/index.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/index.js +4 -49
- package/dist/components/organisms/CommandMenu/index.js.map +1 -1
- package/dist/native/components/atoms/FlipdishLogo/FlipdishLogo.styles.d.ts +71 -0
- package/dist/native/components/atoms/FlipdishLogo/FlipdishLogo.styles.d.ts.map +1 -0
- package/dist/native/components/atoms/FlipdishLogo/FlipdishLogo.styles.js +42 -0
- package/dist/native/components/atoms/FlipdishLogo/FlipdishLogo.styles.js.map +1 -0
- package/dist/native/components/atoms/FlipdishLogo/flipdish-logo.paths.d.ts +7 -0
- package/dist/native/components/atoms/FlipdishLogo/flipdish-logo.paths.d.ts.map +1 -0
- package/dist/native/components/atoms/FlipdishLogo/flipdish-logo.paths.js +49 -0
- package/dist/native/components/atoms/FlipdishLogo/flipdish-logo.paths.js.map +1 -0
- package/dist/native/components/atoms/FlipdishLogo/index.d.ts +49 -9
- package/dist/native/components/atoms/FlipdishLogo/index.d.ts.map +1 -0
- package/dist/native/components/atoms/FlipdishLogo/index.js +25 -0
- package/dist/native/components/atoms/FlipdishLogo/index.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var flipdishLogo_paths = require('./flipdish-logo.paths.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared `FlipdishLogo` config for web and React Native.
|
|
7
|
+
*
|
|
8
|
+
* `sizes.className` is the Tailwind height utility web applies (`h-6` / `h-8` / `h-12`);
|
|
9
|
+
* `sizes.height` is the matching pixel height native needs — `react-native-svg` takes
|
|
10
|
+
* numeric `width`/`height`, and there is no `w-auto` analogue, so width is derived from
|
|
11
|
+
* the lockup's viewBox aspect ratio at render time.
|
|
12
|
+
*
|
|
13
|
+
* `tones.web` is a `text-*` utility that colours the SVG via `currentColor`. `tones.native`
|
|
14
|
+
* is a light-mode hex fill for `Path` — react-native-svg does not cascade `currentColor`,
|
|
15
|
+
* and token-driven colour on SVG hosts is not wired yet (same trade-off as Badge icons /
|
|
16
|
+
* ui-icons). `default` approximates `fg-primary` / `neutral-900`; it does not flip in dark
|
|
17
|
+
* mode. Use `white` or `black` when the surface needs a fixed colour.
|
|
18
|
+
*/
|
|
19
|
+
const styles = {
|
|
20
|
+
lockups: {
|
|
21
|
+
full: { paths: flipdishLogo_paths.FLIPDISH_FULL_PATHS, viewBox: flipdishLogo_paths.FLIPDISH_FULL_VIEWBOX, label: 'Flipdish' },
|
|
22
|
+
poweredBy: { paths: flipdishLogo_paths.FLIPDISH_POWERED_BY_PATHS, viewBox: flipdishLogo_paths.FLIPDISH_POWERED_BY_VIEWBOX, label: 'Powered by Flipdish' },
|
|
23
|
+
icon: { paths: flipdishLogo_paths.FLIPDISH_ICON_PATHS, viewBox: flipdishLogo_paths.FLIPDISH_ICON_VIEWBOX, label: 'Flipdish' },
|
|
24
|
+
},
|
|
25
|
+
sizes: {
|
|
26
|
+
/** 24px — compact headers, dense navigation, and footers. */
|
|
27
|
+
sm: { className: 'h-6', height: 24 },
|
|
28
|
+
/** 32px — the default, for headers, product pages, and inline sections. */
|
|
29
|
+
md: { className: 'h-8', height: 32 },
|
|
30
|
+
/** 48px — hero, splash, and login screens needing extra weight. */
|
|
31
|
+
lg: { className: 'h-12', height: 48 },
|
|
32
|
+
},
|
|
33
|
+
tones: {
|
|
34
|
+
/** Themeable on web — black on light surfaces, white in dark mode. Native: light-mode `#171717`. */
|
|
35
|
+
default: { web: 'text-fg-primary', native: '#171717' },
|
|
36
|
+
/** Always white, for dark or brand-coloured backgrounds. */
|
|
37
|
+
white: { web: 'text-fg-white', native: '#ffffff' },
|
|
38
|
+
/** Always black, regardless of theme. */
|
|
39
|
+
black: { web: 'text-black', native: '#000000' },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.styles = styles;
|
|
44
|
+
//# sourceMappingURL=FlipdishLogo.styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlipdishLogo.styles.cjs","sources":["../../../../src/components/atoms/FlipdishLogo/FlipdishLogo.styles.ts"],"sourcesContent":[null],"names":["FLIPDISH_FULL_PATHS","FLIPDISH_FULL_VIEWBOX","FLIPDISH_POWERED_BY_PATHS","FLIPDISH_POWERED_BY_VIEWBOX","FLIPDISH_ICON_PATHS","FLIPDISH_ICON_VIEWBOX"],"mappings":";;;;AASA;;;;;;;;;;;;;AAaG;AACI,MAAM,MAAM,GAAG;AACpB,IAAA,OAAO,EAAE;AACP,QAAA,IAAI,EAAE,EAAE,KAAK,EAAEA,sCAAmB,EAAE,OAAO,EAAEC,wCAAqB,EAAE,KAAK,EAAE,UAAU,EAAE;AACvF,QAAA,SAAS,EAAE,EAAE,KAAK,EAAEC,4CAAyB,EAAE,OAAO,EAAEC,8CAA2B,EAAE,KAAK,EAAE,qBAAqB,EAAE;AACnH,QAAA,IAAI,EAAE,EAAE,KAAK,EAAEC,sCAAmB,EAAE,OAAO,EAAEC,wCAAqB,EAAE,KAAK,EAAE,UAAU,EAAE;AACxF,KAAA;AACD,IAAA,KAAK,EAAE;;QAEL,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;;QAEpC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;;QAEpC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;AACtC,KAAA;AACD,IAAA,KAAK,EAAE;;QAEL,OAAO,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE;;QAEtD,KAAK,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE;;QAElD,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE;AAChD,KAAA;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `FlipdishLogo` config for web and React Native.
|
|
3
|
+
*
|
|
4
|
+
* `sizes.className` is the Tailwind height utility web applies (`h-6` / `h-8` / `h-12`);
|
|
5
|
+
* `sizes.height` is the matching pixel height native needs — `react-native-svg` takes
|
|
6
|
+
* numeric `width`/`height`, and there is no `w-auto` analogue, so width is derived from
|
|
7
|
+
* the lockup's viewBox aspect ratio at render time.
|
|
8
|
+
*
|
|
9
|
+
* `tones.web` is a `text-*` utility that colours the SVG via `currentColor`. `tones.native`
|
|
10
|
+
* is a light-mode hex fill for `Path` — react-native-svg does not cascade `currentColor`,
|
|
11
|
+
* and token-driven colour on SVG hosts is not wired yet (same trade-off as Badge icons /
|
|
12
|
+
* ui-icons). `default` approximates `fg-primary` / `neutral-900`; it does not flip in dark
|
|
13
|
+
* mode. Use `white` or `black` when the surface needs a fixed colour.
|
|
14
|
+
*/
|
|
15
|
+
export declare const styles: {
|
|
16
|
+
readonly lockups: {
|
|
17
|
+
readonly full: {
|
|
18
|
+
readonly paths: string[];
|
|
19
|
+
readonly viewBox: "0 0 163 48";
|
|
20
|
+
readonly label: "Flipdish";
|
|
21
|
+
};
|
|
22
|
+
readonly poweredBy: {
|
|
23
|
+
readonly paths: string[];
|
|
24
|
+
readonly viewBox: "0 0 150 48";
|
|
25
|
+
readonly label: "Powered by Flipdish";
|
|
26
|
+
};
|
|
27
|
+
readonly icon: {
|
|
28
|
+
readonly paths: string[];
|
|
29
|
+
readonly viewBox: "0 0 57 48";
|
|
30
|
+
readonly label: "Flipdish";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly sizes: {
|
|
34
|
+
/** 24px — compact headers, dense navigation, and footers. */
|
|
35
|
+
readonly sm: {
|
|
36
|
+
readonly className: "h-6";
|
|
37
|
+
readonly height: 24;
|
|
38
|
+
};
|
|
39
|
+
/** 32px — the default, for headers, product pages, and inline sections. */
|
|
40
|
+
readonly md: {
|
|
41
|
+
readonly className: "h-8";
|
|
42
|
+
readonly height: 32;
|
|
43
|
+
};
|
|
44
|
+
/** 48px — hero, splash, and login screens needing extra weight. */
|
|
45
|
+
readonly lg: {
|
|
46
|
+
readonly className: "h-12";
|
|
47
|
+
readonly height: 48;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
readonly tones: {
|
|
51
|
+
/** Themeable on web — black on light surfaces, white in dark mode. Native: light-mode `#171717`. */
|
|
52
|
+
readonly default: {
|
|
53
|
+
readonly web: "text-fg-primary";
|
|
54
|
+
readonly native: "#171717";
|
|
55
|
+
};
|
|
56
|
+
/** Always white, for dark or brand-coloured backgrounds. */
|
|
57
|
+
readonly white: {
|
|
58
|
+
readonly web: "text-fg-white";
|
|
59
|
+
readonly native: "#ffffff";
|
|
60
|
+
};
|
|
61
|
+
/** Always black, regardless of theme. */
|
|
62
|
+
readonly black: {
|
|
63
|
+
readonly web: "text-black";
|
|
64
|
+
readonly native: "#000000";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export type FlipdishLogoVariant = keyof typeof styles.lockups;
|
|
69
|
+
export type FlipdishLogoSize = keyof typeof styles.sizes;
|
|
70
|
+
export type FlipdishLogoTone = keyof typeof styles.tones;
|
|
71
|
+
//# sourceMappingURL=FlipdishLogo.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlipdishLogo.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/FlipdishLogo/FlipdishLogo.styles.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;QAOf,6DAA6D;;;;;QAE7D,2EAA2E;;;;;QAE3E,mEAAmE;;;;;;;QAInE,oGAAoG;;;;;QAEpG,4DAA4D;;;;;QAE5D,yCAAyC;;;;;;CAGnC,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,MAAM,CAAC,OAAO,CAAC;AAC9D,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,MAAM,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,MAAM,CAAC,KAAK,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FLIPDISH_ICON_VIEWBOX, FLIPDISH_ICON_PATHS, FLIPDISH_POWERED_BY_VIEWBOX, FLIPDISH_POWERED_BY_PATHS, FLIPDISH_FULL_VIEWBOX, FLIPDISH_FULL_PATHS } from './flipdish-logo.paths.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared `FlipdishLogo` config for web and React Native.
|
|
5
|
+
*
|
|
6
|
+
* `sizes.className` is the Tailwind height utility web applies (`h-6` / `h-8` / `h-12`);
|
|
7
|
+
* `sizes.height` is the matching pixel height native needs — `react-native-svg` takes
|
|
8
|
+
* numeric `width`/`height`, and there is no `w-auto` analogue, so width is derived from
|
|
9
|
+
* the lockup's viewBox aspect ratio at render time.
|
|
10
|
+
*
|
|
11
|
+
* `tones.web` is a `text-*` utility that colours the SVG via `currentColor`. `tones.native`
|
|
12
|
+
* is a light-mode hex fill for `Path` — react-native-svg does not cascade `currentColor`,
|
|
13
|
+
* and token-driven colour on SVG hosts is not wired yet (same trade-off as Badge icons /
|
|
14
|
+
* ui-icons). `default` approximates `fg-primary` / `neutral-900`; it does not flip in dark
|
|
15
|
+
* mode. Use `white` or `black` when the surface needs a fixed colour.
|
|
16
|
+
*/
|
|
17
|
+
const styles = {
|
|
18
|
+
lockups: {
|
|
19
|
+
full: { paths: FLIPDISH_FULL_PATHS, viewBox: FLIPDISH_FULL_VIEWBOX, label: 'Flipdish' },
|
|
20
|
+
poweredBy: { paths: FLIPDISH_POWERED_BY_PATHS, viewBox: FLIPDISH_POWERED_BY_VIEWBOX, label: 'Powered by Flipdish' },
|
|
21
|
+
icon: { paths: FLIPDISH_ICON_PATHS, viewBox: FLIPDISH_ICON_VIEWBOX, label: 'Flipdish' },
|
|
22
|
+
},
|
|
23
|
+
sizes: {
|
|
24
|
+
/** 24px — compact headers, dense navigation, and footers. */
|
|
25
|
+
sm: { className: 'h-6', height: 24 },
|
|
26
|
+
/** 32px — the default, for headers, product pages, and inline sections. */
|
|
27
|
+
md: { className: 'h-8', height: 32 },
|
|
28
|
+
/** 48px — hero, splash, and login screens needing extra weight. */
|
|
29
|
+
lg: { className: 'h-12', height: 48 },
|
|
30
|
+
},
|
|
31
|
+
tones: {
|
|
32
|
+
/** Themeable on web — black on light surfaces, white in dark mode. Native: light-mode `#171717`. */
|
|
33
|
+
default: { web: 'text-fg-primary', native: '#171717' },
|
|
34
|
+
/** Always white, for dark or brand-coloured backgrounds. */
|
|
35
|
+
white: { web: 'text-fg-white', native: '#ffffff' },
|
|
36
|
+
/** Always black, regardless of theme. */
|
|
37
|
+
black: { web: 'text-black', native: '#000000' },
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { styles };
|
|
42
|
+
//# sourceMappingURL=FlipdishLogo.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlipdishLogo.styles.js","sources":["../../../../src/components/atoms/FlipdishLogo/FlipdishLogo.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AASA;;;;;;;;;;;;;AAaG;AACI,MAAM,MAAM,GAAG;AACpB,IAAA,OAAO,EAAE;AACP,QAAA,IAAI,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,UAAU,EAAE;AACvF,QAAA,SAAS,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE,OAAO,EAAE,2BAA2B,EAAE,KAAK,EAAE,qBAAqB,EAAE;AACnH,QAAA,IAAI,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,UAAU,EAAE;AACxF,KAAA;AACD,IAAA,KAAK,EAAE;;QAEL,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;;QAEpC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;;QAEpC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;AACtC,KAAA;AACD,IAAA,KAAK,EAAE;;QAEL,OAAO,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE;;QAEtD,KAAK,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE;;QAElD,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE;AAChD,KAAA;;;"}
|
|
@@ -3,29 +3,8 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
5
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
-
var
|
|
6
|
+
var FlipdishLogo_styles = require('./FlipdishLogo.styles.cjs');
|
|
7
7
|
|
|
8
|
-
const LOCKUPS = {
|
|
9
|
-
full: { paths: flipdishLogo_paths.FLIPDISH_FULL_PATHS, viewBox: flipdishLogo_paths.FLIPDISH_FULL_VIEWBOX, label: 'Flipdish' },
|
|
10
|
-
poweredBy: { paths: flipdishLogo_paths.FLIPDISH_POWERED_BY_PATHS, viewBox: flipdishLogo_paths.FLIPDISH_POWERED_BY_VIEWBOX, label: 'Powered by Flipdish' },
|
|
11
|
-
icon: { paths: flipdishLogo_paths.FLIPDISH_ICON_PATHS, viewBox: flipdishLogo_paths.FLIPDISH_ICON_VIEWBOX, label: 'Flipdish' },
|
|
12
|
-
};
|
|
13
|
-
const SIZE_CLASS = {
|
|
14
|
-
/** 24px — compact headers, dense navigation, and footers. */
|
|
15
|
-
sm: 'h-6',
|
|
16
|
-
/** 32px — the default, for headers, product pages, and inline sections. */
|
|
17
|
-
md: 'h-8',
|
|
18
|
-
/** 48px — hero, splash, and login screens needing extra weight. */
|
|
19
|
-
lg: 'h-12',
|
|
20
|
-
};
|
|
21
|
-
const TONE_CLASS = {
|
|
22
|
-
/** Themeable — black on light surfaces, white in dark mode. */
|
|
23
|
-
default: 'text-fg-primary',
|
|
24
|
-
/** Always white, for dark or brand-coloured backgrounds. */
|
|
25
|
-
white: 'text-fg-white',
|
|
26
|
-
/** Always black, regardless of theme. */
|
|
27
|
-
black: 'text-black',
|
|
28
|
-
};
|
|
29
8
|
/**
|
|
30
9
|
* The official Flipdish logo: the swift icon mark with the `flipdish` wordmark, picked with
|
|
31
10
|
* `variant` and sized with `size`. It fills with `currentColor`, so it inherits the
|
|
@@ -34,9 +13,9 @@ const TONE_CLASS = {
|
|
|
34
13
|
* @summary official Flipdish icon mark and wordmark
|
|
35
14
|
*/
|
|
36
15
|
const FlipdishLogo = ({ className, variant = 'full', size = 'md', tone = 'default', 'data-testid': dataTestId, ...props }) => {
|
|
37
|
-
const { paths, viewBox, label } =
|
|
16
|
+
const { paths, viewBox, label } = FlipdishLogo_styles.styles.lockups[variant];
|
|
38
17
|
const flipdishLogoTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'flipdish-logo', rootName: 'flipdish-logo' });
|
|
39
|
-
return (jsxRuntime.jsxs("svg", { viewBox: viewBox, fill: "none", role: "img", className: cx.cx('w-auto',
|
|
18
|
+
return (jsxRuntime.jsxs("svg", { viewBox: viewBox, fill: "none", role: "img", className: cx.cx('w-auto', FlipdishLogo_styles.styles.sizes[size].className, FlipdishLogo_styles.styles.tones[tone].web, className), ...props, "data-testid": flipdishLogoTestId, children: [jsxRuntime.jsx("title", { children: label }), paths.map((d) => (jsxRuntime.jsx("path", { d: d, fill: "currentColor" }, d)))] }));
|
|
40
19
|
};
|
|
41
20
|
|
|
42
21
|
exports.FlipdishLogo = FlipdishLogo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/FlipdishLogo/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/FlipdishLogo/index.tsx"],"sourcesContent":[null],"names":["styles","useResolvedTestId","_jsxs","cx","_jsx"],"mappings":";;;;;;;AAoCA;;;;;;AAMG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,SAAS,EACT,OAAO,GAAG,MAAM,EAChB,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,SAAS,EAChB,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAGA,0BAAM,CAAC,OAAO,CAAC,OAAO,CAAC;AACzD,IAAA,MAAM,kBAAkB,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AAEzH,IAAA,QACEC,eAAA,CAAA,KAAA,EAAA,EACE,OAAO,EAAE,OAAO,EAChB,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,KAAK,EACV,SAAS,EAAEC,KAAE,CAAC,QAAQ,EAAEH,0BAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAEA,0BAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,EAAA,GACpF,KAAK,EAAA,aAAA,EACI,kBAAkB,EAAA,QAAA,EAAA,CAE/BI,cAAA,CAAA,OAAA,EAAA,EAAA,QAAA,EAAQ,KAAK,EAAA,CAAS,EACrB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MACXA,cAAA,CAAA,MAAA,EAAA,EAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAC,cAAc,EAAA,EAA5B,CAAC,CAA8B,CAC3C,CAAC,CAAA,EAAA,CACE;AAEV;;"}
|
|
@@ -1,37 +1,6 @@
|
|
|
1
1
|
import type { SVGProps } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly paths: string[];
|
|
5
|
-
readonly viewBox: "0 0 163 48";
|
|
6
|
-
readonly label: "Flipdish";
|
|
7
|
-
};
|
|
8
|
-
readonly poweredBy: {
|
|
9
|
-
readonly paths: string[];
|
|
10
|
-
readonly viewBox: "0 0 150 48";
|
|
11
|
-
readonly label: "Powered by Flipdish";
|
|
12
|
-
};
|
|
13
|
-
readonly icon: {
|
|
14
|
-
readonly paths: string[];
|
|
15
|
-
readonly viewBox: "0 0 57 48";
|
|
16
|
-
readonly label: "Flipdish";
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
declare const SIZE_CLASS: {
|
|
20
|
-
/** 24px — compact headers, dense navigation, and footers. */
|
|
21
|
-
readonly sm: "h-6";
|
|
22
|
-
/** 32px — the default, for headers, product pages, and inline sections. */
|
|
23
|
-
readonly md: "h-8";
|
|
24
|
-
/** 48px — hero, splash, and login screens needing extra weight. */
|
|
25
|
-
readonly lg: "h-12";
|
|
26
|
-
};
|
|
27
|
-
declare const TONE_CLASS: {
|
|
28
|
-
/** Themeable — black on light surfaces, white in dark mode. */
|
|
29
|
-
readonly default: "text-fg-primary";
|
|
30
|
-
/** Always white, for dark or brand-coloured backgrounds. */
|
|
31
|
-
readonly white: "text-fg-white";
|
|
32
|
-
/** Always black, regardless of theme. */
|
|
33
|
-
readonly black: "text-black";
|
|
34
|
-
};
|
|
2
|
+
import { type FlipdishLogoSize, type FlipdishLogoTone, type FlipdishLogoVariant } from './FlipdishLogo.styles';
|
|
3
|
+
export type { FlipdishLogoSize, FlipdishLogoTone, FlipdishLogoVariant } from './FlipdishLogo.styles';
|
|
35
4
|
export interface FlipdishLogoProps extends Omit<SVGProps<SVGSVGElement>, 'fill'> {
|
|
36
5
|
/**
|
|
37
6
|
* Which lockup to render.
|
|
@@ -40,13 +9,13 @@ export interface FlipdishLogoProps extends Omit<SVGProps<SVGSVGElement>, 'fill'>
|
|
|
40
9
|
* - `icon` — the icon mark (swift) only, for tight or square surfaces.
|
|
41
10
|
* @default 'full'
|
|
42
11
|
*/
|
|
43
|
-
variant?:
|
|
12
|
+
variant?: FlipdishLogoVariant;
|
|
44
13
|
/**
|
|
45
14
|
* Preset height: `sm` 24px, `md` 32px, `lg` 48px. For a one-off size, pass a
|
|
46
15
|
* height utility via `className` (it overrides the preset).
|
|
47
16
|
* @default 'md'
|
|
48
17
|
*/
|
|
49
|
-
size?:
|
|
18
|
+
size?: FlipdishLogoSize;
|
|
50
19
|
/**
|
|
51
20
|
* Logo colour.
|
|
52
21
|
* - `default` — follows the theme (black on light surfaces, white in dark mode).
|
|
@@ -54,7 +23,7 @@ export interface FlipdishLogoProps extends Omit<SVGProps<SVGSVGElement>, 'fill'>
|
|
|
54
23
|
* - `black` — always black, regardless of theme.
|
|
55
24
|
* @default 'default'
|
|
56
25
|
*/
|
|
57
|
-
tone?:
|
|
26
|
+
tone?: FlipdishLogoTone;
|
|
58
27
|
/** Overrides the `data-testid` (defaults to `fd-flipdish-logo`). */
|
|
59
28
|
'data-testid'?: string;
|
|
60
29
|
}
|
|
@@ -66,5 +35,4 @@ export interface FlipdishLogoProps extends Omit<SVGProps<SVGSVGElement>, 'fill'>
|
|
|
66
35
|
* @summary official Flipdish icon mark and wordmark
|
|
67
36
|
*/
|
|
68
37
|
export declare const FlipdishLogo: ({ className, variant, size, tone, "data-testid": dataTestId, ...props }: FlipdishLogoProps) => import("react").JSX.Element;
|
|
69
|
-
export {};
|
|
70
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/FlipdishLogo/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/FlipdishLogo/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,mBAAmB,EAAU,MAAM,uBAAuB,CAAC;AAEvH,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAErG,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAC9E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B;;;;OAIG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,yEAO1B,iBAAiB,gCAmBnB,CAAC"}
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
3
|
import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
-
import {
|
|
4
|
+
import { styles } from './FlipdishLogo.styles.js';
|
|
5
5
|
|
|
6
|
-
const LOCKUPS = {
|
|
7
|
-
full: { paths: FLIPDISH_FULL_PATHS, viewBox: FLIPDISH_FULL_VIEWBOX, label: 'Flipdish' },
|
|
8
|
-
poweredBy: { paths: FLIPDISH_POWERED_BY_PATHS, viewBox: FLIPDISH_POWERED_BY_VIEWBOX, label: 'Powered by Flipdish' },
|
|
9
|
-
icon: { paths: FLIPDISH_ICON_PATHS, viewBox: FLIPDISH_ICON_VIEWBOX, label: 'Flipdish' },
|
|
10
|
-
};
|
|
11
|
-
const SIZE_CLASS = {
|
|
12
|
-
/** 24px — compact headers, dense navigation, and footers. */
|
|
13
|
-
sm: 'h-6',
|
|
14
|
-
/** 32px — the default, for headers, product pages, and inline sections. */
|
|
15
|
-
md: 'h-8',
|
|
16
|
-
/** 48px — hero, splash, and login screens needing extra weight. */
|
|
17
|
-
lg: 'h-12',
|
|
18
|
-
};
|
|
19
|
-
const TONE_CLASS = {
|
|
20
|
-
/** Themeable — black on light surfaces, white in dark mode. */
|
|
21
|
-
default: 'text-fg-primary',
|
|
22
|
-
/** Always white, for dark or brand-coloured backgrounds. */
|
|
23
|
-
white: 'text-fg-white',
|
|
24
|
-
/** Always black, regardless of theme. */
|
|
25
|
-
black: 'text-black',
|
|
26
|
-
};
|
|
27
6
|
/**
|
|
28
7
|
* The official Flipdish logo: the swift icon mark with the `flipdish` wordmark, picked with
|
|
29
8
|
* `variant` and sized with `size`. It fills with `currentColor`, so it inherits the
|
|
@@ -32,9 +11,9 @@ const TONE_CLASS = {
|
|
|
32
11
|
* @summary official Flipdish icon mark and wordmark
|
|
33
12
|
*/
|
|
34
13
|
const FlipdishLogo = ({ className, variant = 'full', size = 'md', tone = 'default', 'data-testid': dataTestId, ...props }) => {
|
|
35
|
-
const { paths, viewBox, label } =
|
|
14
|
+
const { paths, viewBox, label } = styles.lockups[variant];
|
|
36
15
|
const flipdishLogoTestId = useResolvedTestId({ testId: dataTestId, segment: 'flipdish-logo', rootName: 'flipdish-logo' });
|
|
37
|
-
return (jsxs("svg", { viewBox: viewBox, fill: "none", role: "img", className: cx('w-auto',
|
|
16
|
+
return (jsxs("svg", { viewBox: viewBox, fill: "none", role: "img", className: cx('w-auto', styles.sizes[size].className, styles.tones[tone].web, className), ...props, "data-testid": flipdishLogoTestId, children: [jsx("title", { children: label }), paths.map((d) => (jsx("path", { d: d, fill: "currentColor" }, d)))] }));
|
|
38
17
|
};
|
|
39
18
|
|
|
40
19
|
export { FlipdishLogo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/FlipdishLogo/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/FlipdishLogo/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;AAoCA;;;;;;AAMG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,SAAS,EACT,OAAO,GAAG,MAAM,EAChB,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,SAAS,EAChB,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;AACzD,IAAA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AAEzH,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,OAAO,EAAE,OAAO,EAChB,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,KAAK,EACV,SAAS,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,EAAA,GACpF,KAAK,EAAA,aAAA,EACI,kBAAkB,EAAA,QAAA,EAAA,CAE/BC,GAAA,CAAA,OAAA,EAAA,EAAA,QAAA,EAAQ,KAAK,EAAA,CAAS,EACrB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MACXA,GAAA,CAAA,MAAA,EAAA,EAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAC,cAAc,EAAA,EAA5B,CAAC,CAA8B,CAC3C,CAAC,CAAA,EAAA,CACE;AAEV;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var hotkeys_utils = require('../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Compares two values to determine if they are deeply equal.
|
|
5
7
|
*
|
|
@@ -30,6 +32,58 @@ const isDeepEqual = (obj1, obj2) => {
|
|
|
30
32
|
}
|
|
31
33
|
return true;
|
|
32
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Turns menu items into the hotkey registrations `CommandMenu` installs.
|
|
37
|
+
* Disabled items and disabled keys are left out, and an empty shortcut registers nothing.
|
|
38
|
+
*
|
|
39
|
+
* @param items Flat menu items, in display order.
|
|
40
|
+
* @param disabledKeys Ids the list treats as disabled, in addition to each item's `isDisabled`.
|
|
41
|
+
* @returns The hotkey strings to register for each triggerable kind, plus whether any shortcut can never fire.
|
|
42
|
+
*/
|
|
43
|
+
const planCommandItemHotkeys = (items, disabledKeys) => {
|
|
44
|
+
const disabled = new Set(disabledKeys);
|
|
45
|
+
const registered = [];
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
if (item.isDisabled || disabled.has(item.id))
|
|
48
|
+
continue;
|
|
49
|
+
const steps = hotkeys_utils.toHotkeySteps(item.shortcutKeys ?? []);
|
|
50
|
+
if (steps.length === 0)
|
|
51
|
+
continue;
|
|
52
|
+
registered.push({ id: item.id, steps, kind: hotkeys_utils.getItemHotkeyKind(steps) });
|
|
53
|
+
}
|
|
54
|
+
const ofKind = (kind) => registered.filter((entry) => entry.kind === kind);
|
|
55
|
+
// Registering a hotkey twice would run the handler twice for one keypress.
|
|
56
|
+
const unique = (kind) => [...new Set(ofKind(kind).map((entry) => entry.steps[0]))];
|
|
57
|
+
return {
|
|
58
|
+
combination: unique('combination'),
|
|
59
|
+
guarded: unique('guarded'),
|
|
60
|
+
typed: ofKind('typed'),
|
|
61
|
+
matchable: registered.filter((entry) => entry.kind === 'combination' || entry.kind === 'guarded'),
|
|
62
|
+
hasUnsupported: ofKind('unsupported').length > 0,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
// `hotkeysEvent` carries fields (e.g. `metadata`) the vendored parser never produces, so compare only the identifying ones.
|
|
66
|
+
const hotkeyMatches = (step, fired) => {
|
|
67
|
+
const parsed = hotkeys_utils.parseHotkey(step);
|
|
68
|
+
return (parsed.hotkey.trim().toLowerCase() === fired.hotkey?.trim().toLowerCase() &&
|
|
69
|
+
parsed.isSequence === fired.isSequence &&
|
|
70
|
+
parsed.alt === fired.alt &&
|
|
71
|
+
parsed.ctrl === fired.ctrl &&
|
|
72
|
+
parsed.shift === fired.shift &&
|
|
73
|
+
parsed.meta === fired.meta &&
|
|
74
|
+
parsed.mod === fired.mod &&
|
|
75
|
+
isDeepEqual(parsed.keys, fired.keys));
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The item a fired combination or guarded hotkey selects.
|
|
79
|
+
*
|
|
80
|
+
* @param matchable Combination and guarded registrations, in source order. A typed or unsupported entry never matches.
|
|
81
|
+
* @param fired The event `react-hotkeys-hook` reports for the key that was pressed.
|
|
82
|
+
* @returns The first matching registration, or `undefined` when the key selects nothing.
|
|
83
|
+
*/
|
|
84
|
+
const findCommandItemForHotkey = (matchable, fired) => matchable.find((entry) => (entry.kind === 'combination' || entry.kind === 'guarded') && hotkeyMatches(entry.steps[0], fired));
|
|
33
85
|
|
|
86
|
+
exports.findCommandItemForHotkey = findCommandItemForHotkey;
|
|
34
87
|
exports.isDeepEqual = isDeepEqual;
|
|
88
|
+
exports.planCommandItemHotkeys = planCommandItemHotkeys;
|
|
35
89
|
//# sourceMappingURL=commandMenu.utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandMenu.utils.cjs","sources":["../../../../src/components/organisms/CommandMenu/commandMenu.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commandMenu.utils.cjs","sources":["../../../../src/components/organisms/CommandMenu/commandMenu.utils.ts"],"sourcesContent":[null],"names":["toHotkeySteps","getItemHotkeyKind","parseHotkey"],"mappings":";;;;AAmDA;;;;;;;AAOG;AACH;MACa,WAAW,GAAG,CAAC,IAAS,EAAE,IAAS,KAAa;;IAE3D,IAAI,IAAI,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;;AAG9B,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE;AAC1F,QAAA,OAAO,KAAK;IACd;;IAGA,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;;AAG/C,IAAA,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;QACvB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;AAC9D,YAAA,OAAO,KAAK;QACd;IACF;AAEA,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;;AAOG;MACU,sBAAsB,GAAG,CAAC,KAAmC,EAAE,YAAwC,KAAuB;AACzI,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,MAAM,UAAU,GAAwB,EAAE;AAE1C,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC,GAAG,CAAC,IA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AACzE,QAAA,MAAM,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU;AACtC,QAAA,MAAM,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;AACxB,QAAA,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;AAC1B,QAAA,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK;AAC5B,QAAA,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;AAC1B,QAAA,MAAM,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG;QACxB,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;AAExC,CAAC;AAED;;;;;;AAMG;MACU,wBAAwB,GAAG,CAAC,SAAuC,EAAE,KAAkB,KAClG,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,KAAK,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;;;;"}
|
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
/** How an item shortcut can be triggered. Matches `getItemHotkeyKind`. */
|
|
2
|
+
export type CommandHotkeyKind = 'combination' | 'guarded' | 'typed' | 'unsupported';
|
|
3
|
+
/** A menu item that may register a shortcut. */
|
|
4
|
+
export interface CommandHotkeyItem {
|
|
5
|
+
/** Id reported through `onSelectionChange` when the shortcut fires. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Skips registration, the same way a disabled list key does. */
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
/** Shortcut entries in hook format or symbol shorthand. Empty and missing shortcuts register nothing. */
|
|
10
|
+
shortcutKeys?: string[];
|
|
11
|
+
}
|
|
12
|
+
/** One registered shortcut, in the order the item appeared. */
|
|
13
|
+
export interface CommandItemHotkey {
|
|
14
|
+
/** Id reported through `onSelectionChange` when the shortcut fires. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Hook-format steps from `toHotkeySteps`. */
|
|
17
|
+
steps: string[];
|
|
18
|
+
/** How the shortcut can be triggered. */
|
|
19
|
+
kind: CommandHotkeyKind;
|
|
20
|
+
}
|
|
21
|
+
/** The hotkey strings and items `CommandMenu` registers from its items. */
|
|
22
|
+
export interface CommandHotkeyPlan {
|
|
23
|
+
/** Combination hotkeys, each registered once. */
|
|
24
|
+
combination: string[];
|
|
25
|
+
/** Guarded hotkeys, each registered once. */
|
|
26
|
+
guarded: string[];
|
|
27
|
+
/** Typed shortcuts in source order. The sequence index selects `id`. */
|
|
28
|
+
typed: CommandItemHotkey[];
|
|
29
|
+
/** Combination and guarded shortcuts, in source order. The first match wins. */
|
|
30
|
+
matchable: CommandItemHotkey[];
|
|
31
|
+
/** Whether any shortcut is drawn but can never be triggered. */
|
|
32
|
+
hasUnsupported: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The fields of a fired hotkey that identify it. Extra event fields are ignored. */
|
|
35
|
+
interface FiredHotkey {
|
|
36
|
+
hotkey?: string;
|
|
37
|
+
isSequence?: boolean;
|
|
38
|
+
alt?: boolean;
|
|
39
|
+
ctrl?: boolean;
|
|
40
|
+
shift?: boolean;
|
|
41
|
+
meta?: boolean;
|
|
42
|
+
mod?: boolean;
|
|
43
|
+
keys?: readonly string[] | null;
|
|
44
|
+
}
|
|
1
45
|
/**
|
|
2
46
|
* Compares two values to determine if they are deeply equal.
|
|
3
47
|
*
|
|
@@ -7,4 +51,22 @@
|
|
|
7
51
|
* @returns True if the values are deeply equal, otherwise false.
|
|
8
52
|
*/
|
|
9
53
|
export declare const isDeepEqual: (obj1: any, obj2: any) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Turns menu items into the hotkey registrations `CommandMenu` installs.
|
|
56
|
+
* Disabled items and disabled keys are left out, and an empty shortcut registers nothing.
|
|
57
|
+
*
|
|
58
|
+
* @param items Flat menu items, in display order.
|
|
59
|
+
* @param disabledKeys Ids the list treats as disabled, in addition to each item's `isDisabled`.
|
|
60
|
+
* @returns The hotkey strings to register for each triggerable kind, plus whether any shortcut can never fire.
|
|
61
|
+
*/
|
|
62
|
+
export declare const planCommandItemHotkeys: (items: readonly CommandHotkeyItem[], disabledKeys?: Iterable<string | number>) => CommandHotkeyPlan;
|
|
63
|
+
/**
|
|
64
|
+
* The item a fired combination or guarded hotkey selects.
|
|
65
|
+
*
|
|
66
|
+
* @param matchable Combination and guarded registrations, in source order. A typed or unsupported entry never matches.
|
|
67
|
+
* @param fired The event `react-hotkeys-hook` reports for the key that was pressed.
|
|
68
|
+
* @returns The first matching registration, or `undefined` when the key selects nothing.
|
|
69
|
+
*/
|
|
70
|
+
export declare const findCommandItemForHotkey: (matchable: readonly CommandItemHotkey[], fired: FiredHotkey) => CommandItemHotkey | undefined;
|
|
71
|
+
export {};
|
|
10
72
|
//# sourceMappingURL=commandMenu.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandMenu.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/CommandMenu/commandMenu.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commandMenu.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/CommandMenu/commandMenu.utils.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEpF,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yGAAyG;IACzG,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yCAAyC;IACzC,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,wEAAwE;IACxE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,gFAAgF;IAChF,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,gEAAgE;IAChE,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,qFAAqF;AACrF,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;GAOG;AAEH,eAAO,MAAM,WAAW,GAAI,MAAM,GAAG,EAAE,MAAM,GAAG,KAAG,OAsBlD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,SAAS,iBAAiB,EAAE,EAAE,eAAe,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,KAAG,iBAsBtH,CAAC;AAkBF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,WAAW,SAAS,iBAAiB,EAAE,EAAE,OAAO,WAAW,KAAG,iBAAiB,GAAG,SACI,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { toHotkeySteps, getItemHotkeyKind, parseHotkey } from '../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Compares two values to determine if they are deeply equal.
|
|
3
5
|
*
|
|
@@ -28,6 +30,56 @@ const isDeepEqual = (obj1, obj2) => {
|
|
|
28
30
|
}
|
|
29
31
|
return true;
|
|
30
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Turns menu items into the hotkey registrations `CommandMenu` installs.
|
|
35
|
+
* Disabled items and disabled keys are left out, and an empty shortcut registers nothing.
|
|
36
|
+
*
|
|
37
|
+
* @param items Flat menu items, in display order.
|
|
38
|
+
* @param disabledKeys Ids the list treats as disabled, in addition to each item's `isDisabled`.
|
|
39
|
+
* @returns The hotkey strings to register for each triggerable kind, plus whether any shortcut can never fire.
|
|
40
|
+
*/
|
|
41
|
+
const planCommandItemHotkeys = (items, disabledKeys) => {
|
|
42
|
+
const disabled = new Set(disabledKeys);
|
|
43
|
+
const registered = [];
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
if (item.isDisabled || disabled.has(item.id))
|
|
46
|
+
continue;
|
|
47
|
+
const steps = toHotkeySteps(item.shortcutKeys ?? []);
|
|
48
|
+
if (steps.length === 0)
|
|
49
|
+
continue;
|
|
50
|
+
registered.push({ id: item.id, steps, kind: getItemHotkeyKind(steps) });
|
|
51
|
+
}
|
|
52
|
+
const ofKind = (kind) => registered.filter((entry) => entry.kind === kind);
|
|
53
|
+
// Registering a hotkey twice would run the handler twice for one keypress.
|
|
54
|
+
const unique = (kind) => [...new Set(ofKind(kind).map((entry) => entry.steps[0]))];
|
|
55
|
+
return {
|
|
56
|
+
combination: unique('combination'),
|
|
57
|
+
guarded: unique('guarded'),
|
|
58
|
+
typed: ofKind('typed'),
|
|
59
|
+
matchable: registered.filter((entry) => entry.kind === 'combination' || entry.kind === 'guarded'),
|
|
60
|
+
hasUnsupported: ofKind('unsupported').length > 0,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
// `hotkeysEvent` carries fields (e.g. `metadata`) the vendored parser never produces, so compare only the identifying ones.
|
|
64
|
+
const hotkeyMatches = (step, fired) => {
|
|
65
|
+
const parsed = parseHotkey(step);
|
|
66
|
+
return (parsed.hotkey.trim().toLowerCase() === fired.hotkey?.trim().toLowerCase() &&
|
|
67
|
+
parsed.isSequence === fired.isSequence &&
|
|
68
|
+
parsed.alt === fired.alt &&
|
|
69
|
+
parsed.ctrl === fired.ctrl &&
|
|
70
|
+
parsed.shift === fired.shift &&
|
|
71
|
+
parsed.meta === fired.meta &&
|
|
72
|
+
parsed.mod === fired.mod &&
|
|
73
|
+
isDeepEqual(parsed.keys, fired.keys));
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The item a fired combination or guarded hotkey selects.
|
|
77
|
+
*
|
|
78
|
+
* @param matchable Combination and guarded registrations, in source order. A typed or unsupported entry never matches.
|
|
79
|
+
* @param fired The event `react-hotkeys-hook` reports for the key that was pressed.
|
|
80
|
+
* @returns The first matching registration, or `undefined` when the key selects nothing.
|
|
81
|
+
*/
|
|
82
|
+
const findCommandItemForHotkey = (matchable, fired) => matchable.find((entry) => (entry.kind === 'combination' || entry.kind === 'guarded') && hotkeyMatches(entry.steps[0], fired));
|
|
31
83
|
|
|
32
|
-
export { isDeepEqual };
|
|
84
|
+
export { findCommandItemForHotkey, isDeepEqual, planCommandItemHotkeys };
|
|
33
85
|
//# sourceMappingURL=commandMenu.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandMenu.utils.js","sources":["../../../../src/components/organisms/CommandMenu/commandMenu.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commandMenu.utils.js","sources":["../../../../src/components/organisms/CommandMenu/commandMenu.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAmDA;;;;;;;AAOG;AACH;MACa,WAAW,GAAG,CAAC,IAAS,EAAE,IAAS,KAAa;;IAE3D,IAAI,IAAI,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;;AAG9B,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI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,CAAC;AAED;;;;;;AAMG;MACU,wBAAwB,GAAG,CAAC,SAAuC,EAAE,KAAkB,KAClG,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,KAAK,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactHotkeysHook = require('react-hotkeys-hook');
|
|
5
|
+
var useKeySequences = require('../../../../hooks/__internal__/useKeySequences/useKeySequences.cjs');
|
|
6
|
+
var hotkeys_utils = require('../../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs');
|
|
7
|
+
var log_utils = require('../../../../utilities/__internal__/logUtils/log.utils.cjs');
|
|
8
|
+
var commandMenu_utils = require('../commandMenu.utils.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Registers each command item's `shortcutKeys` and reports the item it selects.
|
|
12
|
+
* Combinations held with ⌘/Ctrl/Alt also fire while typing; everything else is ignored in a field.
|
|
13
|
+
* A shortcut that can never be triggered warns once.
|
|
14
|
+
*
|
|
15
|
+
* @param options The flat items, any extra disabled ids, and the selection callback.
|
|
16
|
+
* @returns Nothing. Selection is reported through `onSelectionChange`.
|
|
17
|
+
*/
|
|
18
|
+
const useCommandItemHotkeys = ({ items, disabledKeys, onSelectionChange }) => {
|
|
19
|
+
const plan = commandMenu_utils.planCommandItemHotkeys(items, disabledKeys);
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
if (!plan.hasUnsupported)
|
|
22
|
+
return;
|
|
23
|
+
log_utils.warnOnce('CommandMenu:unsupported-shortcut', "CommandMenu: an item's `shortcutKeys` is drawn but can never be triggered. A sequence cannot contain a modifier (['⌘k', 'p']) and a modifier needs a key (['⌘']).");
|
|
24
|
+
}, [plan.hasUnsupported]);
|
|
25
|
+
const selectItemForHotkey = (keyboardEvent, hotkeysEvent) => {
|
|
26
|
+
keyboardEvent.preventDefault();
|
|
27
|
+
const match = commandMenu_utils.findCommandItemForHotkey(plan.matchable, hotkeysEvent);
|
|
28
|
+
if (match)
|
|
29
|
+
onSelectionChange?.(new Set([match.id]));
|
|
30
|
+
};
|
|
31
|
+
// Combinations held with ⌘/Ctrl/Alt cannot be mistaken for typing, so they also work inside the search input.
|
|
32
|
+
reactHotkeysHook.useHotkeys(plan.combination, selectItemForHotkey, {
|
|
33
|
+
enableOnFormTags: true,
|
|
34
|
+
// react-aria re-dispatches a key typed in the search input onto the list; once handled, skip the copy.
|
|
35
|
+
ignoreEventWhen: (event) => event.defaultPrevented,
|
|
36
|
+
});
|
|
37
|
+
// Everything typing could produce (Shift+A, `?`, G then P) is ignored in fields so it never hijacks text entry.
|
|
38
|
+
reactHotkeysHook.useHotkeys(plan.guarded, selectItemForHotkey, { ignoreEventWhen: (event) => event.defaultPrevented || hotkeys_utils.isTypingInField(event) });
|
|
39
|
+
useKeySequences.useKeySequences(plan.typed.map(({ steps }) => steps.map(hotkeys_utils.hotkeyCharacter)), (index) => onSelectionChange?.(new Set([plan.typed[index].id])));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.useCommandItemHotkeys = useCommandItemHotkeys;
|
|
43
|
+
//# sourceMappingURL=useCommandItemHotkeys.cjs.map
|