@badrap/libapp
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -5,105 +5,102 @@ type Json = number | string | boolean | null | Json[] | { | ||
type ClassList = string | Record<string, boolean> | ClassList[]; | ||
declare namespace ui { | ||
export type UiNode = null | boolean | string | UiNode[] | { | ||
type: string; | ||
props?: Record<string, unknown>; | ||
children?: UiNode; | ||
}; | ||
type FC<P extends Record<string, unknown> = {}> = (props: P) => UiNode; | ||
export function jsx<T extends FC | keyof JSX.IntrinsicElements>(type: T, props: Record<string, unknown>): UiNode; | ||
export const jsxs: typeof jsx; | ||
export function Fragment(props: { | ||
children: UiNode; | ||
}): UiNode; | ||
export namespace JSX { | ||
interface ElementAttributesProperty { | ||
props: unknown; | ||
} | ||
interface ElementChildrenAttribute { | ||
children: unknown; | ||
} | ||
type Element = UiNode; | ||
interface IntrinsicElements { | ||
["ui-box"]: { | ||
class?: ClassList; | ||
children?: UiNode; | ||
}; | ||
["ui-form"]: { | ||
children?: UiNode; | ||
}; | ||
["ui-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
action?: Json; | ||
submit?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-upload-button"]: { | ||
name: string; | ||
size?: "sm" | "md"; | ||
action: Json; | ||
disabled?: boolean; | ||
multiple?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-download-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
filename?: string; | ||
context?: Json; | ||
children?: UiNode; | ||
}; | ||
["ui-copy-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
value: string; | ||
children?: UiNode; | ||
}; | ||
["ui-text-field"]: { | ||
name: string; | ||
type?: "text" | "email" | "number" | "password" | "multiline"; | ||
disabled?: boolean; | ||
value?: string; | ||
label?: string; | ||
required?: boolean; | ||
placeholder?: string; | ||
}; | ||
["ui-hidden-input"]: { | ||
name: string; | ||
value?: Json; | ||
valid: boolean; | ||
}; | ||
["ui-checkbox"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-switch"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-link"]: { | ||
href: string; | ||
children?: UiNode; | ||
}; | ||
["ui-redirect"]: { | ||
to: string; | ||
}; | ||
["ui-alert"]: { | ||
type?: "info" | "success" | "warning" | "error"; | ||
title?: string; | ||
children?: UiNode; | ||
}; | ||
} | ||
export type UiNode = null | boolean | string | UiNode[] | { | ||
type: string; | ||
props?: Record<string, unknown>; | ||
children?: UiNode; | ||
}; | ||
type FunctionalComponent<P extends Record<string, unknown> = {}> = (props: P) => UiNode; | ||
export declare function jsx<T extends FunctionalComponent | keyof JSX.IntrinsicElements>(type: T, props: Record<string, unknown>): UiNode; | ||
export declare const jsxs: typeof jsx; | ||
export declare function Fragment(props: { | ||
children: UiNode; | ||
}): UiNode; | ||
export declare namespace JSX { | ||
interface ElementAttributesProperty { | ||
props: unknown; | ||
} | ||
export {}; | ||
interface ElementChildrenAttribute { | ||
children: unknown; | ||
} | ||
type Element = UiNode; | ||
interface IntrinsicElements { | ||
["ui-box"]: { | ||
class?: ClassList; | ||
children?: UiNode; | ||
}; | ||
["ui-form"]: { | ||
children?: UiNode; | ||
}; | ||
["ui-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
action?: Json; | ||
submit?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-upload-button"]: { | ||
name: string; | ||
size?: "sm" | "md"; | ||
action: Json; | ||
disabled?: boolean; | ||
multiple?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-download-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
filename?: string; | ||
context?: Json; | ||
children?: UiNode; | ||
}; | ||
["ui-copy-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
value: string; | ||
children?: UiNode; | ||
}; | ||
["ui-text-field"]: { | ||
name: string; | ||
type?: "text" | "email" | "number" | "password" | "multiline"; | ||
disabled?: boolean; | ||
value?: string; | ||
label?: string; | ||
required?: boolean; | ||
placeholder?: string; | ||
}; | ||
["ui-hidden-input"]: { | ||
name: string; | ||
value?: Json; | ||
valid: boolean; | ||
}; | ||
["ui-checkbox"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-switch"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-link"]: { | ||
href: string; | ||
children?: UiNode; | ||
}; | ||
["ui-redirect"]: { | ||
to: string; | ||
}; | ||
["ui-alert"]: { | ||
type?: "info" | "success" | "warning" | "error"; | ||
title?: string; | ||
children?: UiNode; | ||
}; | ||
} | ||
} | ||
export = ui; | ||
export {}; |
"use strict"; | ||
var ui; | ||
(function (ui) { | ||
function jsx(type, props) { | ||
if (typeof type === "string") { | ||
const { children, ...rest } = props; | ||
return { | ||
type: type, | ||
props: Object.keys(rest).length === 0 ? undefined : rest, | ||
children: Array.isArray(children) | ||
? children | ||
: children == null | ||
? undefined | ||
: [children], | ||
}; | ||
} | ||
return type(props); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Fragment = exports.jsxs = exports.jsx = void 0; | ||
function jsx(type, props) { | ||
if (typeof type === "string") { | ||
const { children, ...rest } = props; | ||
return { | ||
type: type, | ||
props: Object.keys(rest).length === 0 ? undefined : rest, | ||
children: Array.isArray(children) | ||
? children | ||
: children == null | ||
? undefined | ||
: [children], | ||
}; | ||
} | ||
ui.jsx = jsx; | ||
ui.jsxs = jsx; | ||
function Fragment(props) { | ||
return props.children; | ||
} | ||
ui.Fragment = Fragment; | ||
})(ui || (ui = {})); | ||
module.exports = ui; | ||
return type(props); | ||
} | ||
exports.jsx = jsx; | ||
exports.jsxs = jsx; | ||
function Fragment(props) { | ||
return props.children; | ||
} | ||
exports.Fragment = Fragment; | ||
//# sourceMappingURL=jsx-runtime.js.map |
{ | ||
"name": "@badrap/libapp", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "TypeScript helpers for creating Badrap apps", | ||
@@ -16,3 +16,4 @@ "repository": { | ||
"./ui": "./dist/ui/index.js", | ||
"./ui/jsx-runtime": "./dist/ui/jsx-runtime.js" | ||
"./ui/jsx-runtime": "./dist/ui/jsx-runtime.js", | ||
"./ui/jsx-dev-runtime": "./dist/ui/jsx-runtime.js" | ||
}, | ||
@@ -19,0 +20,0 @@ "typesVersions": { |
@@ -1,2 +0,1 @@ | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
type Json = | ||
@@ -9,135 +8,135 @@ | number | ||
| { [K: string]: Json | undefined }; | ||
type ClassList = string | Record<string, boolean> | ClassList[]; | ||
namespace ui { | ||
export type UiNode = | ||
| null | ||
| boolean | ||
| string | ||
| UiNode[] | ||
| { | ||
type: string; | ||
props?: Record<string, unknown>; | ||
children?: UiNode; | ||
}; | ||
export type UiNode = | ||
| null | ||
| boolean | ||
| string | ||
| UiNode[] | ||
| { | ||
type: string; | ||
props?: Record<string, unknown>; | ||
children?: UiNode; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
type FC<P extends Record<string, unknown> = {}> = (props: P) => UiNode; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
type FunctionalComponent<P extends Record<string, unknown> = {}> = ( | ||
props: P, | ||
) => UiNode; | ||
export function jsx<T extends FC | keyof JSX.IntrinsicElements>( | ||
type: T, | ||
props: Record<string, unknown>, | ||
): UiNode { | ||
if (typeof type === "string") { | ||
const { children, ...rest } = props; | ||
return { | ||
type: type as string, | ||
props: Object.keys(rest).length === 0 ? undefined : rest, | ||
children: Array.isArray(children) | ||
? children | ||
: children == null | ||
? undefined | ||
: [children], | ||
}; | ||
} | ||
return (type as FC)(props); | ||
export function jsx< | ||
T extends FunctionalComponent | keyof JSX.IntrinsicElements, | ||
>(type: T, props: Record<string, unknown>): UiNode { | ||
if (typeof type === "string") { | ||
const { children, ...rest } = props; | ||
return { | ||
type: type as string, | ||
props: Object.keys(rest).length === 0 ? undefined : rest, | ||
children: Array.isArray(children) | ||
? children | ||
: children == null | ||
? undefined | ||
: [children], | ||
}; | ||
} | ||
export const jsxs = jsx; | ||
return (type as FunctionalComponent)(props); | ||
} | ||
export function Fragment(props: { children: UiNode }): UiNode { | ||
return props.children; | ||
} | ||
export const jsxs = jsx; | ||
export namespace JSX { | ||
export interface ElementAttributesProperty { | ||
props: unknown; | ||
} | ||
export interface ElementChildrenAttribute { | ||
children: unknown; | ||
} | ||
export type Element = UiNode; | ||
export function Fragment(props: { children: UiNode }): UiNode { | ||
return props.children; | ||
} | ||
export interface IntrinsicElements { | ||
["ui-box"]: { | ||
class?: ClassList; | ||
children?: UiNode; | ||
}; | ||
["ui-form"]: { | ||
children?: UiNode; | ||
}; | ||
["ui-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
action?: Json; | ||
submit?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-upload-button"]: { | ||
name: string; | ||
size?: "sm" | "md"; | ||
action: Json; | ||
disabled?: boolean; | ||
multiple?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-download-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
filename?: string; | ||
context?: Json; | ||
children?: UiNode; | ||
}; | ||
["ui-copy-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
value: string; | ||
children?: UiNode; | ||
}; | ||
["ui-text-field"]: { | ||
name: string; | ||
type?: "text" | "email" | "number" | "password" | "multiline"; | ||
disabled?: boolean; | ||
value?: string; | ||
label?: string; | ||
required?: boolean; | ||
placeholder?: string; | ||
}; | ||
["ui-hidden-input"]: { | ||
name: string; | ||
value?: Json; | ||
valid: boolean; | ||
}; | ||
["ui-checkbox"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-switch"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-link"]: { | ||
href: string; | ||
children?: UiNode; | ||
}; | ||
["ui-redirect"]: { | ||
to: string; | ||
}; | ||
["ui-alert"]: { | ||
type?: "info" | "success" | "warning" | "error"; | ||
title?: string; | ||
children?: UiNode; | ||
}; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
export namespace JSX { | ||
export interface ElementAttributesProperty { | ||
props: unknown; | ||
} | ||
export interface ElementChildrenAttribute { | ||
children: unknown; | ||
} | ||
export type Element = UiNode; | ||
export interface IntrinsicElements { | ||
["ui-box"]: { | ||
class?: ClassList; | ||
children?: UiNode; | ||
}; | ||
["ui-form"]: { | ||
children?: UiNode; | ||
}; | ||
["ui-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
action?: Json; | ||
submit?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-upload-button"]: { | ||
name: string; | ||
size?: "sm" | "md"; | ||
action: Json; | ||
disabled?: boolean; | ||
multiple?: boolean; | ||
children?: UiNode; | ||
}; | ||
["ui-download-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
filename?: string; | ||
context?: Json; | ||
children?: UiNode; | ||
}; | ||
["ui-copy-button"]: { | ||
variant?: "default" | "primary" | "danger"; | ||
size?: "sm" | "md"; | ||
disabled?: boolean; | ||
value: string; | ||
children?: UiNode; | ||
}; | ||
["ui-text-field"]: { | ||
name: string; | ||
type?: "text" | "email" | "number" | "password" | "multiline"; | ||
disabled?: boolean; | ||
value?: string; | ||
label?: string; | ||
required?: boolean; | ||
placeholder?: string; | ||
}; | ||
["ui-hidden-input"]: { | ||
name: string; | ||
value?: Json; | ||
valid: boolean; | ||
}; | ||
["ui-checkbox"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-switch"]: { | ||
name?: string; | ||
label?: string; | ||
action?: Json; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
}; | ||
["ui-link"]: { | ||
href: string; | ||
children?: UiNode; | ||
}; | ||
["ui-redirect"]: { | ||
to: string; | ||
}; | ||
["ui-alert"]: { | ||
type?: "info" | "success" | "warning" | "error"; | ||
title?: string; | ||
children?: UiNode; | ||
}; | ||
} | ||
} | ||
export = ui; |
Sorry, the diff of this file is not supported yet
63720
38
1463