@talxis/base-controls 1.2410.2 → 1.2410.3

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.
@@ -1,6 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { ThemeProvider, Toggle } from '@fluentui/react';
3
3
  import { useRef, useEffect } from 'react';
4
+ import { OptionSet } from '../OptionSet/OptionSet.js';
4
5
  import { useControl } from '../../hooks/useControl.js';
5
6
 
6
7
  const TwoOptions = (props) => {
@@ -12,15 +13,32 @@ const TwoOptions = (props) => {
12
13
  const componentRef = useRef(null);
13
14
  useEffect(() => {
14
15
  if (parameters.AutoFocus?.raw === true) {
15
- componentRef.current.focus();
16
+ componentRef.current?.focus();
16
17
  }
17
18
  }, []);
19
+ const isColorFeatureEnabled = () => {
20
+ if (props.parameters.EnableOptionSetColors?.raw && options.find(x => x.Color)) {
21
+ return true;
22
+ }
23
+ return false;
24
+ };
18
25
  const handleChange = (value) => {
19
26
  onNotifyOutputChanged({
20
27
  value: value
21
28
  });
22
29
  };
23
- return (jsx(ThemeProvider, { theme: theme, applyTo: 'none', children: jsx(Toggle, { styles: {
30
+ return (jsx(ThemeProvider, { theme: theme, applyTo: 'none', children: isColorFeatureEnabled() ? (jsx(OptionSet, { context: props.context, parameters: {
31
+ value: {
32
+ raw: boundValue.raw !== null ? boundValue.raw ? 1 : 0 : boundValue.raw,
33
+ //@ts-ignore - typings
34
+ attributes: boundValue.attributes
35
+ },
36
+ EnableOptionSetColors: {
37
+ raw: true
38
+ },
39
+ }, onNotifyOutputChanged: (outputs) => {
40
+ handleChange(outputs.value == 1 ? true : outputs.value == 0 ? false : undefined);
41
+ } })) : (jsx(Toggle, { styles: {
24
42
  root: {
25
43
  height: sizing.height,
26
44
  width: sizing.width,
@@ -29,7 +47,7 @@ const TwoOptions = (props) => {
29
47
  container: {
30
48
  alignItems: 'center'
31
49
  }
32
- }, theme: theme, checked: boundValue.raw, componentRef: componentRef, disabled: context.mode.isControlDisabled, inlineLabel: true, onText: options.find(option => option.Value === 1)?.Label || 'Yes', offText: options.find(option => option.Value === 0)?.Label || 'No', onChange: (e, value) => handleChange(value) }) }));
50
+ }, theme: theme, checked: boundValue.raw, componentRef: componentRef, disabled: context.mode.isControlDisabled, inlineLabel: true, onText: options.find(option => option.Value === 1)?.Label || 'Yes', offText: options.find(option => option.Value === 0)?.Label || 'No', onChange: (e, value) => handleChange(value) })) }));
33
51
  };
34
52
 
35
53
  export { TwoOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"TwoOptions.js","sources":["../../../src/components/TwoOptions/TwoOptions.tsx"],"sourcesContent":["import { ThemeProvider, Toggle } from '@fluentui/react';\nimport { useControl } from '../../hooks';\nimport { ITwoOptions } from './interfaces';\nimport React, { useEffect, useRef } from 'react';\n\nexport const TwoOptions = (props: ITwoOptions) => {\n const parameters = props.parameters;\n const boundValue = parameters.value;\n const options = boundValue.attributes.Options;\n const { sizing, onNotifyOutputChanged, theme } = useControl('TwoOptions', props);\n const context = props.context;\n const componentRef = useRef<any>(null);\n\n useEffect(() => {\n if (parameters.AutoFocus?.raw === true) {\n componentRef.current.focus();\n }\n }, []);\n\n const handleChange = (value: boolean | undefined): void => {\n onNotifyOutputChanged({\n value: value\n });\n };\n\n return (\n <ThemeProvider theme={theme} applyTo='none'>\n <Toggle\n styles={{\n root: {\n height: sizing.height,\n width: sizing.width,\n marginBottom: 0,\n },\n container: {\n alignItems: 'center'\n }\n }}\n theme={theme}\n checked={boundValue.raw}\n componentRef={componentRef}\n disabled={context.mode.isControlDisabled}\n inlineLabel\n onText={options.find(option => option.Value === 1)?.Label || 'Yes'}\n offText={options.find(option => option.Value === 0)?.Label || 'No'}\n onChange={(e, value) => handleChange(value)}\n />\n </ThemeProvider>\n )\n};"],"names":["_jsx"],"mappings":";;;;;AAKa,MAAA,UAAU,GAAG,CAAC,KAAkB,KAAI;AAC7C,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC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OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,KAAK,IAAI,KAAK,EAClE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,KAAK,IAAI,IAAI,EAClE,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,YAAY,CAAC,KAAK,CAAC,EAC7C,CAAA,EAAA,CACU,EACnB;AACL;;;;"}
1
+ {"version":3,"file":"TwoOptions.js","sources":["../../../src/components/TwoOptions/TwoOptions.tsx"],"sourcesContent":["import { ThemeProvider, Toggle } from '@fluentui/react';\nimport { useControl } from '../../hooks';\nimport { ITwoOptions } from './interfaces';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { OptionSet } from '../OptionSet';\n\nexport const TwoOptions = (props: ITwoOptions) => {\n const parameters = props.parameters;\n const boundValue = parameters.value;\n const options = boundValue.attributes.Options;\n const { sizing, onNotifyOutputChanged, theme } = useControl('TwoOptions', props);\n const context = props.context;\n const componentRef = useRef<any>(null);\n\n useEffect(() => {\n if (parameters.AutoFocus?.raw === true) {\n componentRef.current?.focus();\n }\n }, []);\n\n const isColorFeatureEnabled = () => {\n if (props.parameters.EnableOptionSetColors?.raw && options.find(x => x.Color)) {\n return true;\n }\n return false;\n }\n\n const handleChange = (value: boolean | undefined): void => {\n onNotifyOutputChanged({\n value: value\n });\n };\n\n return (\n <ThemeProvider theme={theme} applyTo='none'>\n {isColorFeatureEnabled() ? (\n <OptionSet\n context={props.context}\n parameters={{\n value: {\n raw: boundValue.raw !== null ? boundValue.raw ? 1 : 0 : boundValue.raw,\n //@ts-ignore - typings\n attributes: boundValue.attributes\n },\n EnableOptionSetColors: {\n raw: true\n },\n }}\n onNotifyOutputChanged={(outputs) => {\n handleChange(outputs.value == 1 ? true : outputs.value == 0 ? false : undefined);\n }}\n />\n ) : (\n <Toggle\n styles={{\n root: {\n height: sizing.height,\n width: sizing.width,\n marginBottom: 0,\n },\n container: {\n alignItems: 'center'\n }\n }}\n theme={theme}\n checked={boundValue.raw}\n componentRef={componentRef}\n disabled={context.mode.isControlDisabled}\n inlineLabel\n onText={options.find(option => option.Value === 1)?.Label || 'Yes'}\n offText={options.find(option => option.Value === 0)?.Label || 'No'}\n onChange={(e, value) => handleChange(value)}\n />)}\n </ThemeProvider>\n )\n};"],"names":["_jsx"],"mappings":";;;;;;AAMa,MAAA,UAAU,GAAG,CAAC,KAAkB,KAAI;AAC7C,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACpC,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;AAC9C,IAAA,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACjF,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,YAAY,GAAG,MAAM,CAAM,IAAI,CAAC,CAAC;IAEvC,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,UAAU,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,EAAE;AACpC,YAAA,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;AACjC,SAAA;KACJ,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,qBAAqB,GAAG,MAAK;QAC/B,IAAI,KAAK,CAAC,UAAU,CAAC,qBAAqB,EAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE;AAC3E,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AACD,QAAA,OAAO,KAAK,CAAC;AACjB,KAAC,CAAA;AAED,IAAA,MAAM,YAAY,GAAG,CAAC,KAA0B,KAAU;AACtD,QAAA,qBAAq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,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,KAAK,IAAI,KAAK,EAClE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,KAAK,IAAI,IAAI,EAClE,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,YAAY,CAAC,KAAK,CAAC,GAC7C,CAAC,EAAA,CACK,EACnB;AACL;;;;"}
@@ -6,6 +6,7 @@ export interface ITwoOptions extends IControl<ITwoOptionsParameters, ITwoOptions
6
6
  }
7
7
  export interface ITwoOptionsParameters extends IBaseParameters {
8
8
  value: ITwoOptionsProperty;
9
+ EnableOptionSetColors?: Omit<ITwoOptionsProperty, 'attributes'>;
9
10
  }
10
11
  export interface ITwoOptionsOutputs extends IOutputs {
11
12
  value?: boolean;
package/dist/index.d.ts CHANGED
@@ -848,6 +848,7 @@ interface ITwoOptions extends IControl<ITwoOptionsParameters, ITwoOptionsOutputs
848
848
  }
849
849
  interface ITwoOptionsParameters extends IBaseParameters {
850
850
  value: ITwoOptionsProperty;
851
+ EnableOptionSetColors?: Omit<ITwoOptionsProperty, 'attributes'>;
851
852
  }
852
853
  interface ITwoOptionsOutputs extends IOutputs$1 {
853
854
  value?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talxis/base-controls",
3
- "version": "1.2410.2",
3
+ "version": "1.2410.3",
4
4
  "description": "Set of React components that natively work with Power Apps Component Framework API's",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",