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

Feat: Give all widgets the name parameter #2350 #2408

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
26,046 changes: 9,438 additions & 16,608 deletions ui/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"jest-canvas-mock": "^2.2.0",
"jest-environment-jsdom": "^29.6.4",
"jest-resolve": "^29.6.4",
"jest-watch-typeahead": "0.4.2",
"jest-watch-typeahead": "^2.2.2",
"react-app-polyfill": "^1.0.6",
"react-test-renderer": "^17.0.2",
"sass": "^1.49.7",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ interface State {
content?: S
/** Collection of small buttons rendered under the title. */
items?: Component[]
/** An identifying name for this component */
name?: S
}

export const View = bond(({ name, state, changed }: Model<State>) => {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/audio_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface AudioAnnotatorItem {
end: F
/** The `name` of the audio annotator tag to refer to for the `label` and `color` of this item. */
tag: S
/** An identifying name for this component */
name?: S
}

/**
Expand Down
2 changes: 2 additions & 0 deletions ui/src/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ interface Breadcrumb {
interface State {
/** A list of `h2o_wave.types.Breadcrumb` instances to display. See `h2o_wave.ui.breadcrumb()` */
items: Breadcrumb[]
/** An optional name for this card. */
name?: Id
}

const
Expand Down
2 changes: 2 additions & 0 deletions ui/src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export interface MiniButtons {
items: Component[]
/** True if the component should be visible. Defaults to True. */
visible?: B
/** An identifying name for this component. */
name?: S
}

/** Create a mini button - same as regular button, but smaller in size. */
Expand Down
1 change: 0 additions & 1 deletion ui/src/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,3 @@ export const
})

cards.register('canvas', View)

2 changes: 1 addition & 1 deletion ui/src/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ export const
return { render, init: scroll, update: scroll, changed }
})

cards.register('chat', View)
cards.register('chat', View)
2 changes: 2 additions & 0 deletions ui/src/chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ interface ChatbotMessage {
content: S
/* True if the message is from the user. */
from_user: B
/** an optional identifying name for this component.*/
name?: S
}

/** Create a chat prompt suggestion displayed as button below the last response in the chatbot component. */
Expand Down
111 changes: 0 additions & 111 deletions ui/src/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,116 +60,5 @@ export const cardDefs: CardDef[] = [
"value": {}
}
]
},
{
"view": "chat",
"icon": "OfficeChat",
"attrs": [
{
"name": "box",
"optional": false,
"t": "box",
"value": "{\"zone\":\"Body\"}"
},
{
"name": "title",
"optional": false,
"t": "textbox",
"value": "Untitled Chat"
},
{
"name": "data",
"optional": false,
"t": "record",
"value": {}
},
{
"name": "capacity",
"optional": true,
"t": "spinbox",
"value": 50,
"min": 10,
"max": 10000,
"step": 10
}
]
},
{
"view": "frame",
"icon": "PageAdd",
"attrs": [
{
"name": "box",
"optional": false,
"t": "box",
"value": "{\"zone\":\"Body\"}"
},
{
"name": "title",
"optional": false,
"t": "textbox",
"value": "Untitled Frame"
},
{
"name": "path",
"optional": true,
"t": "textbox",
"value": ""
},
{
"name": "content",
"optional": true,
"t": "textarea",
"value": ""
}
]
},
{
"view": "markdown",
"icon": "InsertTextBox",
"attrs": [
{
"name": "box",
"optional": false,
"t": "box",
"value": "{\"zone\":\"Body\"}"
},
{
"name": "title",
"optional": false,
"t": "textbox",
"value": "Untitled Content"
},
{
"name": "content",
"optional": false,
"t": "textarea",
"value": "Hello, World!"
}
]
},
{
"view": "markup",
"icon": "FileHTML",
"attrs": [
{
"name": "box",
"optional": false,
"t": "box",
"value": "{\"zone\":\"Body\"}"
},
{
"name": "title",
"optional": false,
"t": "textbox",
"value": "Untitled Content"
},
{
"name": "content",
"optional": false,
"t": "textarea",
"value": "<div/>"
}
]
}
]
2 changes: 1 addition & 1 deletion ui/src/flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ export const
return { render, changed }
})

cards.register('flex', View)
cards.register('flex', View)
2 changes: 2 additions & 0 deletions ui/src/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ interface State {
caption: S
/** The components displayed to the right of the caption. */
items?: Component[]
/** An optional identifying name to the card */
name?: S
}

export const
Expand Down
2 changes: 2 additions & 0 deletions ui/src/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ interface State {
items: Packed<Component[]>
/** The title for this card. */
title?: S
/** An optional name for this form. */
name?: S
}

const
Expand Down
4 changes: 4 additions & 0 deletions ui/src/frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ interface State {
* True if title and padding should be removed. Defaults to False.
*/
compact?: B
/**
* An optional identifying name for this component.
*/
name?: S
}

const
Expand Down
3 changes: 2 additions & 1 deletion ui/src/graphics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ interface State {
* Required only if `image` is set.
*/
image_type?: S
/** An optional identifying name for this Card. */
name?: S
}

const
Expand Down Expand Up @@ -210,4 +212,3 @@ export const

cards.register('graphics', View)


2 changes: 2 additions & 0 deletions ui/src/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ interface State {
secondary_items?: Component[]
/** Header background color. Defaults to 'primary'. */
color?: 'card' | 'transparent' | 'primary'
/** An optional name for this component. */
name?: S
}

const
Expand Down
4 changes: 4 additions & 0 deletions ui/src/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ interface State {
path?: S
/** The path or URL or data URL of the image displayed in the popup after clicking the image. Does not replace the `path` property. */
path_popup?: S
/** An optional identifying name for the image */
name?: S
}


Expand All @@ -67,6 +69,8 @@ export interface Image {
visible?: B
/** The path or URL or data URL of the image displayed in the popup after clicking the image. Does not replace the `path` property. */
path_popup?: S
/** An optional identifying name for this component. */
name?: S
}

export const
Expand Down
8 changes: 8 additions & 0 deletions ui/src/image_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ export interface ImageAnnotatorPoint {
x: F
/** `y` coordinate of the point. */
y: F
/** An optional name for this component. */
name?: S
}

/** Create a polygon annotation shape. */
export interface ImageAnnotatorPolygon {
/** List of polygon points. */
vertices: ImageAnnotatorPoint[]
/** An optional name for this component. */
name?: S
}

/** Create a rectangular annotation shape. */
Expand All @@ -32,6 +36,8 @@ export interface ImageAnnotatorRect {
x2: F
/** `y` coordinate of the diagonally opposite corner. */
y2: F
/** An optional name for this component. */
name?: S
}

/** Create a shape to be rendered as an annotation on an image annotator. */
Expand All @@ -56,6 +62,8 @@ interface ImageAnnotatorItem {
shape: ImageAnnotatorShape
/** The `name` of the image annotator tag to refer to for the `label` and `color` of this item. */
tag: S
/** An optional name for this component. */
name?: S
}

/**
Expand Down
2 changes: 2 additions & 0 deletions ui/src/large_bar_stat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ interface State {
plot_color?: S
/** Data for this card. */
data?: Rec
/** An optional identifying name for this group. */
name?: S
}

export const
Expand Down
2 changes: 2 additions & 0 deletions ui/src/large_stat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ interface State {
caption: S
/** Data for this card. */
data?: Rec
/** An optional identifying name for this card. */
name?: S
}

export const
Expand Down
2 changes: 2 additions & 0 deletions ui/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export interface Links {
inline?: B
/** The width of the links, e.g. '100px'. */
width?: S
/** An identifying name for this component. */
name?: S
}
export const forceFileDownload = (path: S) => {
const anchor = document.createElement('a')
Expand Down
2 changes: 2 additions & 0 deletions ui/src/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ interface State {
* Make spacing tighter. Defaults to True.
**/
compact?: B
/** An optional identifying name for this component. */
name?: S
}

export const
Expand Down
2 changes: 2 additions & 0 deletions ui/src/markup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ interface State {
* True if outer spacing should be removed. Defaults to False.
**/
compact?: B
/** An optional identifying name for this component. */
name?: S
}

export const
Expand Down
6 changes: 6 additions & 0 deletions ui/src/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ interface InlineStylesheet {
content: S
/** A valid media query to set conditions for when the style should be applied. More info at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#attr-media. */
media?: S
/** An optional identifying name for this stylesheet. */
name?: S
}

/**
Expand All @@ -48,6 +50,8 @@ interface Stylesheet {
media?: S
/** The CORS setting. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-crossorigin */
cross_origin?: S
/** An optional identifying name for this stylesheet. */
name?: S
}
/**
* Represents the layout structure for a page.
Expand Down Expand Up @@ -162,6 +166,8 @@ interface State {
stylesheet?: InlineStylesheet
/** External CSS files to load into the page. */
stylesheets?: Stylesheet[]
/** An Optional identifying name for this page */
name?: S
/** EXPERIMENTAL: True to turn on the card animations. Defaults to False. */
animate?: B
}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export interface State {
secondary_items?: Component[]
/** Card background color. Defaults to 'card'. */
color?: 'card' | 'primary'
/** An optional name for this card. */
name?: S
}

const
Expand Down
2 changes: 1 addition & 1 deletion ui/src/parts/lightbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const
iconPressed: { color: 'rgba(255, 255, 255, 0.7)' },
}

type Image = { title: S, description?: S, type?: S, image?: S, path?: S }
type Image = { title: S, description?: S, type?: S, image?: S, path?: S, name?: S }

export interface LightboxProps {
images: Image[],
Expand Down
1 change: 1 addition & 0 deletions ui/src/parts/microarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { stylesheet } from 'typestyle'
import { debounce } from '../ui'

interface Props {
name?: S
data: any[]
zeroValue?: F
value: S
Expand Down
Loading