tycho-components 0.25.1 → 0.25.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.
@@ -49,7 +49,7 @@ export default function AppForm({ fields, form, prefix, onChangeFunctions = {},
49
49
  return (_jsx(CheckboxField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled }, name));
50
50
  }
51
51
  if (field.type === 'switch') {
52
- return (_jsx(SwitchField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled }, name));
52
+ return (_jsx(SwitchField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled, onChange: (value) => handleChange?.(value) }, name));
53
53
  }
54
54
  if (field.type === 'datepicker') {
55
55
  const handleBlur = getOnBlurFn(field.attr);
@@ -17,6 +17,7 @@ export type AppFormField = {
17
17
  disabled?: boolean;
18
18
  options?: SelectItem[];
19
19
  tooltip?: boolean;
20
+ tooltipText?: string;
20
21
  multiple?: boolean;
21
22
  freeSolo?: boolean;
22
23
  minQueryLength?: number;
@@ -0,0 +1,12 @@
1
+ import { UseFormReturn } from 'react-hook-form';
2
+ import { AppFormField } from '../AppForm/AppFormField';
3
+ import './style.scss';
4
+ type Props = {
5
+ fields: AppFormField[];
6
+ form: UseFormReturn<any, any, any>;
7
+ onToggle: (attr: string, value: boolean) => void;
8
+ hasRole?: (role: string) => boolean;
9
+ className?: string;
10
+ };
11
+ export default function AppSwitchGroup({ fields, form, onToggle, hasRole, className, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon, SwitchField, Tooltip } from 'tycho-storybook';
3
+ import FormUtils from '../../functions/FormUtils';
4
+ import './style.scss';
5
+ export default function AppSwitchGroup({ fields, form, onToggle, hasRole = () => true, className, }) {
6
+ const visibleFields = FormUtils.filterFieldsByUserRole(fields, hasRole).filter((field) => field.type === 'switch');
7
+ return (_jsx("div", { className: `app-switch-group-container ${className || ''}`, children: visibleFields.map((field) => (_jsxs("div", { className: "app-switch-group-row", children: [_jsx(SwitchField, { attr: field.attr, label: field.name, createdForm: form, disabled: field.disabled, onChange: (value) => onToggle(field.attr, value) }), field.tooltip && field.tooltipText && (_jsx(Tooltip, { title: field.tooltipText, children: _jsx("span", { className: "app-switch-group-tooltip", children: _jsx(Icon, { name: "help", size: "x-small" }) }) }))] }, field.attr))) }));
8
+ }
@@ -0,0 +1,2 @@
1
+ import AppSwitchGroup from './AppSwitchGroup';
2
+ export default AppSwitchGroup;
@@ -0,0 +1,2 @@
1
+ import AppSwitchGroup from './AppSwitchGroup';
2
+ export default AppSwitchGroup;
@@ -0,0 +1,18 @@
1
+ .app-switch-group-container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--spacing-200);
5
+
6
+ .app-switch-group-row {
7
+ display: flex;
8
+ flex-direction: row;
9
+ align-items: center;
10
+ gap: var(--spacing-100);
11
+ }
12
+
13
+ .app-switch-group-tooltip {
14
+ display: inline-flex;
15
+ cursor: pointer;
16
+ color: var(--icon-secondary);
17
+ }
18
+ }
@@ -12,6 +12,7 @@ export type { FieldOperations, FormField } from './AppEditable/FormField';
12
12
  export { default as AppForm } from './AppForm/AppForm';
13
13
  export { default as AppFormInfo } from './AppForm/AppFormInfo';
14
14
  export type { AppFormField } from './AppForm/AppFormField';
15
+ export { default as AppSwitchGroup } from './AppSwitchGroup';
15
16
  export { convertEnum, convertList } from './AppEditable/FormFieldOption';
16
17
  export type { FormFieldOption } from './AppEditable/FormFieldOption';
17
18
  export { default as AppKeyboard } from './AppKeyboard';
@@ -8,6 +8,7 @@ export { default as AppEditable } from './AppEditable';
8
8
  export { validateFormField } from './AppEditable/FormField';
9
9
  export { default as AppForm } from './AppForm/AppForm';
10
10
  export { default as AppFormInfo } from './AppForm/AppFormInfo';
11
+ export { default as AppSwitchGroup } from './AppSwitchGroup';
11
12
  export { convertEnum, convertList } from './AppEditable/FormFieldOption';
12
13
  export { default as AppKeyboard } from './AppKeyboard';
13
14
  export { default as AppLoading } from './AppLoading';
@@ -10,6 +10,7 @@ export type Corpus = {
10
10
  parameters: Record<string, any>;
11
11
  status: CorpusStatus;
12
12
  opened: boolean;
13
+ featured?: boolean;
13
14
  owner?: User;
14
15
  github?: Github;
15
16
  images?: CorpusImage[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.25.1",
4
+ "version": "0.25.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -82,7 +82,7 @@
82
82
  "react-i18next": "^13.0.2",
83
83
  "react-router-dom": "^6.14.2",
84
84
  "react-toastify": "^9.1.3",
85
- "tycho-storybook": "0.9.2",
85
+ "tycho-storybook": "0.9.4",
86
86
  "wavesurfer-react": "^2.2.2",
87
87
  "wavesurfer.js": "^6.6.3"
88
88
  },