Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
web-ui-pack
Advanced tools
Universal web package with high scalable WebComponents and helpers with focus on DX (developer experience)
You can see demo here or just clone repo and run npm i & npm start
Template repo with React: webpack-must-have
wupdark
(<body wupdark>
) and define main background & text colors.jsx/.tsx
support (for React/Preact)window.__wupln
(details you can find in your editor during the coding via built-in intellisense)It's developed with Typescript and has huge built-in documentation (JSDoc). Every method,property,event and even local variables are documented well so you don't need extra resource to take an example to implement or configure elements. In build-result without comments you will see that it's small-enough
Install with npm npm install web-ui-pack
Add import { WUPPopupElement } from "web-ui-pack";
into any file (main.js
for example)
Call WUPPopupElement.$use()
to register HTML tag into web-browser
For usage with React see CODESTYLE.md (for other frameworks it's very similar)
For usage with HTML + VSCode extend VSCode settings (For WebStorm it works out of box - without extra config)
// .vscode/settings.json
{
// ...
"html.customData": ["node_modules/web-ui-pack/types.html.json"]
}
Type <wup w-
to see suggestions (if it doesn't work reload VSCode). More details below
HTMLElement
BaseElement
BaseModal
BaseControl
multiple
MediaPlayer (Video player)
InfiniteScroll
VirtualScroll
CarouselElement (Slide show)
TableElement
Common rules:
WUP..Element
, WUP..Control
and has <wup-...>
html-tags$...
(events $onOpen
, $onClose
, methods $open()
, $close()
, props like $isOpened
etc.)$defaults
(common options for current class) and personal $options
(per each component). See details in example$options
are observed. So changing options affects on component immediately after empty timeout (every component has static observedOptions
as set of watched options)attributes
updates $options
automatically. So document.querySelector('wup-spin').$options.inline
equal to <wup-spin inline />
web-ui-pack
directly (due to tree-shaking can be not smart enough). Instead use web-ui-pack/path-to-element
exclude: /node_modules\/(?!(web-ui-pack)\/).*/
for babel-loader)jsx/tsx
instead of className
use class
attribute (React issue)$options
, but if you change some option it removes related attribute (for performance reasons). Better to avoid usage attributes at allgot...
(gotReady, gotRemoved)More details you can find in CODESTYLE.md and FAQ
Typescript
import WUPPopupElement, { PopupOpenCases } from "web-ui-pack/popup/popupElement";
WUPPopupElement.$use(); // call it to register in the system
// redefine some defaults; WARN: you can change placement rules here without changing $options per each element!!!
WUPPopupElement.$defaults.offset = [2, 2];
WUPPopupElement.$defaults.minWidthByTarget = true;
WUPPopupElement.$defaults.arrowEnable = true;
// create element
const el = document.createElement("wup-popup");
// WARN el.$options is a observable-clone of WUPPopupElement.$defaults
// WARN: PopupOpenCases is const enum and import PopupOpenCases available only in Typescript
el.$options.openCase = PopupOpenCases.onClick | PopupOpenCases.onFocus; // show popup by target.click and/or target.focus events
el.$options.target = document.querySelector("button");
/*
Placement can be $top, $right, $bottom, $left (top - above at the target etc.)
every placement has align options: $start, $middle, $end (left - to align at start of target)
also you can set $adjust to allow Reduce popup to fit layout
*/
el.$options.placement = [
WUPPopupElement.$placements.$top.$middle; // place at the top of target and align by vertical line
WUPPopupElement.$placements.$bottom.$middle.$adjust, // adjust means 'ignore align to fit layout`
WUPPopupElement.$placements.$bottom.$middle.$adjust.$resizeHeight, // resize means 'allow to resize to fit layout'
]
document.body.append(el);
HTML, JSX, TSX
<button id="btn1">Target</button>
<!-- You can skip pointing attribute 'target' if popup appended after target -->
<wup-popup w-target="#btn1" w-placement="top-start">Some content here</wup-popup>
How to extend/override
/// popup.ts
// you can override via prototypes
const original = WUPPopupElement.prototype.goOpen;
WUPPopupElement.prototype.goOpen = function customGoShow() {
if (window.isBusy) {
return null;
}
return original(...arguments);
};
/*** OR create extended class ***/
class Popup extends WUPPopupElement {
// take a look on definition of WUPPopupElement and you will find internals
protected override goOpen(openCase: PopupOpenCases): boolean {
if (openCase === PopupOpenCases.onHover) {
return false;
}
return super.goOpen(openCase);
}
}
const tagName = "ext-popup";
customElements.define(tagName, Popup);
// That's it. New Popup with custom tag 'ext-popup' is ready
// add for intellisense (for *.ts only)
declare global {
// add element to document.createElement
interface HTMLElementTagNameMap {
[tagName]: Popup;
}
// add element for tsx/jsx intellisense
namespace JSX {
interface IntrinsicElements {
[tagName]: IntrinsicElements["wup-popup"];
}
}
}
use import focusFirst from "web-ui-pack/helpers/focusFirst"
etc.
WARN: don't use import {focusFirst} from "web-ui-pack;
because in this case the whole web-ui-pack module traps in compilation of dev-bundle and increases time of compilation
Animate (show/hide) element as dropdown via scale and counter-scale for children
Animate (show/hide) every element via moving from target to own position
Compare by Date-values without Time
Copy hh:mm:ss.fff part from B to A
Returns parsed date from string based on pointed format
Returns a string representation of a date-time according to pointed format
Find first parent with active scroll X/Y
Find all parents with active scroll X/Y
Set focus on element or first possible nested element
Check if element is visible in scrollable parents
Sum without float-precision-issue
Scale value from one range to another
nestedProperty.set(obj, "value.nestedValue", 1) sets obj.value.nestedValue = 1
nestedProperty.get(obj, "nested.val2", out?: {hasProp?: boolean} ) returns value from obj.nested.val2
deep cloning object
converts object to observable (via Proxy) to allow listen for changes
More strict (for Typescript) wrapper of addEventListener() that returns callback with removeListener()
Fires when element/children takes focus once (fires again after onFocusLost on element)
Handles wheel & touch events for custom scrolling
Returns callback when scrolling is stopped (via checking scroll position every frame-render)
Fires when element/children completely lost focus
Spy on method-call of object
Produce Promise during for "no less than pointed time"; it helps for avoding spinner blinking during the very fast api-request in case: pending > waitResponse > resetPending
Scroll the HTMLElement's parent container such that the element is visible to the user and return promise by animation end
Class makes pointed element scrollable and implements carousel-scroll behavior (appends new items during the scrolling). Supports swipe/pageUp/pageDown/mouseWheel events.
Returns count of chars in lower case (for any language with ignoring numbers, symbols)
Returns count of chars in upper case (for any language with ignoring numbers, symbols)
Changes camelCase, snakeCase, kebabCase text to user-friendly
Locale-object with definitions related to user-locale
Plane time object without date
Be sure that you familiar with common rules
web-ui-pack is compiled to ESNext. So some features maybe don't exist in browsers. To resolve it include the lib into babel-loader (for webpack check module.rules...exclude sections
// webpack.config.js { test: /\.(js|jsx)$/, exclude: (() => { // these packages must be included to change according to browserslist const include = ["web-ui-pack"]; return (v) => v.includes("node_modules") && !include.some((lib) => v.includes(lib)); })(), use: [ "babel-loader", ], },
<wup-popup />
etcIt's possible if you missed import or it was removed by optimizer of webpack etc. To fix this need to force import at least once and don't forget to call
.$use()
import { WUPSelectControl, WUPTextControl } from "web-ui-pack"; WUPTextControl.$use(); // register element WUPSelectControl.$use(); // register element // etc.
see demo/faq
1.0.2 (Nov 21, 2023)
text-align: start
by default to avoid unexpected inheritance[checked]
to re-style whole itemFAQs
Web package with UI elements
The npm package web-ui-pack receives a total of 95 weekly downloads. As such, web-ui-pack popularity was classified as not popular.
We found that web-ui-pack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.