Skip to content

Commit

Permalink
- add a way to pilot if collapsible is managed or not
Browse files Browse the repository at this point in the history
- storybook example
  • Loading branch information
sgendre committed Oct 24, 2023
1 parent fe77487 commit 552b728
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export function defaultTitle(formData, schema, options) {
* @param {function} title the function called by the component to compute the title
* @return {function} CollapsibleFieldset react component
*/
export default function createCollapsibleFieldset(title = defaultTitle) {
// eslint-disable-next-line @typescript-eslint/default-param-last
export default function createCollapsibleFieldset(title = defaultTitle, managed) {
function CollapsibleFieldset(props) {
function toggle(event) {

Check warning on line 77 in packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js#L77

[@typescript-eslint/no-unused-vars] 'event' is defined but never used.
// event.stopPropagation();
Expand All @@ -98,7 +99,7 @@ export default function createCollapsibleFieldset(title = defaultTitle) {
onToggleExpanded={toggle}
onToggle={toggle}
index={index}
managed
managed={!!managed}
expanded={!value.isClosed}
action={
actions?.[0] && {
Expand Down Expand Up @@ -143,6 +144,7 @@ export default function createCollapsibleFieldset(title = defaultTitle) {
}).isRequired,
value: PropTypes.object,
actions: PropTypes.array,
managed: PropTypes.bool,
};
}

Expand Down
10 changes: 10 additions & 0 deletions packages/forms/stories/SchemaFieldsets.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ export const CoreCollapsibleFieldset = {
data: fieldsets.coreCollapsibleFieldset,
},
};
export const CoreArraysCollapsibleFieldset = {
parameters: {
formStoryDisplayMode: {
doc: 'ArraysCollapsibleFieldset/README.md',
},
},
args: {
data: fieldsets.coreArraysCollapsibleFieldset,
},
};
export const CoreColumns = {
parameters: {
formStoryDisplayMode: {
Expand Down
88 changes: 88 additions & 0 deletions packages/forms/stories/json/fieldsets/core-arrays-collapsible.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"jsonSchema": {
"type": "object",
"title": "Comment",
"required": ["comments"],
"properties": {
"groupBy": {
"type": "array",
"minItems": 1,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
"fieldName": {
"type": "string",
"enum": ["First Field", "Second Field", "Third Field"]
}
}
}
},
"operations": {
"type": "array",
"minItems": 1,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
"fieldName": {
"type": "string",
"enum": ["First Field", "Second Field", "Third Field"]
},
"operation": {
"type": "string",
"enum": ["First Operation", "Second Operation", "Third Operation"]
}
}
}
}
}
},
"uiSchema": [
{
"key": "operations",
"title": "Operations",
"itemWidget": "collapsibleFieldset",
"items": [
{
"key": "operations[].fieldName",
"title": "Field"
},
{
"key": "operations[].operation",
"title": "Operation"
}
]
},
{
"key": "groupBy",
"title": "Group by",
"items": [
{
"key": "groupBy[].fieldName",
"title": "Field"
}
]
}
],
"properties": {
"groupBy": [
{
"fieldName": "First Field"
},
{
"fieldName": "Second Field"
}
],
"operations": [
{
"fieldName": "First Field",
"operation": "First Operation"
},
{
"fieldName": "Second Field",
"operation": "First Operation"
}
]
}
}
1 change: 1 addition & 0 deletions packages/forms/stories/json/fieldsets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { default as coreArraysComplex } from './core-arrays-complex.json';
export { default as coreArraysWithCustomOptions } from './core-arrays-with-custom-options.json';
export { default as coreArrays } from './core-arrays.json';
export { default as coreCollapsibleFieldset } from './core-collapsibleFieldset.json';
export { default as coreArraysCollapsibleFieldset } from './core-arrays-collapsible.json';
export { default as coreColumns } from './core-columns.json';
export { default as coreFieldset } from './core-fieldset.json';
export { default as coreTabs } from './core-tabs.json';

0 comments on commit 552b728

Please sign in to comment.