preact#h TypeScript Examples
The following examples show how to use
preact#h.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToolOverlay.tsx From LogicFlow with Apache License 2.0 | 6 votes |
/**
* 外部传入的一般是HTMLElement
*/
getTools() {
const { tool, graphModel } = this.props;
const tools = tool.getTools();
const components = tools.map(item => h(item, {
graphModel,
logicFlow: tool.instance,
}));
tool.components = components;
return components;
}
Example #2
Source File: grid.ts From gridjs with MIT License | 6 votes |
createElement(): VNode {
return h(Container, {
config: this.config,
pipeline: this.config.pipeline,
header: this.config.header,
width: this.config.width,
height: this.config.height,
});
}
Example #3
Source File: plugin.ts From gridjs with MIT License | 6 votes |
render() {
if (this.props.pluginId) {
// render a single plugin
const plugin = this.config.plugin.get(this.props.pluginId);
if (!plugin) return null;
return h(
Fragment,
{},
h(plugin.component, {
plugin: plugin,
...plugin.props,
...this.props.props,
}),
);
} else if (this.props.position !== undefined) {
// render using a specific plugin position
return h(
Fragment,
{},
this.config.plugin
.list(this.props.position)
.map((p) =>
h(p.component, { plugin: p, ...p.props, ...this.props.props }),
),
);
}
return null;
}
Example #4
Source File: snackbar.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #5
Source File: globalStyles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #6
Source File: banner.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #7
Source File: iconAuthors.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #8
Source File: phoneChat.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #9
Source File: segment.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #10
Source File: startAppAnchor.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #11
Source File: startGuide.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #12
Source File: languageSelector.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #13
Source File: loader.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #14
Source File: prompt.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #15
Source File: iconButton.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #16
Source File: optionsPanel.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #17
Source File: optionsPanelConnectCollapsed.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #18
Source File: optionsPanelEntityFormExpanded.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #19
Source File: passwordEntity.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #20
Source File: home.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #21
Source File: passwordList.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #22
Source File: settings.styles.ts From passwords-fountain with MIT License | 5 votes |
setPragma(h);
Example #23
Source File: Router.tsx From help-widget with MIT License | 5 votes |
RouteLink = ({ href, children, ...rest }: h.JSX.HTMLAttributes<HTMLAnchorElement>) => (
<RouterContext.Consumer>
{({ setRoute }) => (
<a href='javascript:' onClick={() => href && setRoute(href)} {...rest}>{children}</a>
)}
</RouterContext.Consumer>
)
Example #24
Source File: InputBase.tsx From adyen-web with MIT License | 5 votes |
export default function InputBase(props) {
const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, isCollatingErrors, disabled } = props;
/**
* To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.
* The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.
*/
if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {
console.error('Error: Form fields that rely on InputBase may not have an onChange property');
}
const handleInput = useCallback(
(event: h.JSX.TargetedEvent<HTMLInputElement>) => {
props.onInput(event);
},
[props.onInput]
);
const handleBlur = useCallback(
(event: h.JSX.TargetedEvent<HTMLInputElement>) => {
props?.onBlurHandler?.(event); // From Field component
if (props.trimOnBlur) {
(event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)
}
props?.onBlur?.(event);
},
[props.onBlur, props.onBlurHandler]
);
const handleFocus = useCallback(
(event: h.JSX.TargetedEvent<HTMLInputElement>) => {
props?.onFocusHandler?.(event); // From Field component
},
[props.onFocusHandler]
);
const inputClassNames = classNames(
'adyen-checkout__input',
[`adyen-checkout__input--${type}`],
props.className,
{
'adyen-checkout__input--invalid': isInvalid,
'adyen-checkout__input--valid': isValid
},
classNameModifiers.map(m => `adyen-checkout__input--${m}`)
);
// Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)
const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, isCollatingErrors: ce, ...newProps } = props;
return (
<input
id={uniqueId}
{...newProps}
type={type}
className={inputClassNames}
readOnly={readonly}
spellCheck={spellCheck}
autoCorrect={autoCorrect}
aria-describedby={isCollatingErrors ? null : `${uniqueId}${ARIA_ERROR_SUFFIX}`}
aria-invalid={isInvalid}
onInput={handleInput}
onBlur={handleBlur}
onFocus={handleFocus}
disabled={disabled}
/>
);
}
Example #25
Source File: markdown.tsx From obsidian-dataview with MIT License | 5 votes |
public constructor(public init: DataviewInit, public element: h.JSX.Element) {
super(init.container);
}
Example #26
Source File: BaseNode.tsx From LogicFlow with Apache License 2.0 | 5 votes |
getAnchorShape(anchorData): h.JSX.Element {
return null;
}
Example #27
Source File: header.ts From gridjs with MIT License | 5 votes |
/**
* Tries to automatically adjust the width of columns based on:
* - Header cell content
* - Cell content of the first row
* - Cell content of the last row
*
* @param config
*/
adjustWidth(config: Config): this {
const container: Element = config.container;
const tableRef: RefObject<Component> = config.tableRef;
const tempRef: RefObject<HTMLDivElement> = config.tempRef;
const autoWidth = config.tempRef || true;
if (!container) {
// we can't calculate the width because the container
// is unknown at this stage
return this;
}
// pixels
const containerWidth = container.clientWidth;
// let's create a shadow table with the first 10 rows of the data
// and let the browser to render the table with table-layout: auto
// no padding, margin or border to get the minimum space required
// to render columns. One the table is rendered and widths are known,
// we unmount the shadow table from the DOM and set the correct width
const shadowTable = createRef();
let widths = {};
if (tableRef.current && autoWidth) {
// render a ShadowTable with the first 10 rows
const el = h(ShadowTable, {
tableRef: tableRef,
});
el.ref = shadowTable;
render(el, tempRef.current);
widths = shadowTable.current.widths();
}
for (const column of flatten(Header.tabularFormat(this.columns))) {
// because we don't want to set the width of parent THs
if (column.columns && column.columns.length > 0) {
continue;
}
if (!column.width && autoWidth) {
// tries to find the corresponding cell
// from the ShadowTable and set the correct width
if (column.id in widths) {
// because a column can be hidden, too
column.width = px(widths[column.id]['width']);
column.minWidth = px(widths[column.id]['minWidth']);
}
} else {
// column width is already defined
// sets the column with based on the width of its container
column.width = px(width(column.width, containerWidth));
}
}
if (tableRef.current && autoWidth) {
// unmount the shadow table from temp
render(null, tempRef.current);
}
return this;
}
Example #28
Source File: html.ts From gridjs with MIT License | 5 votes |
export function html(content: string, parentElement?: string): VNode {
return h(HTMLElement, { content: content, parentElement: parentElement });
}
Example #29
Source File: htmlElement.tsx From gridjs with MIT License | 5 votes |
render() {
return h(this.props.parentElement, {
dangerouslySetInnerHTML: { __html: this.props.content },
});
}