import { CarbonInputOptions, CarbonSelectOptions, CarbonChartOptions, CarbonTableOptions, CarbonTextareaOptions, CarbonCheckboxOptions, CarbonRadioOptions, CarbonAccordionOptions, CarbonBreadcrumbOptions, CarbonButtonOptions, CarbonFileUploaderOptions, CarbonStructuredListOptions, CarbonTabsOptions, CarbonObjectArrayOptions } from '@jaspero/modular-components'; /** * MIT License * * Copyright (c) 2016 Richard Adams (https://github.com/enriched) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ interface JSONSchema { $ref?: string; /** * This is important because it tells refs where * the root of the document is located */ id?: string; /** * It is recommended that the meta-schema is * included in the root of any JSON Schema */ $schema?: JSONSchema; /** * Title of the schema */ title?: string; /** * Schema description */ description?: string; /** * Default json for the object represented by * this schema */ 'default'?: any; /** * The value must be a multiple of the number * (e.g. 10 is a multiple of 5) */ multipleOf?: number; maximum?: number; /** * If true maximum must be > value, >= otherwise */ exclusiveMaximum?: boolean; minimum?: number; /** * If true minimum must be < value, <= otherwise */ exclusiveMinimum?: boolean; maxLength?: number; minLength?: number; /** * This is a regex string that the value must * conform to */ pattern?: string; additionalItems?: boolean | JSONSchema; items?: JSONSchema | JSONSchema[]; maxItems?: number; minItems?: number; uniqueItems?: boolean; maxProperties?: number; minProperties?: number; required?: string[]; additionalProperties?: boolean | JSONSchema; /** * Holds simple JSON Schema definitions for * referencing from elsewhere. */ definitions?: { [key: string]: JSONSchema; }; /** * The keys that can exist on the object with the * json schema that should validate their value */ properties?: { [property: string]: JSONSchema; }; /** * The key of this object is a regex for which * properties the schema applies to */ patternProperties?: { [pattern: string]: JSONSchema; }; /** * If the key is present as a property then the * string of properties must also be present. * If the value is a JSON Schema then it must * also be valid for the object if the key is * present. */ dependencies?: { [key: string]: JSONSchema | string[]; }; /** * Enumerates the values that this schema can be * e.g. * {"type": "string", * "enum": ["red", "green", "blue"]} */ 'enum'?: any[]; /** * The basic type of this schema, can be one of * [string, number, object, array, boolean, null] * or an array of the acceptable types */ type?: string | string[]; allOf?: JSONSchema[]; anyOf?: JSONSchema[]; oneOf?: JSONSchema[]; /** * The entity being validated must not match this schema */ not?: JSONSchema; } declare class ModularSchema { private _schema; constructor(schema: JSONSchema); get schema(): JSONSchema; createInstance(value: any): ModularInstance; static fromJSON(value: { [key: string]: any; }): ModularSchema; } declare class ModularInstance { private _schema; private _ajv; constructor(configuration: { schema: ModularSchema; value: any; }); private _value; get value(): any; set value(val: any); update(value: any, options?: { merge?: boolean; }): void; valid(): boolean; } declare enum Components { CarbonInput = "carbon-input", CarbonSelect = "carbon-select", CarbonChart = "carbon-chart", CarbonDatepicker = "carbon-datepicker", CarbonTable = "carbon-table", CarbonTextarea = "carbon-textarea", CarbonCheckbox = "carbon-checkbox", CarbonRadio = "carbon-radio", CarbonSlider = "carbon-slider", CarbonToggle = "carbon-toggle", CarbonAccordion = "carbon-accordion", CarbonBreadcrumb = "carbon-breadcrumb", CarbonButton = "carbon-button", CarbonFileUploader = "carbon-fileuploader", CarbonStructuredList = "carbon-structuredlist", CarbonTabs = "carbon-tabs", CarbonObjectArray = "carbon-object-array", CarbonContentSwitcher = "carbon-contentswitcher" } interface ComponentOptions { [Components.CarbonInput]: CarbonInputOptions; [Components.CarbonSelect]: CarbonSelectOptions; [Components.CarbonChart]: CarbonChartOptions; [Components.CarbonDatepicker]: CarbonDatePicker; [Components.CarbonTable]: CarbonTableOptions; [Components.CarbonTextarea]: CarbonTextareaOptions; [Components.CarbonCheckbox]: CarbonCheckboxOptions; [Components.CarbonRadio]: CarbonRadioOptions; [Components.CarbonAccordion]: CarbonAccordionOptions; [Components.CarbonBreadcrumb]: CarbonBreadcrumbOptions; [Components.CarbonButton]: CarbonButtonOptions; [Components.CarbonFileUploader]: CarbonFileUploaderOptions; [Components.CarbonStructuredList]: CarbonStructuredListOptions; [Components.CarbonTabs]: CarbonTabsOptions; [Components.CarbonObjectArray]: CarbonObjectArrayOptions; } interface ViewInterface { field: string; component: FIELD; options?: OPTIONS[FIELD]; events: { [key: string]: (element: HTMLElement, event: Event) => void; }; columns?: { desktop?: number; tablet?: number; mobile?: number; } | number; hidden?: { /** * Check is only triggered when these fields are changed */ deps: string[]; check: (value: any) => boolean; }; } type View = FIELD extends keyof OPTIONS ? ViewInterface : never; declare function registerComponent(name: string, component: CustomElementConstructor): void; interface ViewRow { align?: 'start' | 'center' | 'end'; container?: string; id?: string; classes?: string[]; items: View[]; } interface ModuleRender { getValue: (elements?: ModuleViewElement[]) => Promise; addEventListener: (event: Events, callback: (value?: any) => void) => void; save: (id?: string, elements?: ModuleViewElement[]) => Promise; removeEventListener: (event: Events, callback: (value?: any) => void) => void; destroy: () => void; setValue: (value: any) => void; validity: { [key: string]: boolean; }; isValid: () => boolean; } interface ModuleViewElement { key?: string; element: HTMLElement; options?: any; optionsCalled: boolean; save?: (id: any, value?: any) => Promise; getValue?: () => any; } type Events = 'change'; declare class ModularView { elements: ModuleViewElement[]; componentPrefix: string; private _schema; private readonly _views; constructor(configuration: { componentPrefix?: string; schema: ModularSchema; views: ViewRow[]; }); setOptions(): void; render(options: { parentElement: HTMLElement; instance: ModularInstance; container?: string; }): ModuleRender; } declare function initializeCSSUtil(): void; declare global { interface Window { modular: { components: { [key: string]: CustomElementConstructor; }; }; } } export { ComponentOptions, Components, JSONSchema, ModularInstance, ModularSchema, ModularView, ModuleRender, ModuleViewElement, View, ViewInterface, ViewRow, initializeCSSUtil, registerComponent };