@fluentui/react-swatch-picker 0.0.0-nightly-20240517-0405.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/CHANGELOG.md +136 -0
- package/LICENSE +15 -0
- package/README.md +61 -0
- package/dist/index.d.ts +346 -0
- package/lib/ColorSwatch.js +1 -0
- package/lib/ColorSwatch.js.map +1 -0
- package/lib/EmptySwatch.js +1 -0
- package/lib/EmptySwatch.js.map +1 -0
- package/lib/ImageSwatch.js +1 -0
- package/lib/ImageSwatch.js.map +1 -0
- package/lib/SwatchPicker.js +1 -0
- package/lib/SwatchPicker.js.map +1 -0
- package/lib/SwatchPickerRow.js +1 -0
- package/lib/SwatchPickerRow.js.map +1 -0
- package/lib/components/ColorSwatch/ColorSwatch.js +14 -0
- package/lib/components/ColorSwatch/ColorSwatch.js.map +1 -0
- package/lib/components/ColorSwatch/ColorSwatch.types.js +1 -0
- package/lib/components/ColorSwatch/ColorSwatch.types.js.map +1 -0
- package/lib/components/ColorSwatch/index.js +5 -0
- package/lib/components/ColorSwatch/index.js.map +1 -0
- package/lib/components/ColorSwatch/renderColorSwatch.js +14 -0
- package/lib/components/ColorSwatch/renderColorSwatch.js.map +1 -0
- package/lib/components/ColorSwatch/useColorSwatch.js +76 -0
- package/lib/components/ColorSwatch/useColorSwatch.js.map +1 -0
- package/lib/components/ColorSwatch/useColorSwatchStyles.styles.js +148 -0
- package/lib/components/ColorSwatch/useColorSwatchStyles.styles.js.map +1 -0
- package/lib/components/EmptySwatch/EmptySwatch.js +14 -0
- package/lib/components/EmptySwatch/EmptySwatch.js.map +1 -0
- package/lib/components/EmptySwatch/EmptySwatch.types.js +1 -0
- package/lib/components/EmptySwatch/EmptySwatch.types.js.map +1 -0
- package/lib/components/EmptySwatch/index.js +5 -0
- package/lib/components/EmptySwatch/index.js.map +1 -0
- package/lib/components/EmptySwatch/renderEmptySwatch.js +8 -0
- package/lib/components/EmptySwatch/renderEmptySwatch.js.map +1 -0
- package/lib/components/EmptySwatch/useEmptySwatch.js +36 -0
- package/lib/components/EmptySwatch/useEmptySwatch.js.map +1 -0
- package/lib/components/EmptySwatch/useEmptySwatchStyles.styles.js +78 -0
- package/lib/components/EmptySwatch/useEmptySwatchStyles.styles.js.map +1 -0
- package/lib/components/ImageSwatch/ImageSwatch.js +14 -0
- package/lib/components/ImageSwatch/ImageSwatch.js.map +1 -0
- package/lib/components/ImageSwatch/ImageSwatch.types.js +1 -0
- package/lib/components/ImageSwatch/ImageSwatch.types.js.map +1 -0
- package/lib/components/ImageSwatch/index.js +5 -0
- package/lib/components/ImageSwatch/index.js.map +1 -0
- package/lib/components/ImageSwatch/renderImageSwatch.js +8 -0
- package/lib/components/ImageSwatch/renderImageSwatch.js.map +1 -0
- package/lib/components/ImageSwatch/useImageSwatch.js +51 -0
- package/lib/components/ImageSwatch/useImageSwatch.js.map +1 -0
- package/lib/components/ImageSwatch/useImageSwatchStyles.styles.js +102 -0
- package/lib/components/ImageSwatch/useImageSwatchStyles.styles.js.map +1 -0
- package/lib/components/SwatchPicker/SwatchPicker.js +16 -0
- package/lib/components/SwatchPicker/SwatchPicker.js.map +1 -0
- package/lib/components/SwatchPicker/SwatchPicker.types.js +1 -0
- package/lib/components/SwatchPicker/SwatchPicker.types.js.map +1 -0
- package/lib/components/SwatchPicker/index.js +5 -0
- package/lib/components/SwatchPicker/index.js.map +1 -0
- package/lib/components/SwatchPicker/renderSwatchPicker.js +14 -0
- package/lib/components/SwatchPicker/renderSwatchPicker.js.map +1 -0
- package/lib/components/SwatchPicker/useSwatchPicker.js +54 -0
- package/lib/components/SwatchPicker/useSwatchPicker.js.map +1 -0
- package/lib/components/SwatchPicker/useSwatchPickerStyles.styles.js +44 -0
- package/lib/components/SwatchPicker/useSwatchPickerStyles.styles.js.map +1 -0
- package/lib/components/SwatchPickerRow/SwatchPickerRow.js +14 -0
- package/lib/components/SwatchPickerRow/SwatchPickerRow.js.map +1 -0
- package/lib/components/SwatchPickerRow/SwatchPickerRow.types.js +1 -0
- package/lib/components/SwatchPickerRow/SwatchPickerRow.types.js.map +1 -0
- package/lib/components/SwatchPickerRow/index.js +5 -0
- package/lib/components/SwatchPickerRow/index.js.map +1 -0
- package/lib/components/SwatchPickerRow/renderSwatchPickerRow.js +8 -0
- package/lib/components/SwatchPickerRow/renderSwatchPickerRow.js.map +1 -0
- package/lib/components/SwatchPickerRow/useSwatchPickerRow.js +28 -0
- package/lib/components/SwatchPickerRow/useSwatchPickerRow.js.map +1 -0
- package/lib/components/SwatchPickerRow/useSwatchPickerRowStyles.styles.js +29 -0
- package/lib/components/SwatchPickerRow/useSwatchPickerRowStyles.styles.js.map +1 -0
- package/lib/contexts/index.js +1 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/contexts/swatchPicker.js +29 -0
- package/lib/contexts/swatchPicker.js.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/renderUtils.js +32 -0
- package/lib/utils/renderUtils.js.map +1 -0
- package/lib-commonjs/ColorSwatch.js +6 -0
- package/lib-commonjs/ColorSwatch.js.map +1 -0
- package/lib-commonjs/EmptySwatch.js +6 -0
- package/lib-commonjs/EmptySwatch.js.map +1 -0
- package/lib-commonjs/ImageSwatch.js +6 -0
- package/lib-commonjs/ImageSwatch.js.map +1 -0
- package/lib-commonjs/SwatchPicker.js +6 -0
- package/lib-commonjs/SwatchPicker.js.map +1 -0
- package/lib-commonjs/SwatchPickerRow.js +6 -0
- package/lib-commonjs/SwatchPickerRow.js.map +1 -0
- package/lib-commonjs/components/ColorSwatch/ColorSwatch.js +23 -0
- package/lib-commonjs/components/ColorSwatch/ColorSwatch.js.map +1 -0
- package/lib-commonjs/components/ColorSwatch/ColorSwatch.types.js +4 -0
- package/lib-commonjs/components/ColorSwatch/ColorSwatch.types.js.map +1 -0
- package/lib-commonjs/components/ColorSwatch/index.js +10 -0
- package/lib-commonjs/components/ColorSwatch/index.js.map +1 -0
- package/lib-commonjs/components/ColorSwatch/renderColorSwatch.js +22 -0
- package/lib-commonjs/components/ColorSwatch/renderColorSwatch.js.map +1 -0
- package/lib-commonjs/components/ColorSwatch/useColorSwatch.js +79 -0
- package/lib-commonjs/components/ColorSwatch/useColorSwatch.js.map +1 -0
- package/lib-commonjs/components/ColorSwatch/useColorSwatchStyles.styles.js +303 -0
- package/lib-commonjs/components/ColorSwatch/useColorSwatchStyles.styles.js.map +1 -0
- package/lib-commonjs/components/EmptySwatch/EmptySwatch.js +23 -0
- package/lib-commonjs/components/EmptySwatch/EmptySwatch.js.map +1 -0
- package/lib-commonjs/components/EmptySwatch/EmptySwatch.types.js +4 -0
- package/lib-commonjs/components/EmptySwatch/EmptySwatch.types.js.map +1 -0
- package/lib-commonjs/components/EmptySwatch/index.js +10 -0
- package/lib-commonjs/components/EmptySwatch/index.js.map +1 -0
- package/lib-commonjs/components/EmptySwatch/renderEmptySwatch.js +16 -0
- package/lib-commonjs/components/EmptySwatch/renderEmptySwatch.js.map +1 -0
- package/lib-commonjs/components/EmptySwatch/useEmptySwatch.js +39 -0
- package/lib-commonjs/components/EmptySwatch/useEmptySwatch.js.map +1 -0
- package/lib-commonjs/components/EmptySwatch/useEmptySwatchStyles.styles.js +197 -0
- package/lib-commonjs/components/EmptySwatch/useEmptySwatchStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ImageSwatch/ImageSwatch.js +23 -0
- package/lib-commonjs/components/ImageSwatch/ImageSwatch.js.map +1 -0
- package/lib-commonjs/components/ImageSwatch/ImageSwatch.types.js +4 -0
- package/lib-commonjs/components/ImageSwatch/ImageSwatch.types.js.map +1 -0
- package/lib-commonjs/components/ImageSwatch/index.js +10 -0
- package/lib-commonjs/components/ImageSwatch/index.js.map +1 -0
- package/lib-commonjs/components/ImageSwatch/renderImageSwatch.js +16 -0
- package/lib-commonjs/components/ImageSwatch/renderImageSwatch.js.map +1 -0
- package/lib-commonjs/components/ImageSwatch/useImageSwatch.js +54 -0
- package/lib-commonjs/components/ImageSwatch/useImageSwatch.js.map +1 -0
- package/lib-commonjs/components/ImageSwatch/useImageSwatchStyles.styles.js +246 -0
- package/lib-commonjs/components/ImageSwatch/useImageSwatchStyles.styles.js.map +1 -0
- package/lib-commonjs/components/SwatchPicker/SwatchPicker.js +25 -0
- package/lib-commonjs/components/SwatchPicker/SwatchPicker.js.map +1 -0
- package/lib-commonjs/components/SwatchPicker/SwatchPicker.types.js +6 -0
- package/lib-commonjs/components/SwatchPicker/SwatchPicker.types.js.map +1 -0
- package/lib-commonjs/components/SwatchPicker/index.js +10 -0
- package/lib-commonjs/components/SwatchPicker/index.js.map +1 -0
- package/lib-commonjs/components/SwatchPicker/renderSwatchPicker.js +22 -0
- package/lib-commonjs/components/SwatchPicker/renderSwatchPicker.js.map +1 -0
- package/lib-commonjs/components/SwatchPicker/useSwatchPicker.js +57 -0
- package/lib-commonjs/components/SwatchPicker/useSwatchPicker.js.map +1 -0
- package/lib-commonjs/components/SwatchPicker/useSwatchPickerStyles.styles.js +74 -0
- package/lib-commonjs/components/SwatchPicker/useSwatchPickerStyles.styles.js.map +1 -0
- package/lib-commonjs/components/SwatchPickerRow/SwatchPickerRow.js +23 -0
- package/lib-commonjs/components/SwatchPickerRow/SwatchPickerRow.js.map +1 -0
- package/lib-commonjs/components/SwatchPickerRow/SwatchPickerRow.types.js +4 -0
- package/lib-commonjs/components/SwatchPickerRow/SwatchPickerRow.types.js.map +1 -0
- package/lib-commonjs/components/SwatchPickerRow/index.js +10 -0
- package/lib-commonjs/components/SwatchPickerRow/index.js.map +1 -0
- package/lib-commonjs/components/SwatchPickerRow/renderSwatchPickerRow.js +16 -0
- package/lib-commonjs/components/SwatchPickerRow/renderSwatchPickerRow.js.map +1 -0
- package/lib-commonjs/components/SwatchPickerRow/useSwatchPickerRow.js +31 -0
- package/lib-commonjs/components/SwatchPickerRow/useSwatchPickerRow.js.map +1 -0
- package/lib-commonjs/components/SwatchPickerRow/useSwatchPickerRowStyles.styles.js +47 -0
- package/lib-commonjs/components/SwatchPickerRow/useSwatchPickerRowStyles.styles.js.map +1 -0
- package/lib-commonjs/contexts/index.js +6 -0
- package/lib-commonjs/contexts/index.js.map +1 -0
- package/lib-commonjs/contexts/swatchPicker.js +54 -0
- package/lib-commonjs/contexts/swatchPicker.js.map +1 -0
- package/lib-commonjs/index.js +112 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/utils/renderUtils.js +43 -0
- package/lib-commonjs/utils/renderUtils.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { slot, useEventCallback, getIntrinsicElementProps, mergeCallbacks } from '@fluentui/react-utilities';
|
|
3
|
+
import { useSwatchPickerContextValue_unstable } from '../../contexts/swatchPicker';
|
|
4
|
+
import { swatchCSSVars } from './useColorSwatchStyles.styles';
|
|
5
|
+
import { ProhibitedFilled } from '@fluentui/react-icons';
|
|
6
|
+
import { tokens } from '@fluentui/react-theme';
|
|
7
|
+
/**
|
|
8
|
+
* Create the state required to render ColorSwatch.
|
|
9
|
+
*
|
|
10
|
+
* The returned state can be modified with hooks such as useColorSwatchStyles_unstable,
|
|
11
|
+
* before being passed to renderColorSwatch_unstable.
|
|
12
|
+
*
|
|
13
|
+
* @param props - props from this instance of ColorSwatch
|
|
14
|
+
* @param ref - reference to root HTMLButtonElement of ColorSwatch
|
|
15
|
+
*/ export const useColorSwatch_unstable = (props, ref)=>{
|
|
16
|
+
const { borderColor, color, disabled, disabledIcon, icon, value, onClick, size, shape, style, ...rest } = props;
|
|
17
|
+
const _size = useSwatchPickerContextValue_unstable((ctx)=>ctx.size);
|
|
18
|
+
const _shape = useSwatchPickerContextValue_unstable((ctx)=>ctx.shape);
|
|
19
|
+
const isGrid = useSwatchPickerContextValue_unstable((ctx)=>ctx.isGrid);
|
|
20
|
+
const requestSelectionChange = useSwatchPickerContextValue_unstable((ctx)=>ctx.requestSelectionChange);
|
|
21
|
+
const selected = useSwatchPickerContextValue_unstable((ctx)=>ctx.selectedValue === value);
|
|
22
|
+
const onColorSwatchClick = useEventCallback(mergeCallbacks(onClick, (event)=>requestSelectionChange(event, {
|
|
23
|
+
selectedValue: value,
|
|
24
|
+
selectedSwatch: color
|
|
25
|
+
})));
|
|
26
|
+
const rootVariables = {
|
|
27
|
+
[swatchCSSVars.color]: color,
|
|
28
|
+
[swatchCSSVars.borderColor]: borderColor !== null && borderColor !== void 0 ? borderColor : tokens.colorTransparentStroke
|
|
29
|
+
};
|
|
30
|
+
const role = isGrid ? 'gridcell' : 'radio';
|
|
31
|
+
const ariaSelected = isGrid ? {
|
|
32
|
+
'aria-selected': selected
|
|
33
|
+
} : {
|
|
34
|
+
'aria-checked': selected
|
|
35
|
+
};
|
|
36
|
+
const iconShorthand = slot.optional(icon, {
|
|
37
|
+
elementType: 'span'
|
|
38
|
+
});
|
|
39
|
+
const disabledIconShorthand = slot.optional(disabledIcon, {
|
|
40
|
+
defaultProps: {
|
|
41
|
+
children: /*#__PURE__*/ React.createElement(ProhibitedFilled, null)
|
|
42
|
+
},
|
|
43
|
+
renderByDefault: true,
|
|
44
|
+
elementType: 'span'
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
components: {
|
|
48
|
+
root: 'button',
|
|
49
|
+
icon: 'span',
|
|
50
|
+
disabledIcon: 'span'
|
|
51
|
+
},
|
|
52
|
+
root: slot.always(getIntrinsicElementProps('button', {
|
|
53
|
+
ref,
|
|
54
|
+
role,
|
|
55
|
+
...ariaSelected,
|
|
56
|
+
onClick: onColorSwatchClick,
|
|
57
|
+
type: 'button',
|
|
58
|
+
disabled,
|
|
59
|
+
...rest,
|
|
60
|
+
style: {
|
|
61
|
+
...rootVariables,
|
|
62
|
+
...style
|
|
63
|
+
}
|
|
64
|
+
}), {
|
|
65
|
+
elementType: 'button'
|
|
66
|
+
}),
|
|
67
|
+
icon: iconShorthand,
|
|
68
|
+
disabledIcon: disabledIconShorthand,
|
|
69
|
+
disabled,
|
|
70
|
+
size: size !== null && size !== void 0 ? size : _size,
|
|
71
|
+
shape: shape !== null && shape !== void 0 ? shape : _shape,
|
|
72
|
+
selected,
|
|
73
|
+
color,
|
|
74
|
+
value
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useColorSwatch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { slot, useEventCallback, getIntrinsicElementProps, mergeCallbacks } from '@fluentui/react-utilities';\nimport type { ColorSwatchProps, ColorSwatchState } from './ColorSwatch.types';\nimport { useSwatchPickerContextValue_unstable } from '../../contexts/swatchPicker';\nimport { swatchCSSVars } from './useColorSwatchStyles.styles';\nimport { ProhibitedFilled } from '@fluentui/react-icons';\nimport { tokens } from '@fluentui/react-theme';\n\n/**\n * Create the state required to render ColorSwatch.\n *\n * The returned state can be modified with hooks such as useColorSwatchStyles_unstable,\n * before being passed to renderColorSwatch_unstable.\n *\n * @param props - props from this instance of ColorSwatch\n * @param ref - reference to root HTMLButtonElement of ColorSwatch\n */\nexport const useColorSwatch_unstable = (\n props: ColorSwatchProps,\n ref: React.Ref<HTMLButtonElement>,\n): ColorSwatchState => {\n const { borderColor, color, disabled, disabledIcon, icon, value, onClick, size, shape, style, ...rest } = props;\n const _size = useSwatchPickerContextValue_unstable(ctx => ctx.size);\n const _shape = useSwatchPickerContextValue_unstable(ctx => ctx.shape);\n const isGrid = useSwatchPickerContextValue_unstable(ctx => ctx.isGrid);\n\n const requestSelectionChange = useSwatchPickerContextValue_unstable(ctx => ctx.requestSelectionChange);\n const selected = useSwatchPickerContextValue_unstable(ctx => ctx.selectedValue === value);\n\n const onColorSwatchClick = useEventCallback(\n mergeCallbacks(onClick, (event: React.MouseEvent<HTMLButtonElement>) =>\n requestSelectionChange(event, {\n selectedValue: value,\n selectedSwatch: color,\n }),\n ),\n );\n\n const rootVariables = {\n [swatchCSSVars.color]: color,\n [swatchCSSVars.borderColor]: borderColor ?? tokens.colorTransparentStroke,\n };\n\n const role = isGrid ? 'gridcell' : 'radio';\n const ariaSelected = isGrid\n ? {\n 'aria-selected': selected,\n }\n : { 'aria-checked': selected };\n\n const iconShorthand = slot.optional(icon, { elementType: 'span' });\n const disabledIconShorthand = slot.optional(disabledIcon, {\n defaultProps: {\n children: <ProhibitedFilled />,\n },\n renderByDefault: true,\n elementType: 'span',\n });\n\n return {\n components: {\n root: 'button',\n icon: 'span',\n disabledIcon: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref,\n role,\n ...ariaSelected,\n onClick: onColorSwatchClick,\n type: 'button',\n disabled,\n ...rest,\n style: {\n ...rootVariables,\n ...style,\n },\n }),\n { elementType: 'button' },\n ),\n icon: iconShorthand,\n disabledIcon: disabledIconShorthand,\n disabled,\n size: size ?? _size,\n shape: shape ?? _shape,\n selected,\n color,\n value,\n };\n};\n"],"names":["React","slot","useEventCallback","getIntrinsicElementProps","mergeCallbacks","useSwatchPickerContextValue_unstable","swatchCSSVars","ProhibitedFilled","tokens","useColorSwatch_unstable","props","ref","borderColor","color","disabled","disabledIcon","icon","value","onClick","size","shape","style","rest","_size","ctx","_shape","isGrid","requestSelectionChange","selected","selectedValue","onColorSwatchClick","event","selectedSwatch","rootVariables","colorTransparentStroke","role","ariaSelected","iconShorthand","optional","elementType","disabledIconShorthand","defaultProps","children","renderByDefault","components","root","always","type"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,EAAEC,gBAAgB,EAAEC,wBAAwB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7G,SAASC,oCAAoC,QAAQ,8BAA8B;AACnF,SAASC,aAAa,QAAQ,gCAAgC;AAC9D,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,MAAM,QAAQ,wBAAwB;AAE/C;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CACrCC,OACAC;IAEA,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGZ;IAC1G,MAAMa,QAAQlB,qCAAqCmB,CAAAA,MAAOA,IAAIL,IAAI;IAClE,MAAMM,SAASpB,qCAAqCmB,CAAAA,MAAOA,IAAIJ,KAAK;IACpE,MAAMM,SAASrB,qCAAqCmB,CAAAA,MAAOA,IAAIE,MAAM;IAErE,MAAMC,yBAAyBtB,qCAAqCmB,CAAAA,MAAOA,IAAIG,sBAAsB;IACrG,MAAMC,WAAWvB,qCAAqCmB,CAAAA,MAAOA,IAAIK,aAAa,KAAKZ;IAEnF,MAAMa,qBAAqB5B,iBACzBE,eAAec,SAAS,CAACa,QACvBJ,uBAAuBI,OAAO;YAC5BF,eAAeZ;YACfe,gBAAgBnB;QAClB;IAIJ,MAAMoB,gBAAgB;QACpB,CAAC3B,cAAcO,KAAK,CAAC,EAAEA;QACvB,CAACP,cAAcM,WAAW,CAAC,EAAEA,wBAAAA,yBAAAA,cAAeJ,OAAO0B,sBAAsB;IAC3E;IAEA,MAAMC,OAAOT,SAAS,aAAa;IACnC,MAAMU,eAAeV,SACjB;QACE,iBAAiBE;IACnB,IACA;QAAE,gBAAgBA;IAAS;IAE/B,MAAMS,gBAAgBpC,KAAKqC,QAAQ,CAACtB,MAAM;QAAEuB,aAAa;IAAO;IAChE,MAAMC,wBAAwBvC,KAAKqC,QAAQ,CAACvB,cAAc;QACxD0B,cAAc;YACZC,wBAAU,oBAACnC;QACb;QACAoC,iBAAiB;QACjBJ,aAAa;IACf;IAEA,OAAO;QACLK,YAAY;YACVC,MAAM;YACN7B,MAAM;YACND,cAAc;QAChB;QACA8B,MAAM5C,KAAK6C,MAAM,CACf3C,yBAAyB,UAAU;YACjCQ;YACAwB;YACA,GAAGC,YAAY;YACflB,SAASY;YACTiB,MAAM;YACNjC;YACA,GAAGQ,IAAI;YACPD,OAAO;gBACL,GAAGY,aAAa;gBAChB,GAAGZ,KAAK;YACV;QACF,IACA;YAAEkB,aAAa;QAAS;QAE1BvB,MAAMqB;QACNtB,cAAcyB;QACd1B;QACAK,MAAMA,iBAAAA,kBAAAA,OAAQI;QACdH,OAAOA,kBAAAA,mBAAAA,QAASK;QAChBG;QACAf;QACAI;IACF;AACF,EAAE"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { __resetStyles, __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
2
|
+
import { tokens } from '@fluentui/react-theme';
|
|
3
|
+
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
|
|
4
|
+
export const colorSwatchClassNames = {
|
|
5
|
+
root: 'fui-ColorSwatch',
|
|
6
|
+
icon: 'fui-ColorSwatch__icon',
|
|
7
|
+
disabledIcon: 'fui-ColorSwatch__disabledIcon'
|
|
8
|
+
};
|
|
9
|
+
export const swatchCSSVars = {
|
|
10
|
+
color: `--fui-SwatchPicker--color`,
|
|
11
|
+
borderColor: `--fui-SwatchPicker--borderColor`
|
|
12
|
+
};
|
|
13
|
+
const {
|
|
14
|
+
color,
|
|
15
|
+
borderColor
|
|
16
|
+
} = swatchCSSVars;
|
|
17
|
+
/**
|
|
18
|
+
* Styles for the root slot
|
|
19
|
+
*/
|
|
20
|
+
const useResetStyles = /*#__PURE__*/__resetStyles("rwl4y25", null, {
|
|
21
|
+
r: [".rwl4y25{display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;box-sizing:border-box;border:1px solid var(--fui-SwatchPicker--borderColor);background:var(--fui-SwatchPicker--color);overflow:hidden;padding:0;}", ".rwl4y25:hover{cursor:pointer;border:none;box-shadow:inset 0 0 0 var(--strokeWidthThick) var(--colorBrandStroke1),inset 0 0 0 var(--strokeWidthThicker) var(--colorStrokeFocus1);}", ".rwl4y25:hover:active{border:none;box-shadow:inset 0 0 0 var(--strokeWidthThicker) var(--colorBrandStroke1),inset 0 0 0 var(--strokeWidthThickest) var(--colorStrokeFocus1);}", ".rwl4y25:focus{outline:none;}", ".rwl4y25:focus-visible{outline:none;}", ".rwl4y25[data-fui-focus-visible]{border:none;outline:none;box-shadow:inset 0 0 0 var(--strokeWidthThick) var(--colorStrokeFocus2),inset 0 0 0 var(--strokeWidthThicker) var(--colorStrokeFocus1);}"],
|
|
22
|
+
s: ["@media (forced-colors: active){.rwl4y25{forced-color-adjust:none;}.rwl4y25:hover{box-shadow:inset 0 0 0 var(--strokeWidthThick) var(--colorBrandStroke2Hover),inset 0 0 0 var(--strokeWidthThicker) var(--colorStrokeFocus1);}.rwl4y25:hover:active{box-shadow:inset 0 0 0 var(--strokeWidthThicker) var(--colorBrandStroke2Pressed),inset 0 0 0 var(--strokeWidthThickest) var(--colorStrokeFocus1);}}"]
|
|
23
|
+
});
|
|
24
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
25
|
+
disabled: {
|
|
26
|
+
eoavqd: "fphbwmw",
|
|
27
|
+
Bvxd0ez: "f1q3txrk"
|
|
28
|
+
},
|
|
29
|
+
selected: {
|
|
30
|
+
icvyot: "f1ern45e",
|
|
31
|
+
vrafjx: ["f1n71otn", "f1deefiw"],
|
|
32
|
+
oivjwe: "f1h8hb77",
|
|
33
|
+
wvpqe5: ["f1deefiw", "f1n71otn"],
|
|
34
|
+
E5pizo: "f8ps3yo",
|
|
35
|
+
Bvxd0ez: "f1txz9o1",
|
|
36
|
+
vajtyg: "f1frtkom",
|
|
37
|
+
j6ew2k: "f16jq8vy",
|
|
38
|
+
Bspt33j: "f18nq7tj"
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
h: [".fphbwmw:hover{cursor:not-allowed;}", ".f1q3txrk:hover{box-shadow:none;}", ".f1txz9o1:hover{box-shadow:inset 0 0 0 var(--strokeWidthThickest) var(--colorBrandStroke1),inset 0 0 0 6px var(--colorStrokeFocus1);}", ".f1frtkom:hover:active{box-shadow:inset 0 0 0 var(--strokeWidthThickest) var(--colorBrandStroke1),inset 0 0 0 7px var(--colorStrokeFocus1);}"],
|
|
42
|
+
d: [".f1ern45e{border-top-style:none;}", ".f1n71otn{border-right-style:none;}", ".f1deefiw{border-left-style:none;}", ".f1h8hb77{border-bottom-style:none;}", ".f8ps3yo{box-shadow:inset 0 0 0 var(--strokeWidthThicker) var(--colorBrandStroke1),inset 0 0 0 5px var(--colorStrokeFocus1);}", ".f16jq8vy[data-fui-focus-visible]{box-shadow:inset 0 0 0 var(--strokeWidthThicker) var(--colorStrokeFocus2),inset 0 0 0 5px var(--colorStrokeFocus1);}"],
|
|
43
|
+
m: [["@media (forced-colors: active){.f18nq7tj{box-shadow:inset 0 0 0 var(--strokeWidthThicker) var(--colorBrandStroke2Pressed),inset 0 0 0 5px var(--colorStrokeFocus1);}}", {
|
|
44
|
+
m: "(forced-colors: active)"
|
|
45
|
+
}]]
|
|
46
|
+
});
|
|
47
|
+
const useSizeStyles = /*#__PURE__*/__styles({
|
|
48
|
+
"extra-small": {
|
|
49
|
+
a9b677: "f64fuq3",
|
|
50
|
+
Bqenvij: "fjamq6b"
|
|
51
|
+
},
|
|
52
|
+
small: {
|
|
53
|
+
a9b677: "fq4mcun",
|
|
54
|
+
Bqenvij: "frvgh55"
|
|
55
|
+
},
|
|
56
|
+
medium: {
|
|
57
|
+
a9b677: "f1w9dchk",
|
|
58
|
+
Bqenvij: "fxldao9"
|
|
59
|
+
},
|
|
60
|
+
large: {
|
|
61
|
+
a9b677: "f1szoe96",
|
|
62
|
+
Bqenvij: "f1d2rq10"
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
d: [".f64fuq3{width:20px;}", ".fjamq6b{height:20px;}", ".fq4mcun{width:24px;}", ".frvgh55{height:24px;}", ".f1w9dchk{width:28px;}", ".fxldao9{height:28px;}", ".f1szoe96{width:32px;}", ".f1d2rq10{height:32px;}"]
|
|
66
|
+
});
|
|
67
|
+
const useShapeStyles = /*#__PURE__*/__styles({
|
|
68
|
+
rounded: {
|
|
69
|
+
Bbmb7ep: ["f1aa9q02", "f16jpd5f"],
|
|
70
|
+
Beyfa6y: ["f16jpd5f", "f1aa9q02"],
|
|
71
|
+
B7oj6ja: ["f1jar5jt", "fyu767a"],
|
|
72
|
+
Btl43ni: ["fyu767a", "f1jar5jt"],
|
|
73
|
+
kdpuga: ["f1o2ludy", "f1kjnpwc"],
|
|
74
|
+
Bw81rd7: ["f1kjnpwc", "f1o2ludy"],
|
|
75
|
+
B6xbmo0: ["fxmnebo", "f1witrsb"],
|
|
76
|
+
dm238s: ["f1witrsb", "fxmnebo"]
|
|
77
|
+
},
|
|
78
|
+
circular: {
|
|
79
|
+
Bbmb7ep: ["f8fbkgy", "f1nfllo7"],
|
|
80
|
+
Beyfa6y: ["f1nfllo7", "f8fbkgy"],
|
|
81
|
+
B7oj6ja: ["f1djnp8u", "f1s8kh49"],
|
|
82
|
+
Btl43ni: ["f1s8kh49", "f1djnp8u"],
|
|
83
|
+
kdpuga: ["fanj13w", "f1gou5sz"],
|
|
84
|
+
Bw81rd7: ["f1gou5sz", "fanj13w"],
|
|
85
|
+
B6xbmo0: ["fulf6x3", "foeb2x"],
|
|
86
|
+
dm238s: ["foeb2x", "fulf6x3"]
|
|
87
|
+
},
|
|
88
|
+
square: {
|
|
89
|
+
Bbmb7ep: ["fzi6hpg", "fyowgf4"],
|
|
90
|
+
Beyfa6y: ["fyowgf4", "fzi6hpg"],
|
|
91
|
+
B7oj6ja: ["f3fg2lr", "f13av6d4"],
|
|
92
|
+
Btl43ni: ["f13av6d4", "f3fg2lr"],
|
|
93
|
+
kdpuga: ["f1ndz5i7", "f1co4qro"],
|
|
94
|
+
Bw81rd7: ["f1co4qro", "f1ndz5i7"],
|
|
95
|
+
B6xbmo0: ["f146y5a9", "f1k2ftg"],
|
|
96
|
+
dm238s: ["f1k2ftg", "f146y5a9"]
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
d: [".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f1o2ludy[data-fui-focus-visible]{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f1kjnpwc[data-fui-focus-visible]{border-bottom-left-radius:var(--borderRadiusMedium);}", ".fxmnebo[data-fui-focus-visible]{border-top-right-radius:var(--borderRadiusMedium);}", ".f1witrsb[data-fui-focus-visible]{border-top-left-radius:var(--borderRadiusMedium);}", ".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".fanj13w[data-fui-focus-visible]{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1gou5sz[data-fui-focus-visible]{border-bottom-left-radius:var(--borderRadiusCircular);}", ".fulf6x3[data-fui-focus-visible]{border-top-right-radius:var(--borderRadiusCircular);}", ".foeb2x[data-fui-focus-visible]{border-top-left-radius:var(--borderRadiusCircular);}", ".fzi6hpg{border-bottom-right-radius:var(--borderRadiusNone);}", ".fyowgf4{border-bottom-left-radius:var(--borderRadiusNone);}", ".f3fg2lr{border-top-right-radius:var(--borderRadiusNone);}", ".f13av6d4{border-top-left-radius:var(--borderRadiusNone);}", ".f1ndz5i7[data-fui-focus-visible]{border-bottom-right-radius:var(--borderRadiusNone);}", ".f1co4qro[data-fui-focus-visible]{border-bottom-left-radius:var(--borderRadiusNone);}", ".f146y5a9[data-fui-focus-visible]{border-top-right-radius:var(--borderRadiusNone);}", ".f1k2ftg[data-fui-focus-visible]{border-top-left-radius:var(--borderRadiusNone);}"]
|
|
100
|
+
});
|
|
101
|
+
const useIconStyles = /*#__PURE__*/__styles({
|
|
102
|
+
disabledIcon: {
|
|
103
|
+
sj55zd: "fqpbvvt",
|
|
104
|
+
Bhu2qc9: "f14y0k3d"
|
|
105
|
+
},
|
|
106
|
+
icon: {
|
|
107
|
+
qhf8xq: "f1euv43f",
|
|
108
|
+
mc9l5x: "f22iagw",
|
|
109
|
+
qb2dma: "f7nlbp4"
|
|
110
|
+
},
|
|
111
|
+
"extra-small": {
|
|
112
|
+
Be2twd7: "f4ybsrx"
|
|
113
|
+
},
|
|
114
|
+
small: {
|
|
115
|
+
Be2twd7: "f4ybsrx"
|
|
116
|
+
},
|
|
117
|
+
medium: {
|
|
118
|
+
Be2twd7: "fe5j1ua"
|
|
119
|
+
},
|
|
120
|
+
large: {
|
|
121
|
+
Be2twd7: "f1rt2boy"
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
d: [".fqpbvvt{color:var(--colorNeutralForegroundInverted);}", ".f14y0k3d{filter:drop-shadow(0 1px 1px rgb(0 0 0 / 1));}", ".f1euv43f{position:absolute;}", ".f22iagw{display:flex;}", ".f7nlbp4{align-self:center;}", ".f4ybsrx{font-size:16px;}", ".fe5j1ua{font-size:20px;}", ".f1rt2boy{font-size:24px;}"]
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Apply styling to the ColorSwatch slots based on the state
|
|
128
|
+
*/
|
|
129
|
+
export const useColorSwatchStyles_unstable = state => {
|
|
130
|
+
const resetStyles = useResetStyles();
|
|
131
|
+
const styles = useStyles();
|
|
132
|
+
const sizeStyles = useSizeStyles();
|
|
133
|
+
const shapeStyles = useShapeStyles();
|
|
134
|
+
const iconStyles = useIconStyles();
|
|
135
|
+
const {
|
|
136
|
+
size = 'medium',
|
|
137
|
+
shape = 'square'
|
|
138
|
+
} = state;
|
|
139
|
+
state.root.className = mergeClasses(colorSwatchClassNames.root, resetStyles, sizeStyles[size], shapeStyles[shape], state.selected && styles.selected, state.disabled && styles.disabled, state.root.className);
|
|
140
|
+
if (state.disabled && state.disabledIcon) {
|
|
141
|
+
state.disabledIcon.className = mergeClasses(iconStyles.icon, iconStyles[size], iconStyles.disabledIcon, state.disabledIcon.className);
|
|
142
|
+
}
|
|
143
|
+
if (state.icon) {
|
|
144
|
+
state.icon.className = mergeClasses(iconStyles.icon, iconStyles[size], state.icon.className);
|
|
145
|
+
}
|
|
146
|
+
return state;
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=useColorSwatchStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__resetStyles","__styles","mergeClasses","shorthands","tokens","createCustomFocusIndicatorStyle","colorSwatchClassNames","root","icon","disabledIcon","swatchCSSVars","color","borderColor","useResetStyles","r","s","useStyles","disabled","eoavqd","Bvxd0ez","selected","icvyot","vrafjx","oivjwe","wvpqe5","E5pizo","vajtyg","j6ew2k","Bspt33j","h","d","m","useSizeStyles","a9b677","Bqenvij","small","medium","large","useShapeStyles","rounded","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","kdpuga","Bw81rd7","B6xbmo0","dm238s","circular","square","useIconStyles","sj55zd","Bhu2qc9","qhf8xq","mc9l5x","qb2dma","Be2twd7","useColorSwatchStyles_unstable","state","resetStyles","styles","sizeStyles","shapeStyles","iconStyles","size","shape","className"],"sources":["useColorSwatchStyles.styles.js"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nexport const colorSwatchClassNames = {\n root: 'fui-ColorSwatch',\n icon: 'fui-ColorSwatch__icon',\n disabledIcon: 'fui-ColorSwatch__disabledIcon'\n};\nexport const swatchCSSVars = {\n color: `--fui-SwatchPicker--color`,\n borderColor: `--fui-SwatchPicker--borderColor`\n};\nconst { color, borderColor } = swatchCSSVars;\n/**\n * Styles for the root slot\n */ const useResetStyles = makeResetStyles({\n display: 'inline-flex',\n flexShrink: 0,\n alignItems: 'center',\n justifyContent: 'center',\n boxSizing: 'border-box',\n border: `1px solid var(${borderColor})`,\n background: `var(${color})`,\n overflow: 'hidden',\n padding: '0',\n ':hover': {\n cursor: 'pointer',\n border: 'none',\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThick} ${tokens.colorBrandStroke1}, inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorStrokeFocus1}`\n },\n ':hover:active': {\n border: 'none',\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorBrandStroke1}, inset 0 0 0 ${tokens.strokeWidthThickest} ${tokens.colorStrokeFocus1}`\n },\n ':focus': {\n outline: 'none'\n },\n ':focus-visible': {\n outline: 'none'\n },\n ...createCustomFocusIndicatorStyle({\n border: 'none',\n outline: 'none',\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThick} ${tokens.colorStrokeFocus2}, inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorStrokeFocus1}`\n }),\n // High contrast styles\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'none',\n ':hover': {\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThick} ${tokens.colorBrandStroke2Hover}, inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorStrokeFocus1}`\n },\n ':hover:active': {\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorBrandStroke2Pressed}, inset 0 0 0 ${tokens.strokeWidthThickest} ${tokens.colorStrokeFocus1}`\n }\n }\n});\nconst useStyles = makeStyles({\n disabled: {\n ':hover': {\n cursor: 'not-allowed',\n boxShadow: 'none'\n }\n },\n selected: {\n ...shorthands.border('none'),\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorBrandStroke1}, inset 0 0 0 5px ${tokens.colorStrokeFocus1}`,\n ':hover': {\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThickest} ${tokens.colorBrandStroke1}, inset 0 0 0 6px ${tokens.colorStrokeFocus1}`\n },\n ':hover:active': {\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThickest} ${tokens.colorBrandStroke1}, inset 0 0 0 7px ${tokens.colorStrokeFocus1}`\n },\n ...createCustomFocusIndicatorStyle({\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorStrokeFocus2}, inset 0 0 0 5px ${tokens.colorStrokeFocus1}`\n }),\n '@media (forced-colors: active)': {\n boxShadow: `inset 0 0 0 ${tokens.strokeWidthThicker} ${tokens.colorBrandStroke2Pressed}, inset 0 0 0 5px ${tokens.colorStrokeFocus1}`\n }\n }\n});\nconst useSizeStyles = makeStyles({\n 'extra-small': {\n width: '20px',\n height: '20px'\n },\n small: {\n width: '24px',\n height: '24px'\n },\n medium: {\n width: '28px',\n height: '28px'\n },\n large: {\n width: '32px',\n height: '32px'\n }\n});\nconst useShapeStyles = makeStyles({\n rounded: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...createCustomFocusIndicatorStyle({\n ...shorthands.borderRadius(tokens.borderRadiusMedium)\n })\n },\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n ...createCustomFocusIndicatorStyle({\n ...shorthands.borderRadius(tokens.borderRadiusCircular)\n })\n },\n square: {\n ...shorthands.borderRadius(tokens.borderRadiusNone),\n ...createCustomFocusIndicatorStyle({\n ...shorthands.borderRadius(tokens.borderRadiusNone)\n })\n }\n});\nconst useIconStyles = makeStyles({\n disabledIcon: {\n color: tokens.colorNeutralForegroundInverted,\n filter: 'drop-shadow(0 1px 1px rgb(0 0 0 / 1))'\n },\n icon: {\n position: 'absolute',\n display: 'flex',\n alignSelf: 'center'\n },\n 'extra-small': {\n fontSize: '16px'\n },\n small: {\n fontSize: '16px'\n },\n medium: {\n fontSize: '20px'\n },\n large: {\n fontSize: '24px'\n }\n});\n/**\n * Apply styling to the ColorSwatch slots based on the state\n */ export const useColorSwatchStyles_unstable = (state)=>{\n const resetStyles = useResetStyles();\n const styles = useStyles();\n const sizeStyles = useSizeStyles();\n const shapeStyles = useShapeStyles();\n const iconStyles = useIconStyles();\n const { size = 'medium', shape = 'square' } = state;\n state.root.className = mergeClasses(colorSwatchClassNames.root, resetStyles, sizeStyles[size], shapeStyles[shape], state.selected && styles.selected, state.disabled && styles.disabled, state.root.className);\n if (state.disabled && state.disabledIcon) {\n state.disabledIcon.className = mergeClasses(iconStyles.icon, iconStyles[size], iconStyles.disabledIcon, state.disabledIcon.className);\n }\n if (state.icon) {\n state.icon.className = mergeClasses(iconStyles.icon, iconStyles[size], state.icon.className);\n }\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAAAC,QAAA,EAAsCC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACtF,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,OAAO,MAAMC,qBAAqB,GAAG;EACjCC,IAAI,EAAE,iBAAiB;EACvBC,IAAI,EAAE,uBAAuB;EAC7BC,YAAY,EAAE;AAClB,CAAC;AACD,OAAO,MAAMC,aAAa,GAAG;EACzBC,KAAK,EAAG,2BAA0B;EAClCC,WAAW,EAAG;AAClB,CAAC;AACD,MAAM;EAAED,KAAK;EAAEC;AAAY,CAAC,GAAGF,aAAa;AAC5C;AACA;AACA;AAAI,MAAMG,cAAc,gBAAGb,aAAA;EAAAc,CAAA;EAAAC,CAAA;AAAA,CAwC1B,CAAC;AACF,MAAMC,SAAS,gBAAGf,QAAA;EAAAgB,QAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,QAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAN,OAAA;IAAAO,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;EAAAC,CAAA;EAAAC,CAAA;IAAAA,CAAA;EAAA;AAAA,CAuBjB,CAAC;AACF,MAAMC,aAAa,gBAAG/B,QAAA;EAAA;IAAAgC,MAAA;IAAAC,OAAA;EAAA;EAAAC,KAAA;IAAAF,MAAA;IAAAC,OAAA;EAAA;EAAAE,MAAA;IAAAH,MAAA;IAAAC,OAAA;EAAA;EAAAG,KAAA;IAAAJ,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAJ,CAAA;AAAA,CAiBrB,CAAC;AACF,MAAMQ,cAAc,gBAAGrC,QAAA;EAAAsC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAR,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAE,MAAA;IAAAT,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAjB,CAAA;AAAA,CAmBtB,CAAC;AACF,MAAMoB,aAAa,gBAAGjD,QAAA;EAAAQ,YAAA;IAAA0C,MAAA;IAAAC,OAAA;EAAA;EAAA5C,IAAA;IAAA6C,MAAA;IAAAC,MAAA;IAAAC,MAAA;EAAA;EAAA;IAAAC,OAAA;EAAA;EAAArB,KAAA;IAAAqB,OAAA;EAAA;EAAApB,MAAA;IAAAoB,OAAA;EAAA;EAAAnB,KAAA;IAAAmB,OAAA;EAAA;AAAA;EAAA1B,CAAA;AAAA,CAsBrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAM2B,6BAA6B,GAAIC,KAAK,IAAG;EACtD,MAAMC,WAAW,GAAG9C,cAAc,CAAC,CAAC;EACpC,MAAM+C,MAAM,GAAG5C,SAAS,CAAC,CAAC;EAC1B,MAAM6C,UAAU,GAAG7B,aAAa,CAAC,CAAC;EAClC,MAAM8B,WAAW,GAAGxB,cAAc,CAAC,CAAC;EACpC,MAAMyB,UAAU,GAAGb,aAAa,CAAC,CAAC;EAClC,MAAM;IAAEc,IAAI,GAAG,QAAQ;IAAEC,KAAK,GAAG;EAAS,CAAC,GAAGP,KAAK;EACnDA,KAAK,CAACnD,IAAI,CAAC2D,SAAS,GAAGhE,YAAY,CAACI,qBAAqB,CAACC,IAAI,EAAEoD,WAAW,EAAEE,UAAU,CAACG,IAAI,CAAC,EAAEF,WAAW,CAACG,KAAK,CAAC,EAAEP,KAAK,CAACtC,QAAQ,IAAIwC,MAAM,CAACxC,QAAQ,EAAEsC,KAAK,CAACzC,QAAQ,IAAI2C,MAAM,CAAC3C,QAAQ,EAAEyC,KAAK,CAACnD,IAAI,CAAC2D,SAAS,CAAC;EAC9M,IAAIR,KAAK,CAACzC,QAAQ,IAAIyC,KAAK,CAACjD,YAAY,EAAE;IACtCiD,KAAK,CAACjD,YAAY,CAACyD,SAAS,GAAGhE,YAAY,CAAC6D,UAAU,CAACvD,IAAI,EAAEuD,UAAU,CAACC,IAAI,CAAC,EAAED,UAAU,CAACtD,YAAY,EAAEiD,KAAK,CAACjD,YAAY,CAACyD,SAAS,CAAC;EACzI;EACA,IAAIR,KAAK,CAAClD,IAAI,EAAE;IACZkD,KAAK,CAAClD,IAAI,CAAC0D,SAAS,GAAGhE,YAAY,CAAC6D,UAAU,CAACvD,IAAI,EAAEuD,UAAU,CAACC,IAAI,CAAC,EAAEN,KAAK,CAAClD,IAAI,CAAC0D,SAAS,CAAC;EAChG;EACA,OAAOR,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useEmptySwatch_unstable } from './useEmptySwatch';
|
|
3
|
+
import { renderEmptySwatch_unstable } from './renderEmptySwatch';
|
|
4
|
+
import { useEmptySwatchStyles_unstable } from './useEmptySwatchStyles.styles';
|
|
5
|
+
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
|
|
6
|
+
/**
|
|
7
|
+
* EmptySwatch component is used for adding new color swatches.
|
|
8
|
+
*/ export const EmptySwatch = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
9
|
+
const state = useEmptySwatch_unstable(props, ref);
|
|
10
|
+
useEmptySwatchStyles_unstable(state);
|
|
11
|
+
useCustomStyleHook_unstable('useEmptySwatchStyles_unstable')(state);
|
|
12
|
+
return renderEmptySwatch_unstable(state);
|
|
13
|
+
});
|
|
14
|
+
EmptySwatch.displayName = 'EmptySwatch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["EmptySwatch.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useEmptySwatch_unstable } from './useEmptySwatch';\nimport { renderEmptySwatch_unstable } from './renderEmptySwatch';\nimport { useEmptySwatchStyles_unstable } from './useEmptySwatchStyles.styles';\nimport type { EmptySwatchProps } from './EmptySwatch.types';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * EmptySwatch component is used for adding new color swatches.\n */\nexport const EmptySwatch: ForwardRefComponent<EmptySwatchProps> = React.forwardRef((props, ref) => {\n const state = useEmptySwatch_unstable(props, ref);\n\n useEmptySwatchStyles_unstable(state);\n useCustomStyleHook_unstable('useEmptySwatchStyles_unstable')(state);\n return renderEmptySwatch_unstable(state);\n});\n\nEmptySwatch.displayName = 'EmptySwatch';\n"],"names":["React","useEmptySwatch_unstable","renderEmptySwatch_unstable","useEmptySwatchStyles_unstable","useCustomStyleHook_unstable","EmptySwatch","forwardRef","props","ref","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,gCAAgC;AAE9E,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;CAEC,GACD,OAAO,MAAMC,4BAAqDL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQR,wBAAwBM,OAAOC;IAE7CL,8BAA8BM;IAC9BL,4BAA4B,iCAAiCK;IAC7D,OAAOP,2BAA2BO;AACpC,GAAG;AAEHJ,YAAYK,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["EmptySwatch.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { SwatchPickerProps } from '../SwatchPicker/SwatchPicker.types';\n\nexport type EmptySwatchSlots = {\n root: Slot<'button'>;\n};\n\n/**\n * EmptySwatch Props\n */\nexport type EmptySwatchProps = ComponentProps<EmptySwatchSlots> & Pick<SwatchPickerProps, 'size' | 'shape'>;\n\n/**\n * State used in rendering EmptySwatch\n */\nexport type EmptySwatchState = ComponentState<EmptySwatchSlots> & Pick<EmptySwatchProps, 'size' | 'shape'>;\n"],"names":[],"mappings":"AAAA,WAe2G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EmptySwatch';\nexport * from './EmptySwatch.types';\nexport * from './renderEmptySwatch';\nexport * from './useEmptySwatch';\nexport * from './useEmptySwatchStyles.styles';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,gCAAgC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* Render the final JSX of EmptySwatch
|
|
5
|
+
*/ export const renderEmptySwatch_unstable = (state)=>{
|
|
6
|
+
assertSlots(state);
|
|
7
|
+
return /*#__PURE__*/ _jsx(state.root, {});
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renderEmptySwatch.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { EmptySwatchState, EmptySwatchSlots } from './EmptySwatch.types';\n\n/**\n * Render the final JSX of EmptySwatch\n */\nexport const renderEmptySwatch_unstable = (state: EmptySwatchState) => {\n assertSlots<EmptySwatchSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderEmptySwatch_unstable","state","root"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CAACC;IACzCF,YAA8BE;IAE9B,qBAAO,KAACA,MAAMC,IAAI;AACpB,EAAE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
|
|
3
|
+
import { useSwatchPickerContextValue_unstable } from '../../contexts/swatchPicker';
|
|
4
|
+
/**
|
|
5
|
+
* Create the state required to render EmptySwatch.
|
|
6
|
+
*
|
|
7
|
+
* The returned state can be modified with hooks such as useEmptySwatchStyles_unstable,
|
|
8
|
+
* before being passed to renderEmptySwatch_unstable.
|
|
9
|
+
*
|
|
10
|
+
* @param props - props from this instance of EmptySwatch
|
|
11
|
+
* @param ref - reference to root HTMLDivElement of EmptySwatch
|
|
12
|
+
*/ export const useEmptySwatch_unstable = (props, ref)=>{
|
|
13
|
+
const { size, shape, ...rest } = props;
|
|
14
|
+
const _size = useSwatchPickerContextValue_unstable((ctx)=>ctx.size);
|
|
15
|
+
const _shape = useSwatchPickerContextValue_unstable((ctx)=>ctx.shape);
|
|
16
|
+
const isGrid = useSwatchPickerContextValue_unstable((ctx)=>ctx.isGrid);
|
|
17
|
+
const role = isGrid ? 'gridcell' : 'radio';
|
|
18
|
+
const a11yProps = isGrid ? {} : {
|
|
19
|
+
'aria-checked': false
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
components: {
|
|
23
|
+
root: 'button'
|
|
24
|
+
},
|
|
25
|
+
root: slot.always(getIntrinsicElementProps('button', {
|
|
26
|
+
ref,
|
|
27
|
+
role,
|
|
28
|
+
...a11yProps,
|
|
29
|
+
...rest
|
|
30
|
+
}), {
|
|
31
|
+
elementType: 'button'
|
|
32
|
+
}),
|
|
33
|
+
size: size !== null && size !== void 0 ? size : _size,
|
|
34
|
+
shape: shape !== null && shape !== void 0 ? shape : _shape
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useEmptySwatch.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';\nimport type { EmptySwatchProps, EmptySwatchState } from './EmptySwatch.types';\nimport { useSwatchPickerContextValue_unstable } from '../../contexts/swatchPicker';\n\n/**\n * Create the state required to render EmptySwatch.\n *\n * The returned state can be modified with hooks such as useEmptySwatchStyles_unstable,\n * before being passed to renderEmptySwatch_unstable.\n *\n * @param props - props from this instance of EmptySwatch\n * @param ref - reference to root HTMLDivElement of EmptySwatch\n */\nexport const useEmptySwatch_unstable = (\n props: EmptySwatchProps,\n ref: React.Ref<HTMLButtonElement>,\n): EmptySwatchState => {\n const { size, shape, ...rest } = props;\n const _size = useSwatchPickerContextValue_unstable(ctx => ctx.size);\n const _shape = useSwatchPickerContextValue_unstable(ctx => ctx.shape);\n const isGrid = useSwatchPickerContextValue_unstable(ctx => ctx.isGrid);\n\n const role = isGrid ? 'gridcell' : 'radio';\n const a11yProps = isGrid ? {} : { 'aria-checked': false };\n return {\n components: {\n root: 'button',\n },\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref,\n role,\n ...a11yProps,\n ...rest,\n }),\n { elementType: 'button' },\n ),\n size: size ?? _size,\n shape: shape ?? _shape,\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useSwatchPickerContextValue_unstable","useEmptySwatch_unstable","props","ref","size","shape","rest","_size","ctx","_shape","isGrid","role","a11yProps","components","root","always","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,IAAI,QAAQ,4BAA4B;AAE3E,SAASC,oCAAoC,QAAQ,8BAA8B;AAEnF;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CACrCC,OACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGJ;IACjC,MAAMK,QAAQP,qCAAqCQ,CAAAA,MAAOA,IAAIJ,IAAI;IAClE,MAAMK,SAAST,qCAAqCQ,CAAAA,MAAOA,IAAIH,KAAK;IACpE,MAAMK,SAASV,qCAAqCQ,CAAAA,MAAOA,IAAIE,MAAM;IAErE,MAAMC,OAAOD,SAAS,aAAa;IACnC,MAAME,YAAYF,SAAS,CAAC,IAAI;QAAE,gBAAgB;IAAM;IACxD,OAAO;QACLG,YAAY;YACVC,MAAM;QACR;QACAA,MAAMf,KAAKgB,MAAM,CACfjB,yBAAyB,UAAU;YACjCK;YACAQ;YACA,GAAGC,SAAS;YACZ,GAAGN,IAAI;QACT,IACA;YAAEU,aAAa;QAAS;QAE1BZ,MAAMA,iBAAAA,kBAAAA,OAAQG;QACdF,OAAOA,kBAAAA,mBAAAA,QAASI;IAClB;AACF,EAAE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { __resetStyles, __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
2
|
+
import { tokens } from '@fluentui/react-theme';
|
|
3
|
+
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
|
|
4
|
+
export const emptySwatchClassNames = {
|
|
5
|
+
root: 'fui-EmptySwatch'
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Styles for the root slot
|
|
9
|
+
*/
|
|
10
|
+
const useStyles = /*#__PURE__*/__resetStyles("r1top892", null, [".r1top892{background-color:var(--colorTransparentBackground);border:1px dashed var(--colorNeutralForeground4);}"]);
|
|
11
|
+
const useSizeStyles = /*#__PURE__*/__styles({
|
|
12
|
+
"extra-small": {
|
|
13
|
+
a9b677: "f64fuq3",
|
|
14
|
+
Bqenvij: "fjamq6b"
|
|
15
|
+
},
|
|
16
|
+
small: {
|
|
17
|
+
a9b677: "fq4mcun",
|
|
18
|
+
Bqenvij: "frvgh55"
|
|
19
|
+
},
|
|
20
|
+
medium: {
|
|
21
|
+
a9b677: "f1w9dchk",
|
|
22
|
+
Bqenvij: "fxldao9"
|
|
23
|
+
},
|
|
24
|
+
large: {
|
|
25
|
+
a9b677: "f1szoe96",
|
|
26
|
+
Bqenvij: "f1d2rq10"
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
d: [".f64fuq3{width:20px;}", ".fjamq6b{height:20px;}", ".fq4mcun{width:24px;}", ".frvgh55{height:24px;}", ".f1w9dchk{width:28px;}", ".fxldao9{height:28px;}", ".f1szoe96{width:32px;}", ".f1d2rq10{height:32px;}"]
|
|
30
|
+
});
|
|
31
|
+
const useShapeStyles = /*#__PURE__*/__styles({
|
|
32
|
+
rounded: {
|
|
33
|
+
Bbmb7ep: ["f1aa9q02", "f16jpd5f"],
|
|
34
|
+
Beyfa6y: ["f16jpd5f", "f1aa9q02"],
|
|
35
|
+
B7oj6ja: ["f1jar5jt", "fyu767a"],
|
|
36
|
+
Btl43ni: ["fyu767a", "f1jar5jt"],
|
|
37
|
+
kdpuga: ["f1o2ludy", "f1kjnpwc"],
|
|
38
|
+
Bw81rd7: ["f1kjnpwc", "f1o2ludy"],
|
|
39
|
+
B6xbmo0: ["fxmnebo", "f1witrsb"],
|
|
40
|
+
dm238s: ["f1witrsb", "fxmnebo"]
|
|
41
|
+
},
|
|
42
|
+
circular: {
|
|
43
|
+
Bbmb7ep: ["f8fbkgy", "f1nfllo7"],
|
|
44
|
+
Beyfa6y: ["f1nfllo7", "f8fbkgy"],
|
|
45
|
+
B7oj6ja: ["f1djnp8u", "f1s8kh49"],
|
|
46
|
+
Btl43ni: ["f1s8kh49", "f1djnp8u"],
|
|
47
|
+
kdpuga: ["fanj13w", "f1gou5sz"],
|
|
48
|
+
Bw81rd7: ["f1gou5sz", "fanj13w"],
|
|
49
|
+
B6xbmo0: ["fulf6x3", "foeb2x"],
|
|
50
|
+
dm238s: ["foeb2x", "fulf6x3"]
|
|
51
|
+
},
|
|
52
|
+
square: {
|
|
53
|
+
Bbmb7ep: ["fzi6hpg", "fyowgf4"],
|
|
54
|
+
Beyfa6y: ["fyowgf4", "fzi6hpg"],
|
|
55
|
+
B7oj6ja: ["f3fg2lr", "f13av6d4"],
|
|
56
|
+
Btl43ni: ["f13av6d4", "f3fg2lr"],
|
|
57
|
+
kdpuga: ["f1ndz5i7", "f1co4qro"],
|
|
58
|
+
Bw81rd7: ["f1co4qro", "f1ndz5i7"],
|
|
59
|
+
B6xbmo0: ["f146y5a9", "f1k2ftg"],
|
|
60
|
+
dm238s: ["f1k2ftg", "f146y5a9"]
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
d: [".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f1o2ludy[data-fui-focus-visible]{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f1kjnpwc[data-fui-focus-visible]{border-bottom-left-radius:var(--borderRadiusMedium);}", ".fxmnebo[data-fui-focus-visible]{border-top-right-radius:var(--borderRadiusMedium);}", ".f1witrsb[data-fui-focus-visible]{border-top-left-radius:var(--borderRadiusMedium);}", ".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".fanj13w[data-fui-focus-visible]{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1gou5sz[data-fui-focus-visible]{border-bottom-left-radius:var(--borderRadiusCircular);}", ".fulf6x3[data-fui-focus-visible]{border-top-right-radius:var(--borderRadiusCircular);}", ".foeb2x[data-fui-focus-visible]{border-top-left-radius:var(--borderRadiusCircular);}", ".fzi6hpg{border-bottom-right-radius:var(--borderRadiusNone);}", ".fyowgf4{border-bottom-left-radius:var(--borderRadiusNone);}", ".f3fg2lr{border-top-right-radius:var(--borderRadiusNone);}", ".f13av6d4{border-top-left-radius:var(--borderRadiusNone);}", ".f1ndz5i7[data-fui-focus-visible]{border-bottom-right-radius:var(--borderRadiusNone);}", ".f1co4qro[data-fui-focus-visible]{border-bottom-left-radius:var(--borderRadiusNone);}", ".f146y5a9[data-fui-focus-visible]{border-top-right-radius:var(--borderRadiusNone);}", ".f1k2ftg[data-fui-focus-visible]{border-top-left-radius:var(--borderRadiusNone);}"]
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Apply styling to the EmptySwatch slots based on the state
|
|
67
|
+
*/
|
|
68
|
+
export const useEmptySwatchStyles_unstable = state => {
|
|
69
|
+
const styles = useStyles();
|
|
70
|
+
const sizeStyles = useSizeStyles();
|
|
71
|
+
const shapeStyles = useShapeStyles();
|
|
72
|
+
var _state_size;
|
|
73
|
+
const size = (_state_size = state.size) !== null && _state_size !== void 0 ? _state_size : 'medium';
|
|
74
|
+
var _state_shape;
|
|
75
|
+
state.root.className = mergeClasses(emptySwatchClassNames.root, styles, sizeStyles[size], shapeStyles[(_state_shape = state.shape) !== null && _state_shape !== void 0 ? _state_shape : 'square'], state.root.className);
|
|
76
|
+
return state;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=useEmptySwatchStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__resetStyles","__styles","mergeClasses","shorthands","tokens","createCustomFocusIndicatorStyle","emptySwatchClassNames","root","useStyles","useSizeStyles","a9b677","Bqenvij","small","medium","large","d","useShapeStyles","rounded","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","kdpuga","Bw81rd7","B6xbmo0","dm238s","circular","square","useEmptySwatchStyles_unstable","state","styles","sizeStyles","shapeStyles","_state_size","size","_state_shape","className","shape"],"sources":["useEmptySwatchStyles.styles.js"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nexport const emptySwatchClassNames = {\n root: 'fui-EmptySwatch'\n};\n/**\n * Styles for the root slot\n */ const useStyles = makeResetStyles({\n backgroundColor: tokens.colorTransparentBackground,\n border: `1px dashed ${tokens.colorNeutralForeground4}`\n});\nconst useSizeStyles = makeStyles({\n 'extra-small': {\n width: '20px',\n height: '20px'\n },\n small: {\n width: '24px',\n height: '24px'\n },\n medium: {\n width: '28px',\n height: '28px'\n },\n large: {\n width: '32px',\n height: '32px'\n }\n});\nconst useShapeStyles = makeStyles({\n rounded: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...createCustomFocusIndicatorStyle({\n ...shorthands.borderRadius(tokens.borderRadiusMedium)\n })\n },\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n ...createCustomFocusIndicatorStyle({\n ...shorthands.borderRadius(tokens.borderRadiusCircular)\n })\n },\n square: {\n ...shorthands.borderRadius(tokens.borderRadiusNone),\n ...createCustomFocusIndicatorStyle({\n ...shorthands.borderRadius(tokens.borderRadiusNone)\n })\n }\n});\n/**\n * Apply styling to the EmptySwatch slots based on the state\n */ export const useEmptySwatchStyles_unstable = (state)=>{\n const styles = useStyles();\n const sizeStyles = useSizeStyles();\n const shapeStyles = useShapeStyles();\n var _state_size;\n const size = (_state_size = state.size) !== null && _state_size !== void 0 ? _state_size : 'medium';\n var _state_shape;\n state.root.className = mergeClasses(emptySwatchClassNames.root, styles, sizeStyles[size], shapeStyles[(_state_shape = state.shape) !== null && _state_shape !== void 0 ? _state_shape : 'square'], state.root.className);\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAAAC,QAAA,EAAsCC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACtF,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,OAAO,MAAMC,qBAAqB,GAAG;EACjCC,IAAI,EAAE;AACV,CAAC;AACD;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGR,aAAA,sIAGrB,CAAC;AACF,MAAMS,aAAa,gBAAGR,QAAA;EAAA;IAAAS,MAAA;IAAAC,OAAA;EAAA;EAAAC,KAAA;IAAAF,MAAA;IAAAC,OAAA;EAAA;EAAAE,MAAA;IAAAH,MAAA;IAAAC,OAAA;EAAA;EAAAG,KAAA;IAAAJ,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAI,CAAA;AAAA,CAiBrB,CAAC;AACF,MAAMC,cAAc,gBAAGf,QAAA;EAAAgB,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAR,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAE,MAAA;IAAAT,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAV,CAAA;AAAA,CAmBtB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMa,6BAA6B,GAAIC,KAAK,IAAG;EACtD,MAAMC,MAAM,GAAGtB,SAAS,CAAC,CAAC;EAC1B,MAAMuB,UAAU,GAAGtB,aAAa,CAAC,CAAC;EAClC,MAAMuB,WAAW,GAAGhB,cAAc,CAAC,CAAC;EACpC,IAAIiB,WAAW;EACf,MAAMC,IAAI,GAAG,CAACD,WAAW,GAAGJ,KAAK,CAACK,IAAI,MAAM,IAAI,IAAID,WAAW,KAAK,KAAK,CAAC,GAAGA,WAAW,GAAG,QAAQ;EACnG,IAAIE,YAAY;EAChBN,KAAK,CAACtB,IAAI,CAAC6B,SAAS,GAAGlC,YAAY,CAACI,qBAAqB,CAACC,IAAI,EAAEuB,MAAM,EAAEC,UAAU,CAACG,IAAI,CAAC,EAAEF,WAAW,CAAC,CAACG,YAAY,GAAGN,KAAK,CAACQ,KAAK,MAAM,IAAI,IAAIF,YAAY,KAAK,KAAK,CAAC,GAAGA,YAAY,GAAG,QAAQ,CAAC,EAAEN,KAAK,CAACtB,IAAI,CAAC6B,SAAS,CAAC;EACxN,OAAOP,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useImageSwatch_unstable } from './useImageSwatch';
|
|
3
|
+
import { renderImageSwatch_unstable } from './renderImageSwatch';
|
|
4
|
+
import { useImageSwatchStyles_unstable } from './useImageSwatchStyles.styles';
|
|
5
|
+
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
|
|
6
|
+
/**
|
|
7
|
+
* ImageSwatch component is used to render an images, patterns and textures.
|
|
8
|
+
*/ export const ImageSwatch = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
9
|
+
const state = useImageSwatch_unstable(props, ref);
|
|
10
|
+
useImageSwatchStyles_unstable(state);
|
|
11
|
+
useCustomStyleHook_unstable('useImageSwatchStyles_unstable')(state);
|
|
12
|
+
return renderImageSwatch_unstable(state);
|
|
13
|
+
});
|
|
14
|
+
ImageSwatch.displayName = 'ImageSwatch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ImageSwatch.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useImageSwatch_unstable } from './useImageSwatch';\nimport { renderImageSwatch_unstable } from './renderImageSwatch';\nimport { useImageSwatchStyles_unstable } from './useImageSwatchStyles.styles';\nimport type { ImageSwatchProps } from './ImageSwatch.types';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * ImageSwatch component is used to render an images, patterns and textures.\n */\nexport const ImageSwatch: ForwardRefComponent<ImageSwatchProps> = React.forwardRef((props, ref) => {\n const state = useImageSwatch_unstable(props, ref);\n\n useImageSwatchStyles_unstable(state);\n useCustomStyleHook_unstable('useImageSwatchStyles_unstable')(state);\n\n return renderImageSwatch_unstable(state);\n});\n\nImageSwatch.displayName = 'ImageSwatch';\n"],"names":["React","useImageSwatch_unstable","renderImageSwatch_unstable","useImageSwatchStyles_unstable","useCustomStyleHook_unstable","ImageSwatch","forwardRef","props","ref","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,gCAAgC;AAE9E,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;CAEC,GACD,OAAO,MAAMC,4BAAqDL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQR,wBAAwBM,OAAOC;IAE7CL,8BAA8BM;IAC9BL,4BAA4B,iCAAiCK;IAE7D,OAAOP,2BAA2BO;AACpC,GAAG;AAEHJ,YAAYK,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ImageSwatch.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { SwatchPickerProps } from '../SwatchPicker/SwatchPicker.types';\n\nexport type ImageSwatchSlots = {\n root: Slot<'button'>;\n};\n\n/**\n * ImageSwatch Props\n */\nexport type ImageSwatchProps = ComponentProps<ImageSwatchSlots> &\n Pick<SwatchPickerProps, 'size' | 'shape'> & {\n /**\n * Swatch color\n */\n src: string;\n\n /**\n * Swatch value\n */\n value: string;\n };\n\n/**\n * State used in rendering ImageSwatch\n */\nexport type ImageSwatchState = ComponentState<ImageSwatchSlots> &\n Pick<ImageSwatchProps, 'color' | 'size' | 'shape' | 'value'> & {\n selected: boolean;\n };\n"],"names":[],"mappings":"AAAA,WA6BI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ImageSwatch';\nexport * from './ImageSwatch.types';\nexport * from './renderImageSwatch';\nexport * from './useImageSwatch';\nexport * from './useImageSwatchStyles.styles';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,gCAAgC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* Render the final JSX of ImageSwatch
|
|
5
|
+
*/ export const renderImageSwatch_unstable = (state)=>{
|
|
6
|
+
assertSlots(state);
|
|
7
|
+
return /*#__PURE__*/ _jsx(state.root, {});
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renderImageSwatch.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { ImageSwatchState, ImageSwatchSlots } from './ImageSwatch.types';\n\n/**\n * Render the final JSX of ImageSwatch\n */\nexport const renderImageSwatch_unstable = (state: ImageSwatchState) => {\n assertSlots<ImageSwatchSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderImageSwatch_unstable","state","root"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CAACC;IACzCF,YAA8BE;IAE9B,qBAAO,KAACA,MAAMC,IAAI;AACpB,EAAE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getIntrinsicElementProps, slot, useEventCallback, mergeCallbacks } from '@fluentui/react-utilities';
|
|
3
|
+
import { useSwatchPickerContextValue_unstable } from '../../contexts/swatchPicker';
|
|
4
|
+
/**
|
|
5
|
+
* Create the state required to render ImageSwatch.
|
|
6
|
+
*
|
|
7
|
+
* The returned state can be modified with hooks such as useImageSwatchStyles_unstable,
|
|
8
|
+
* before being passed to renderImageSwatch_unstable.
|
|
9
|
+
*
|
|
10
|
+
* @param props - props from this instance of ImageSwatch
|
|
11
|
+
* @param ref - reference to root HTMLDivElement of ImageSwatch
|
|
12
|
+
*/ export const useImageSwatch_unstable = (props, ref)=>{
|
|
13
|
+
const { src, value, onClick, style, ...rest } = props;
|
|
14
|
+
const size = useSwatchPickerContextValue_unstable((ctx)=>ctx.size);
|
|
15
|
+
const shape = useSwatchPickerContextValue_unstable((ctx)=>ctx.shape);
|
|
16
|
+
const isGrid = useSwatchPickerContextValue_unstable((ctx)=>ctx.isGrid);
|
|
17
|
+
const requestSelectionChange = useSwatchPickerContextValue_unstable((ctx)=>ctx.requestSelectionChange);
|
|
18
|
+
const selected = useSwatchPickerContextValue_unstable((ctx)=>ctx.selectedValue === value);
|
|
19
|
+
const role = isGrid ? 'gridcell' : 'radio';
|
|
20
|
+
const ariaSelected = isGrid ? {
|
|
21
|
+
'aria-selected': selected
|
|
22
|
+
} : {
|
|
23
|
+
'aria-checked': selected
|
|
24
|
+
};
|
|
25
|
+
const onImageSwatchClick = useEventCallback(mergeCallbacks(onClick, (event)=>requestSelectionChange(event, {
|
|
26
|
+
selectedValue: value,
|
|
27
|
+
selectedSwatch: src
|
|
28
|
+
})));
|
|
29
|
+
return {
|
|
30
|
+
components: {
|
|
31
|
+
root: 'button'
|
|
32
|
+
},
|
|
33
|
+
root: slot.always(getIntrinsicElementProps('button', {
|
|
34
|
+
ref,
|
|
35
|
+
role,
|
|
36
|
+
...ariaSelected,
|
|
37
|
+
onClick: onImageSwatchClick,
|
|
38
|
+
...rest,
|
|
39
|
+
style: {
|
|
40
|
+
backgroundImage: `url(${src})`,
|
|
41
|
+
...style
|
|
42
|
+
}
|
|
43
|
+
}), {
|
|
44
|
+
elementType: 'button'
|
|
45
|
+
}),
|
|
46
|
+
value,
|
|
47
|
+
selected,
|
|
48
|
+
size,
|
|
49
|
+
shape
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useImageSwatch.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot, useEventCallback, mergeCallbacks } from '@fluentui/react-utilities';\nimport type { ImageSwatchProps, ImageSwatchState } from './ImageSwatch.types';\nimport { useSwatchPickerContextValue_unstable } from '../../contexts/swatchPicker';\n\n/**\n * Create the state required to render ImageSwatch.\n *\n * The returned state can be modified with hooks such as useImageSwatchStyles_unstable,\n * before being passed to renderImageSwatch_unstable.\n *\n * @param props - props from this instance of ImageSwatch\n * @param ref - reference to root HTMLDivElement of ImageSwatch\n */\nexport const useImageSwatch_unstable = (\n props: ImageSwatchProps,\n ref: React.Ref<HTMLButtonElement>,\n): ImageSwatchState => {\n const { src, value, onClick, style, ...rest } = props;\n const size = useSwatchPickerContextValue_unstable(ctx => ctx.size);\n const shape = useSwatchPickerContextValue_unstable(ctx => ctx.shape);\n const isGrid = useSwatchPickerContextValue_unstable(ctx => ctx.isGrid);\n\n const requestSelectionChange = useSwatchPickerContextValue_unstable(ctx => ctx.requestSelectionChange);\n const selected = useSwatchPickerContextValue_unstable(ctx => ctx.selectedValue === value);\n\n const role = isGrid ? 'gridcell' : 'radio';\n const ariaSelected = isGrid\n ? {\n 'aria-selected': selected,\n }\n : { 'aria-checked': selected };\n\n const onImageSwatchClick = useEventCallback(\n mergeCallbacks(onClick, (event: React.MouseEvent<HTMLButtonElement>) =>\n requestSelectionChange(event, {\n selectedValue: value,\n selectedSwatch: src,\n }),\n ),\n );\n\n return {\n components: {\n root: 'button',\n },\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref,\n role,\n ...ariaSelected,\n onClick: onImageSwatchClick,\n ...rest,\n style: {\n backgroundImage: `url(${src})`,\n ...style,\n },\n }),\n { elementType: 'button' },\n ),\n value,\n selected,\n size,\n shape,\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useEventCallback","mergeCallbacks","useSwatchPickerContextValue_unstable","useImageSwatch_unstable","props","ref","src","value","onClick","style","rest","size","ctx","shape","isGrid","requestSelectionChange","selected","selectedValue","role","ariaSelected","onImageSwatchClick","event","selectedSwatch","components","root","always","backgroundImage","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7G,SAASC,oCAAoC,QAAQ,8BAA8B;AAEnF;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CACrCC,OACAC;IAEA,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGN;IAChD,MAAMO,OAAOT,qCAAqCU,CAAAA,MAAOA,IAAID,IAAI;IACjE,MAAME,QAAQX,qCAAqCU,CAAAA,MAAOA,IAAIC,KAAK;IACnE,MAAMC,SAASZ,qCAAqCU,CAAAA,MAAOA,IAAIE,MAAM;IAErE,MAAMC,yBAAyBb,qCAAqCU,CAAAA,MAAOA,IAAIG,sBAAsB;IACrG,MAAMC,WAAWd,qCAAqCU,CAAAA,MAAOA,IAAIK,aAAa,KAAKV;IAEnF,MAAMW,OAAOJ,SAAS,aAAa;IACnC,MAAMK,eAAeL,SACjB;QACE,iBAAiBE;IACnB,IACA;QAAE,gBAAgBA;IAAS;IAE/B,MAAMI,qBAAqBpB,iBACzBC,eAAeO,SAAS,CAACa,QACvBN,uBAAuBM,OAAO;YAC5BJ,eAAeV;YACfe,gBAAgBhB;QAClB;IAIJ,OAAO;QACLiB,YAAY;YACVC,MAAM;QACR;QACAA,MAAMzB,KAAK0B,MAAM,CACf3B,yBAAyB,UAAU;YACjCO;YACAa;YACA,GAAGC,YAAY;YACfX,SAASY;YACT,GAAGV,IAAI;YACPD,OAAO;gBACLiB,iBAAiB,CAAC,IAAI,EAAEpB,IAAI,CAAC,CAAC;gBAC9B,GAAGG,KAAK;YACV;QACF,IACA;YAAEkB,aAAa;QAAS;QAE1BpB;QACAS;QACAL;QACAE;IACF;AACF,EAAE"}
|