Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commits' author was amended #5

Merged
merged 10 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist
node_modules
types
dist
node_modules
types
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.8.7",
"version": "1.9.0",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
9,132 changes: 2,270 additions & 6,862 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/form-js-carbon-styles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bpmn-io/form-js-carbon-styles",
"version": "1.8.7",
"version": "1.8.8",
"description": "Custom carbon styles for form-js",
"scripts": {
"all": "run-s test",
Expand All @@ -18,7 +18,7 @@
"url": "https://github.com/bpmn-io"
},
"devDependencies": {
"@bpmn-io/form-js-viewer": "^1.8.7",
"@bpmn-io/form-js-viewer": "^1.8.8",
"@carbon/elements": "^11.44.0",
"styled-components": "^6.1.8"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/form-js-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bpmn-io/form-js-editor",
"version": "1.8.7",
"version": "1.9.0",
"description": "Edit forms - powered by bpmn.io",
"exports": {
".": {
Expand Down Expand Up @@ -48,8 +48,8 @@
},
"dependencies": {
"@bpmn-io/draggle": "^4.0.0",
"@bpmn-io/form-js-viewer": "^1.8.7",
"@bpmn-io/properties-panel": "^3.20.0",
"@bpmn-io/form-js-viewer": "^1.8.8",
"@bpmn-io/properties-panel": "^3.20.1",
"array-move": "^3.0.1",
"big.js": "^6.2.1",
"ids": "^1.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { reduce, isArray } from 'min-dash';

import { FormPropertiesPanelContext } from './context';

import { PropertiesPanelHeaderProvider } from './PropertiesPanelHeaderProvider';
import { getPropertiesPanelHeaderProvider } from './PropertiesPanelHeaderProvider';
import { PropertiesPanelPlaceholderProvider } from './PropertiesPanelPlaceholderProvider';

const EMPTY = {};

export function PropertiesPanel(props) {
const { eventBus, getProviders, injector } = props;

const formEditor = injector.get('formEditor');
const modeling = injector.get('modeling');
const selectionModule = injector.get('selection');
const propertiesPanelConfig = injector.get('config.propertiesPanel') || {};
const propertiesPanelConfig = injector.get('config.propertiesPanel') || EMPTY;

const { feelPopupContainer } = propertiesPanelConfig;

Expand Down Expand Up @@ -83,6 +85,17 @@ export function PropertiesPanel(props) {
);
}, [providers, selectedFormField, editField]);

const formFields = getService('formFields');

const PropertiesPanelHeaderProvider = useMemo(
() =>
getPropertiesPanelHeaderProvider({
getDocumentationRef: propertiesPanelConfig.getDocumentationRef,
formFields,
}),
[formFields, propertiesPanelConfig],
);

return (
<div
class="fjs-properties-panel"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,50 @@
import { textToLabel } from './Util';

import { iconsByType } from '../../render/components/icons';

import { getPaletteIcon } from '../palette/components/Palette';

import { useService } from './hooks';

const headerlessTypes = ['spacer', 'separator', 'expression', 'html'];

export const PropertiesPanelHeaderProvider = {
getElementLabel: (field) => {
const { type } = field;

if (headerlessTypes.includes(type)) {
return '';
}

if (type === 'text') {
return textToLabel(field.text);
}

if (type === 'image') {
return field.alt;
}

if (type === 'default') {
return field.id;
}

return field.label;
},

getElementIcon: (field) => {
const { type } = field;

// @Note: We know that we are inside the properties panel context,
// so we can savely use the hook here.
// eslint-disable-next-line react-hooks/rules-of-hooks
const fieldDefinition = useService('formFields').get(type).config;

const Icon = fieldDefinition.icon || iconsByType(type);

if (Icon) {
return () => <Icon width="36" height="36" viewBox="0 0 54 54" />;
} else if (fieldDefinition.iconUrl) {
return getPaletteIcon({ iconUrl: fieldDefinition.iconUrl, label: fieldDefinition.label });
}
},

getTypeLabel: (field) => {
const { type } = field;

if (type === 'default') {
return 'Form';
}

// @Note: We know that we are inside the properties panel context,
// so we can savely use the hook here.
// eslint-disable-next-line react-hooks/rules-of-hooks
const fieldDefinition = useService('formFields').get(type).config;

return fieldDefinition.label || type;
},
};
export function getPropertiesPanelHeaderProvider(options = {}) {
const { getDocumentationRef, formFields } = options;

return {
getElementLabel: (field) => {
const { type } = field;
if (headerlessTypes.includes(type)) {
return '';
}
if (type === 'text') {
return textToLabel(field.text);
}
if (type === 'image') {
return field.alt;
}
if (type === 'default') {
return field.id;
}
return field.label;
},

getElementIcon: (field) => {
const { type } = field;
const fieldDefinition = formFields.get(type).config;
const Icon = fieldDefinition.icon || iconsByType(type);
if (Icon) {
return () => <Icon width="36" height="36" viewBox="0 0 54 54" />;
} else if (fieldDefinition.iconUrl) {
return getPaletteIcon({ iconUrl: fieldDefinition.iconUrl, label: fieldDefinition.label });
}
},

getTypeLabel: (field) => {
const { type } = field;
if (type === 'default') {
return 'Form';
}
const fieldDefinition = formFields.get(type).config;
return fieldDefinition.label || type;
},

getDocumentationRef,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TableHeaderGroups,
LayoutGroup,
SecurityAttributesGroup,
StyleGroup,
} from './groups';

import { hasEntryConfigured } from './Util';
Expand Down Expand Up @@ -51,12 +52,13 @@ export class PropertiesProvider {
if (!field) {
return groups;
}

const getService = (type, strict = true) => this._injector.get(type, strict);

groups = [
...groups,
GeneralGroup(field, editField, getService),
StyleGroup(field, editField),
...OptionsGroups(field, editField, getService),
...TableHeaderGroups(field, editField),
SecurityAttributesGroup(field, editField),
Expand All @@ -69,9 +71,10 @@ export class PropertiesProvider {
CustomPropertiesGroup(field, editField),
].filter((group) => group != null);


this._filterVisibleEntries(groups, field, getService);

// contract: if a group has no entries or items, it should not be displayed at all

return groups.filter((group) => {
return group.items || (group.entries && group.entries.length);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { get } from 'min-dash';
import { useService } from '../hooks';
import { SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel';
import { useDirection } from '../../../../../form-js-viewer/src/render/context/DirectionContext';

export function DirectionEntry(props) {
const { editField, field } = props;

const entries = [
{
id: 'direction',
component: Direction,
editField,
field,
isEdited: isSelectEntryEdited,
isDefaultVisible: (field) => field.type === 'default',
},
];

return entries;
}

function Direction(props) {
const { editField, field, id } = props;
const { setDirection } = useDirection(); // Get the context

const debounce = useService('debounce');

const path = ['direction'];

const getValue = () => {
const value = get(field, path, 'ltr');
return value;
};

const setValue = (value) => {
setDirection(value); // Update context
return editField(field, path, value || 'ltr');
};

const getOptions = () => [
{
label: 'Left to Right',
value: 'ltr',
},
{
label: 'Right to Left',
value: 'rtl',
},
];

return SelectEntry({
debounce,
element: field,
getValue,
id: 'direction',
label: 'Direction',
setValue,
getOptions,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export { RowCountEntry } from './RowCountEntry';
export { HeadersSourceSelectEntry } from './HeadersSourceSelectEntry';
export { ColumnsExpressionEntry } from './ColumnsExpressionEntry';
export { StaticColumnsSourceEntry } from './StaticColumnsSourceEntry';
export { DirectionEntry } from './DirectionEntry';
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DirectionEntry } from '../entries/DirectionEntry';

export function StyleGroup(field, editField, getService) {
const entries = [...DirectionEntry({ field, editField, getService })];

if (entries.length === 0) {
return null;
}

return {
id: 'style',
label: 'Style',
entries,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export { LayoutGroup } from './LayoutGroup';
export { SecurityAttributesGroup } from './SecurityAttributesGroup';
export { ConditionGroup } from './ConditionGroup';
export { TableHeaderGroups } from './TableHeaderGroups';
export { StyleGroup } from './StyleGroup';

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cleanup, render } from '@testing-library/preact/pure';

import { FormFields } from '@bpmn-io/form-js-viewer';

import { PropertiesPanelHeaderProvider } from '../../../../src/features/properties-panel/PropertiesPanelHeaderProvider';
import { getPropertiesPanelHeaderProvider } from '../../../../src/features/properties-panel/PropertiesPanelHeaderProvider';

import { MockPropertiesPanelContext, TestPropertiesPanel } from './helper';

Expand Down Expand Up @@ -50,6 +50,22 @@ describe('PropertiesPanelHeaderProvider', function () {
expect(label.innerText).to.eql(field.label);
});

it('should render documentation link', function () {
// given
const field = { type: 'textfield' };

const getDocumentationRef = () => 'https://example.com/';

// when
const { container } = renderHeader({ field, getDocumentationRef });

// then
const documentationLink = container.querySelector('.bio-properties-panel-header-link');

expect(documentationLink).to.exist;
expect(documentationLink.href).to.eql(getDocumentationRef());
});

describe('extension support', function () {
it('should render type label from config', function () {
// given
Expand Down Expand Up @@ -130,7 +146,7 @@ describe('PropertiesPanelHeaderProvider', function () {

// helpers /////////

function renderHeader({ services, ...restOptions }) {
function renderHeader({ services = {}, getDocumentationRef, ...restOptions }) {
const defaultField = { type: 'textfield' };

const options = {
Expand All @@ -140,7 +156,13 @@ function renderHeader({ services, ...restOptions }) {

return render(
<MockPropertiesPanelContext options={options} services={services}>
<TestPropertiesPanel field={options.field} headerProvider={PropertiesPanelHeaderProvider} />
<TestPropertiesPanel
field={options.field}
headerProvider={getPropertiesPanelHeaderProvider({
formFields: services.formFields || new FormFields(),
getDocumentationRef,
})}
/>
</MockPropertiesPanelContext>,
);
}
4 changes: 2 additions & 2 deletions packages/form-js-integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bpmn-io/form-js-integration",
"version": "1.8.7",
"version": "1.9.0",
"description": "A set of form-js integration testing resources",
"private": true,
"scripts": {
Expand All @@ -17,6 +17,6 @@
"url": "https://github.com/bpmn-io"
},
"dependencies": {
"@bpmn-io/form-js": "^1.8.7"
"@bpmn-io/form-js": "^1.9.0"
}
}
Loading
Loading