@talxis/base-controls 1.2406.13 → 1.2406.15

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,14 +1 @@
1
- export { L as Lookup } from '../../Lookup-85a4c52d.js';
2
- import 'react/jsx-runtime';
3
- import 'react';
4
- import '@fluentui/react';
5
- import '@talxis/react-components/dist/components/TagPicker';
6
- import '../../hooks/useMouseOver.js';
7
- import '../../hooks/useFocusIn.js';
8
- import '../../hooks/useComponentSizing.js';
9
- import '../../hooks/useComponent.js';
10
- import 'fast-deep-equal/es6';
11
- import 'merge-anything';
12
- import 'liquidjs';
13
- import '@fluentui/react/lib/Text';
14
- import '@fluentui/react/lib/components/Button/CommandBarButton/CommandBarButton';
1
+ export{L as Lookup}from"../../Lookup-85a4c52d.js";import"react/jsx-runtime";import"react";import"@fluentui/react";import"@talxis/react-components/dist/components/TagPicker";import"../../hooks/useMouseOver.js";import"../../hooks/useFocusIn.js";import"../../hooks/useComponentSizing.js";import"../../hooks/useComponent.js";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"@fluentui/react/lib/Text";import"@fluentui/react/lib/components/Button/CommandBarButton/CommandBarButton";
@@ -1,72 +1 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useComponent } from '../../hooks/useComponent.js';
3
- import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
4
- import { useRef, useEffect } from 'react';
5
- import 'fast-deep-equal/es6';
6
- import 'merge-anything';
7
- import 'liquidjs';
8
- import '../../hooks/useComponentSizing.js';
9
-
10
- const MultiSelectOptionSet = (props) => {
11
- var _a, _b;
12
- const { sizing, onNotifyOutputChanged } = useComponent('MultiSelectOptionSet', props);
13
- const parameters = props.parameters;
14
- const boundValue = parameters.value;
15
- const componentRef = useRef(null);
16
- const { Options } = parameters.value.attributes;
17
- const context = props.context;
18
- const comboBoxOptions = Options.map(option => ({
19
- key: option.Value.toString(),
20
- text: option.Label,
21
- }));
22
- const handleChange = (option) => {
23
- if (!option) {
24
- onNotifyOutputChanged({
25
- value: undefined
26
- });
27
- return;
28
- }
29
- const optionKey = option.key.toString();
30
- const updatedSelectedKeys = new Set(boundValue.raw || []);
31
- if (option.selected) {
32
- updatedSelectedKeys.add(+optionKey);
33
- }
34
- else {
35
- updatedSelectedKeys.delete(+optionKey);
36
- }
37
- const updatedSelectedKeysArray = Array.from(updatedSelectedKeys);
38
- onNotifyOutputChanged({
39
- value: updatedSelectedKeysArray.map(key => +key)
40
- });
41
- };
42
- useEffect(() => {
43
- var _a, _b;
44
- if ((_a = parameters.AutoFocus) === null || _a === void 0 ? void 0 : _a.raw) {
45
- (_b = componentRef.current) === null || _b === void 0 ? void 0 : _b.focus(true);
46
- }
47
- }, []);
48
- return jsx(ComboBox, { componentRef: componentRef, borderless: ((_a = parameters.EnableBorder) === null || _a === void 0 ? void 0 : _a.raw) === false, options: comboBoxOptions, allowFreeInput: true, multiSelect: true, autoComplete: "on", autofill: ((_b = parameters.AutoFocus) === null || _b === void 0 ? void 0 : _b.raw) === true ? {
49
- autoFocus: true
50
- } : undefined, readOnly: context.mode.isControlDisabled, errorMessage: boundValue.errorMessage, selectedKey: boundValue.raw ? boundValue.raw.map(key => key.toString()) : [-1], useComboBoxAsMenuWidth: true, styles: {
51
- root: {
52
- height: sizing.height,
53
- width: sizing.width,
54
- display: 'flex',
55
- alignItems: 'center',
56
- },
57
- callout: {
58
- maxHeight: '300px !important'
59
- }
60
- }, deleteButtonProps: {
61
- key: 'delete',
62
- showOnlyOnHover: false,
63
- iconProps: {
64
- iconName: 'Delete'
65
- },
66
- onClick: (e, value) => {
67
- handleChange(null);
68
- }
69
- }, onChange: (e, option) => handleChange(option) });
70
- };
71
-
72
- export { MultiSelectOptionSet };
1
+ import{jsx as e}from"react/jsx-runtime";import{useComponent as o}from"../../hooks/useComponent.js";import{ComboBox as t}from"@talxis/react-components/dist/components/ComboBox";import{useRef as r,useEffect as n}from"react";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"../../hooks/useComponentSizing.js";const i=i=>{var l,a;const{sizing:s,onNotifyOutputChanged:u}=o("MultiSelectOptionSet",i),m=i.parameters,d=m.value,p=r(null),{Options:c}=m.value.attributes,v=i.context,g=c.map((e=>({key:e.Value.toString(),text:e.Label}))),h=e=>{if(!e)return void u({value:void 0});const o=e.key.toString(),t=new Set(d.raw||[]);e.selected?t.add(+o):t.delete(+o);const r=Array.from(t);u({value:r.map((e=>+e))})};return n((()=>{var e,o;(null===(e=m.AutoFocus)||void 0===e?void 0:e.raw)&&(null===(o=p.current)||void 0===o||o.focus(!0))}),[]),e(t,{componentRef:p,borderless:!1===(null===(l=m.EnableBorder)||void 0===l?void 0:l.raw),options:g,allowFreeInput:!0,multiSelect:!0,autoComplete:"on",autofill:!0===(null===(a=m.AutoFocus)||void 0===a?void 0:a.raw)?{autoFocus:!0}:void 0,readOnly:v.mode.isControlDisabled,errorMessage:d.errorMessage,selectedKey:d.raw?d.raw.map((e=>e.toString())):[-1],useComboBoxAsMenuWidth:!0,styles:{root:{height:s.height,width:s.width,display:"flex",alignItems:"center"},callout:{maxHeight:"300px !important"}},deleteButtonProps:{key:"delete",showOnlyOnHover:!1,iconProps:{iconName:"Delete"},onClick:(e,o)=>{h(null)}},onChange:(e,o)=>h(o)})};export{i as MultiSelectOptionSet};
@@ -1,59 +1 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useComponent } from '../../hooks/useComponent.js';
3
- import { ComboBox } from '@talxis/react-components/dist/components/ComboBox';
4
- import { useRef, useEffect } from 'react';
5
- import 'fast-deep-equal/es6';
6
- import 'merge-anything';
7
- import 'liquidjs';
8
- import '../../hooks/useComponentSizing.js';
9
-
10
- const OptionSet = (props) => {
11
- var _a, _b, _c;
12
- const { sizing, onNotifyOutputChanged } = useComponent('OptionSet', props);
13
- const componentRef = useRef(null);
14
- const parameters = props.parameters;
15
- const boundValue = parameters.value;
16
- const { Options } = parameters.value.attributes;
17
- const context = props.context;
18
- const comboBoxOptions = Options.map(option => ({
19
- key: option.Value.toString(),
20
- text: option.Label,
21
- }));
22
- const handleChange = (option) => {
23
- let value = undefined;
24
- if (option) {
25
- value = parseInt(option.key);
26
- }
27
- onNotifyOutputChanged({
28
- value: value
29
- });
30
- };
31
- useEffect(() => {
32
- var _a, _b;
33
- if ((_a = parameters.AutoFocus) === null || _a === void 0 ? void 0 : _a.raw) {
34
- (_b = componentRef.current) === null || _b === void 0 ? void 0 : _b.focus(true);
35
- }
36
- }, []);
37
- return jsx(ComboBox, { componentRef: componentRef, borderless: ((_a = parameters.EnableBorder) === null || _a === void 0 ? void 0 : _a.raw) === false, options: comboBoxOptions, readOnly: context.mode.isControlDisabled,
38
- //the defaultValue comes in the raw prop directly, no need to look at it
39
- selectedKey: (_c = (_b = boundValue.raw) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : -1, errorMessage: boundValue.errorMessage, useComboBoxAsMenuWidth: true, styles: {
40
- root: {
41
- height: sizing.height,
42
- width: sizing.width,
43
- display: 'flex',
44
- alignItems: 'center',
45
- },
46
- callout: {
47
- maxHeight: '300px !important'
48
- }
49
- }, deleteButtonProps: {
50
- key: 'delete',
51
- showOnlyOnHover: true,
52
- iconProps: {
53
- iconName: 'Delete'
54
- },
55
- onClick: (e, value) => { handleChange(null); }
56
- }, onChange: (e, option) => handleChange(option) });
57
- };
58
-
59
- export { OptionSet };
1
+ import{jsx as e}from"react/jsx-runtime";import{useComponent as o}from"../../hooks/useComponent.js";import{ComboBox as t}from"@talxis/react-components/dist/components/ComboBox";import{useRef as r,useEffect as n}from"react";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"../../hooks/useComponentSizing.js";const i=i=>{var s,l,a;const{sizing:m,onNotifyOutputChanged:u}=o("OptionSet",i),p=r(null),d=i.parameters,c=d.value,{Options:g}=d.value.attributes,h=i.context,v=g.map((e=>({key:e.Value.toString(),text:e.Label}))),x=e=>{let o;e&&(o=parseInt(e.key)),u({value:o})};return n((()=>{var e,o;(null===(e=d.AutoFocus)||void 0===e?void 0:e.raw)&&(null===(o=p.current)||void 0===o||o.focus(!0))}),[]),e(t,{componentRef:p,borderless:!1===(null===(s=d.EnableBorder)||void 0===s?void 0:s.raw),options:v,readOnly:h.mode.isControlDisabled,selectedKey:null!==(a=null===(l=c.raw)||void 0===l?void 0:l.toString())&&void 0!==a?a:-1,errorMessage:c.errorMessage,useComboBoxAsMenuWidth:!0,styles:{root:{height:m.height,width:m.width,display:"flex",alignItems:"center"},callout:{maxHeight:"300px !important"}},deleteButtonProps:{key:"delete",showOnlyOnHover:!0,iconProps:{iconName:"Delete"},onClick:(e,o)=>{x(null)}},onChange:(e,o)=>x(o)})};export{i as OptionSet};
@@ -1,86 +1 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { TextField as TextField$1 } from '@talxis/react-components/dist/components/TextField';
3
- import { useRef, useState, useEffect } from 'react';
4
- import { useInputBasedComponent } from '../../hooks/useInputBasedComponent.js';
5
- import '../../hooks/useComponent.js';
6
- import 'fast-deep-equal/es6';
7
- import 'merge-anything';
8
- import 'liquidjs';
9
- import '../../hooks/useComponentSizing.js';
10
-
11
- const useTextFieldHeight = (ref, initialHeight, isMultiline) => {
12
- const getInitialHeight = () => {
13
- if (initialHeight) {
14
- return initialHeight;
15
- }
16
- if (isMultiline) {
17
- return 80;
18
- }
19
- return undefined;
20
- };
21
- const hasBeenResizedRef = useRef(false);
22
- const [height, setHeight] = useState(getInitialHeight());
23
- const firstRenderRef = useRef(true);
24
- useEffect(() => {
25
- var _a;
26
- if (!isMultiline) {
27
- return;
28
- }
29
- const resizeObserver = new ResizeObserver(() => {
30
- if (firstRenderRef.current || hasBeenResizedRef.current) {
31
- firstRenderRef.current = false;
32
- return;
33
- }
34
- hasBeenResizedRef.current = true;
35
- setHeight(undefined);
36
- });
37
- const textarea = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector('textarea');
38
- if (height) {
39
- textarea.setAttribute('style', `height: ${height}px`);
40
- }
41
- resizeObserver.observe(textarea);
42
- return () => {
43
- resizeObserver.disconnect();
44
- };
45
- }, []);
46
- return [height];
47
- };
48
-
49
- const TextField = (props) => {
50
- var _a, _b, _c, _d, _e, _f, _g;
51
- const context = props.context;
52
- const parameters = props.parameters;
53
- const boundValue = parameters.value;
54
- const ref = useRef(null);
55
- const { value, sizing, setValue, onNotifyOutputChanged } = useInputBasedComponent('TextField', props);
56
- const [height] = useTextFieldHeight(ref, sizing.height, (_a = props.parameters.IsMultiLine) === null || _a === void 0 ? void 0 : _a.raw);
57
- return (jsx(TextField$1, { readOnly: context.mode.isControlDisabled,
58
- //TODO: should be inherited by the type, eg TextArea = multiline
59
- multiline: (_b = parameters.IsMultiLine) === null || _b === void 0 ? void 0 : _b.raw, resizable: (_c = parameters.isResizable) === null || _c === void 0 ? void 0 : _c.raw, autoFocus: (_d = parameters.AutoFocus) === null || _d === void 0 ? void 0 : _d.raw, elementRef: ref, styles: {
60
- fieldGroup: {
61
- height: height,
62
- width: context.mode.allocatedWidth || undefined
63
- }
64
- }, borderless: ((_e = parameters.EnableBorder) === null || _e === void 0 ? void 0 : _e.raw) === false, errorMessage: boundValue.errorMessage, deleteButtonProps: ((_f = parameters.EnableDeleteButton) === null || _f === void 0 ? void 0 : _f.raw) === true ? {
65
- key: 'delete',
66
- showOnlyOnHover: true,
67
- iconProps: {
68
- iconName: 'Delete'
69
- },
70
- onClick: () => setValue(undefined)
71
- } : undefined, clickToCopyProps: ((_g = parameters.EnableCopyButton) === null || _g === void 0 ? void 0 : _g.raw) === true ? {
72
- key: 'copy',
73
- showOnlyOnHover: true,
74
- iconProps: {
75
- iconName: 'Copy'
76
- }
77
- } : undefined, value: value !== null && value !== void 0 ? value : "", onBlur: () => {
78
- onNotifyOutputChanged({
79
- value: value !== null && value !== void 0 ? value : undefined
80
- });
81
- }, onChange: (e, value) => {
82
- setValue(value);
83
- } }));
84
- };
85
-
86
- export { TextField };
1
+ import{jsx as e}from"react/jsx-runtime";import{TextField as o}from"@talxis/react-components/dist/components/TextField";import{useRef as t,useState as r,useEffect as i}from"react";import{useInputBasedComponent as n}from"../../hooks/useInputBasedComponent.js";import"../../hooks/useComponent.js";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"../../hooks/useComponentSizing.js";const l=l=>{var s,u,a,d,v,p,c;const m=l.context,h=l.parameters,y=h.value,g=t(null),{value:w,sizing:b,setValue:C,onNotifyOutputChanged:f}=n("TextField",l),[x]=((e,o,n)=>{const l=t(!1),[s,u]=r(o||(n?80:void 0)),a=t(!0);return i((()=>{var o;if(!n)return;const t=new ResizeObserver((()=>{a.current||l.current?a.current=!1:(l.current=!0,u(void 0))})),r=null===(o=e.current)||void 0===o?void 0:o.querySelector("textarea");return s&&r.setAttribute("style",`height: ${s}px`),t.observe(r),()=>{t.disconnect()}}),[]),[s]})(g,b.height,null===(s=l.parameters.IsMultiLine)||void 0===s?void 0:s.raw);return e(o,{readOnly:m.mode.isControlDisabled,multiline:null===(u=h.IsMultiLine)||void 0===u?void 0:u.raw,resizable:null===(a=h.isResizable)||void 0===a?void 0:a.raw,autoFocus:null===(d=h.AutoFocus)||void 0===d?void 0:d.raw,elementRef:g,styles:{fieldGroup:{height:x,width:m.mode.allocatedWidth||void 0}},borderless:!1===(null===(v=h.EnableBorder)||void 0===v?void 0:v.raw),errorMessage:y.errorMessage,deleteButtonProps:!0===(null===(p=h.EnableDeleteButton)||void 0===p?void 0:p.raw)?{key:"delete",showOnlyOnHover:!0,iconProps:{iconName:"Delete"},onClick:()=>C(void 0)}:void 0,clickToCopyProps:!0===(null===(c=h.EnableCopyButton)||void 0===c?void 0:c.raw)?{key:"copy",showOnlyOnHover:!0,iconProps:{iconName:"Copy"}}:void 0,value:null!=w?w:"",onBlur:()=>{f({value:null!=w?w:void 0})},onChange:(e,o)=>{C(o)}})};export{l as TextField};
@@ -1,40 +1 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { Toggle } from '@fluentui/react';
3
- import { useComponent } from '../../hooks/useComponent.js';
4
- import { useRef, useEffect } from 'react';
5
- import 'fast-deep-equal/es6';
6
- import 'merge-anything';
7
- import 'liquidjs';
8
- import '../../hooks/useComponentSizing.js';
9
-
10
- const TwoOptions = (props) => {
11
- var _a, _b;
12
- const parameters = props.parameters;
13
- const boundValue = parameters.value;
14
- const options = boundValue.attributes.Options;
15
- const { sizing, onNotifyOutputChanged } = useComponent('TwoOptions', props);
16
- props.context;
17
- const componentRef = useRef(null);
18
- useEffect(() => {
19
- var _a;
20
- if (((_a = parameters.AutoFocus) === null || _a === void 0 ? void 0 : _a.raw) === true) {
21
- componentRef.current.focus();
22
- }
23
- }, []);
24
- const handleChange = (value) => {
25
- onNotifyOutputChanged({
26
- value: value
27
- });
28
- };
29
- return jsx(Toggle, { styles: {
30
- root: {
31
- height: sizing.height,
32
- width: sizing.width
33
- },
34
- container: {
35
- alignItems: 'center'
36
- }
37
- }, checked: boundValue.raw, componentRef: componentRef, inlineLabel: true, onText: ((_a = options.find(option => option.Value === 1)) === null || _a === void 0 ? void 0 : _a.Label) || 'Yes', offText: ((_b = options.find(option => option.Value === 0)) === null || _b === void 0 ? void 0 : _b.Label) || 'No', onChange: (e, value) => handleChange(value) });
38
- };
39
-
40
- export { TwoOptions };
1
+ import{jsx as o}from"react/jsx-runtime";import{Toggle as t}from"@fluentui/react";import{useComponent as e}from"../../hooks/useComponent.js";import{useRef as i,useEffect as n}from"react";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"../../hooks/useComponentSizing.js";const r=r=>{var a,s;const u=r.parameters,l=u.value,m=l.attributes.Options,{sizing:p,onNotifyOutputChanged:c}=e("TwoOptions",r);r.context;const d=i(null);n((()=>{var o;!0===(null===(o=u.AutoFocus)||void 0===o?void 0:o.raw)&&d.current.focus()}),[]);return o(t,{styles:{root:{height:p.height,width:p.width},container:{alignItems:"center"}},checked:l.raw,componentRef:d,inlineLabel:!0,onText:(null===(a=m.find((o=>1===o.Value)))||void 0===a?void 0:a.Label)||"Yes",offText:(null===(s=m.find((o=>0===o.Value)))||void 0===s?void 0:s.Label)||"No",onChange:(o,t)=>(o=>{c({value:o})})(t)})};export{r as TwoOptions};
@@ -1,6 +1 @@
1
- export { useComponent } from './useComponent.js';
2
- import 'react';
3
- import 'fast-deep-equal/es6';
4
- import 'merge-anything';
5
- import 'liquidjs';
6
- import './useComponentSizing.js';
1
+ export{useComponent}from"./useComponent.js";import"react";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"./useComponentSizing.js";
@@ -1,83 +1 @@
1
- import { useRef, useMemo, useEffect } from 'react';
2
- import equal from 'fast-deep-equal/es6';
3
- import { merge } from 'merge-anything';
4
- import { Liquid } from 'liquidjs';
5
- import { useComponentSizing } from './useComponentSizing.js';
6
-
7
- /**
8
- * Provides automatic checking if the given outputs are different from the provided inputs. Use the provided method any time you want
9
- * to notify the framework that you wish to write changes. The hook will notify the framework only if the provided output differs from the current inputs.
10
- */
11
- const useComponent = (name, props, defaultTranslations) => {
12
- const parametersRef = useRef(props.parameters);
13
- const sizing = useComponentSizing(props.context.mode);
14
- const liquid = useMemo(() => new Liquid(), []);
15
- const labels = useMemo(() => {
16
- var _a;
17
- const mergedTranslations = merge(defaultTranslations !== null && defaultTranslations !== void 0 ? defaultTranslations : {}, (_a = props.translations) !== null && _a !== void 0 ? _a : {});
18
- return new Proxy(mergedTranslations, {
19
- get(target, key) {
20
- return (variables) => getLabel(key, mergedTranslations, variables);
21
- }
22
- });
23
- }, []);
24
- useEffect(() => {
25
- parametersRef.current = props.parameters;
26
- }, [props.parameters]);
27
- const getLabel = (key, translations, variables) => {
28
- const strigify = (value) => {
29
- if (typeof value === 'string') {
30
- return value;
31
- }
32
- return JSON.stringify(value);
33
- };
34
- const translation = translations[key];
35
- if (!translation) {
36
- console.error(`Translation for the ${key} label of the ${name} component has not been defined!`);
37
- return key;
38
- }
39
- if (typeof translation === 'string' || Array.isArray(translation)) {
40
- return strigify(translation);
41
- }
42
- let label = translation[props.context.userSettings.languageId];
43
- if (!label) {
44
- console.info(`Translation for the ${key} label of the ${name} component has not been found. Using default Czech label instead.`);
45
- label = translation[1029];
46
- }
47
- if (!label) {
48
- console.error(`Translation for the ${key} label of the ${name} component does not exists neither for Czech language and current LCID.`);
49
- label = key;
50
- }
51
- return liquid.parseAndRenderSync(strigify(label), variables);
52
- };
53
- const onNotifyOutputChanged = (outputs) => {
54
- var _a, _b;
55
- let isDirty = false;
56
- for (let [key, outputValue] of Object.entries(outputs)) {
57
- const parameterValue = (_a = parametersRef.current[key]) === null || _a === void 0 ? void 0 : _a.raw;
58
- if (!equal(parameterValue, outputValue)) {
59
- if (outputValue === "") {
60
- outputValue = null;
61
- }
62
- // handles undefined X null
63
- if (parameterValue == outputValue) {
64
- continue;
65
- }
66
- isDirty = true;
67
- break;
68
- }
69
- }
70
- if (!isDirty) {
71
- return;
72
- }
73
- //console.log(`Change detected, triggering notifyOutputChanged on component ${name}.`);
74
- (_b = props.onNotifyOutputChanged) === null || _b === void 0 ? void 0 : _b.call(props, outputs);
75
- };
76
- return {
77
- labels,
78
- sizing,
79
- onNotifyOutputChanged
80
- };
81
- };
82
-
83
- export { useComponent };
1
+ import{useRef as e,useMemo as n,useEffect as t}from"react";import o from"fast-deep-equal/es6";import{merge as r}from"merge-anything";import{Liquid as a}from"liquidjs";import{useComponentSizing as i}from"./useComponentSizing.js";const s=(s,l,f)=>{const u=e(l.parameters),c=i(l.context.mode),d=n((()=>new a),[]),m=n((()=>{var e;const n=r(null!=f?f:{},null!==(e=l.translations)&&void 0!==e?e:{});return new Proxy(n,{get:(e,t)=>e=>p(t,n,e)})}),[]);t((()=>{u.current=l.parameters}),[l.parameters]);const p=(e,n,t)=>{const o=e=>"string"==typeof e?e:JSON.stringify(e),r=n[e];if(!r)return console.error(`Translation for the ${e} label of the ${s} component has not been defined!`),e;if("string"==typeof r||Array.isArray(r))return o(r);let a=r[l.context.userSettings.languageId];return a||(console.info(`Translation for the ${e} label of the ${s} component has not been found. Using default Czech label instead.`),a=r[1029]),a||(console.error(`Translation for the ${e} label of the ${s} component does not exists neither for Czech language and current LCID.`),a=e),d.parseAndRenderSync(o(a),t)};return{labels:m,sizing:c,onNotifyOutputChanged:e=>{var n,t;let r=!1;for(let[t,a]of Object.entries(e)){const e=null===(n=u.current[t])||void 0===n?void 0:n.raw;if(!o(e,a)){if(""===a&&(a=null),e==a)continue;r=!0;break}}r&&(null===(t=l.onNotifyOutputChanged)||void 0===t||t.call(l,e))}}};export{s as useComponent};
@@ -1,14 +1 @@
1
- const useComponentSizing = (mode) => {
2
- const getAllocationSize = (allocationSize) => {
3
- if (!allocationSize || allocationSize === -1) {
4
- return undefined;
5
- }
6
- return allocationSize;
7
- };
8
- return {
9
- height: getAllocationSize(mode.allocatedHeight),
10
- width: getAllocationSize(mode.allocatedWidth)
11
- };
12
- };
13
-
14
- export { useComponentSizing };
1
+ const t=t=>{const e=t=>{if(t&&-1!==t)return t};return{height:e(t.allocatedHeight),width:e(t.allocatedWidth)}};export{t as useComponentSizing};
@@ -1,24 +1 @@
1
- import { useState, useEffect } from 'react';
2
-
3
- const useFocusIn = (ref) => {
4
- const [isFocused, setIsFocused] = useState(false);
5
- useEffect(() => {
6
- var _a, _b;
7
- const onFocus = () => {
8
- setIsFocused(true);
9
- };
10
- const onBlur = () => {
11
- setIsFocused(false);
12
- };
13
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener('focusin', onFocus);
14
- (_b = ref.current) === null || _b === void 0 ? void 0 : _b.addEventListener('focusout', onBlur);
15
- return () => {
16
- var _a, _b;
17
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('focusin', onFocus);
18
- (_b = ref.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('focusout', onBlur);
19
- };
20
- }, []);
21
- return isFocused;
22
- };
23
-
24
- export { useFocusIn };
1
+ import{useState as e,useEffect as r}from"react";const n=n=>{const[t,o]=e(!1);return r((()=>{var e,r;const t=()=>{o(!0)},u=()=>{o(!1)};return null===(e=n.current)||void 0===e||e.addEventListener("focusin",t),null===(r=n.current)||void 0===r||r.addEventListener("focusout",u),()=>{var e,r;null===(e=n.current)||void 0===e||e.removeEventListener("focusin",t),null===(r=n.current)||void 0===r||r.removeEventListener("focusout",u)}}),[]),t};export{n as useFocusIn};
@@ -1,42 +1 @@
1
- import { useState, useRef, useEffect } from 'react';
2
- import { useComponent } from './useComponent.js';
3
- import 'fast-deep-equal/es6';
4
- import 'merge-anything';
5
- import 'liquidjs';
6
- import './useComponentSizing.js';
7
-
8
- const useInputBasedComponent = (name, props, options) => {
9
- var _a;
10
- const { formatter, valueExtractor } = Object.assign({}, options);
11
- const rawValue = props.parameters.value.raw;
12
- const [value, setValue] = useState((_a = formatter === null || formatter === void 0 ? void 0 : formatter(rawValue)) !== null && _a !== void 0 ? _a : rawValue);
13
- const valueRef = useRef(rawValue);
14
- const { labels, sizing, onNotifyOutputChanged } = useComponent(name, props, options === null || options === void 0 ? void 0 : options.defaultTranslations);
15
- useEffect(() => {
16
- const formattedValue = formatter === null || formatter === void 0 ? void 0 : formatter(rawValue);
17
- setValue(formattedValue !== null && formattedValue !== void 0 ? formattedValue : rawValue);
18
- //console.log(`Updating component ${name} with new value: ${formattedValue ?? rawValue}`);
19
- }, [rawValue]);
20
- useEffect(() => {
21
- valueRef.current = value;
22
- }, [value]);
23
- useEffect(() => {
24
- return () => {
25
- var _a, _b;
26
- if (((_a = props.parameters.NotifyOutputChangedOnUnmount) === null || _a === void 0 ? void 0 : _a.raw) === true) {
27
- onNotifyOutputChanged({
28
- value: (_b = valueExtractor === null || valueExtractor === void 0 ? void 0 : valueExtractor(valueRef.current)) !== null && _b !== void 0 ? _b : valueRef.current
29
- });
30
- }
31
- };
32
- }, []);
33
- return {
34
- value,
35
- labels,
36
- sizing,
37
- onNotifyOutputChanged,
38
- setValue
39
- };
40
- };
41
-
42
- export { useInputBasedComponent };
1
+ import{useState as t,useRef as n,useEffect as e}from"react";import{useComponent as o}from"./useComponent.js";import"fast-deep-equal/es6";import"merge-anything";import"liquidjs";import"./useComponentSizing.js";const r=(r,l,u)=>{var a;const{formatter:i,valueExtractor:s}=Object.assign({},u),m=l.parameters.value.raw,[p,d]=t(null!==(a=null==i?void 0:i(m))&&void 0!==a?a:m),v=n(m),{labels:c,sizing:g,onNotifyOutputChanged:f}=o(r,l,null==u?void 0:u.defaultTranslations);return e((()=>{const t=null==i?void 0:i(m);d(null!=t?t:m)}),[m]),e((()=>{v.current=p}),[p]),e((()=>()=>{var t,n;!0===(null===(t=l.parameters.NotifyOutputChangedOnUnmount)||void 0===t?void 0:t.raw)&&f({value:null!==(n=null==s?void 0:s(v.current))&&void 0!==n?n:v.current})}),[]),{value:p,labels:c,sizing:g,onNotifyOutputChanged:f,setValue:d}};export{r as useInputBasedComponent};
@@ -1,24 +1 @@
1
- import { useState, useEffect } from 'react';
2
-
3
- const useMouseOver = (ref) => {
4
- const [isMouseOver, setIsMouseOver] = useState(false);
5
- useEffect(() => {
6
- var _a, _b;
7
- const onMouseEnter = () => {
8
- setIsMouseOver(true);
9
- };
10
- const onMouseLeave = () => {
11
- setIsMouseOver(false);
12
- };
13
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', onMouseEnter);
14
- (_b = ref.current) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', onMouseLeave);
15
- return () => {
16
- var _a, _b;
17
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', onMouseEnter);
18
- (_b = ref.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', onMouseLeave);
19
- };
20
- }, []);
21
- return isMouseOver;
22
- };
23
-
24
- export { useMouseOver };
1
+ import{useState as e,useEffect as r}from"react";const n=n=>{const[t,o]=e(!1);return r((()=>{var e,r;const t=()=>{o(!0)},u=()=>{o(!1)};return null===(e=n.current)||void 0===e||e.addEventListener("mouseenter",t),null===(r=n.current)||void 0===r||r.addEventListener("mouseleave",u),()=>{var e,r;null===(e=n.current)||void 0===e||e.removeEventListener("mouseenter",t),null===(r=n.current)||void 0===r||r.removeEventListener("mouseleave",u)}}),[]),t};export{n as useMouseOver};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talxis/base-controls",
3
- "version": "1.2406.13",
3
+ "version": "1.2406.15",
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",