@patternfly/pfe-core 2.0.0-next.10 → 2.0.0-next.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +4 -4
- package/controllers/color-context.d.ts +2 -2
- package/controllers/floating-dom-controller.d.ts +3 -3
- package/controllers/internals-controller.d.ts +9 -0
- package/controllers/internals-controller.js +2 -0
- package/controllers/internals-controller.js.map +7 -0
- package/controllers/property-observer-controller.d.ts +3 -3
- package/controllers/slot-controller.d.ts +1 -1
- package/decorators/deprecation.d.ts +1 -1
- package/decorators/observed.d.ts +1 -1
- package/functions/isElementInView.d.ts +12 -0
- package/functions/isElementInView.js +2 -0
- package/functions/isElementInView.js.map +7 -0
- package/package.json +4 -2
package/context.d.ts
CHANGED
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type Context<T> = {
|
|
9
9
|
name: string;
|
|
10
10
|
initialValue?: T;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* An unknown context typeU
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type UnknownContext = Context<unknown>;
|
|
16
16
|
/**
|
|
17
17
|
* A helper type which can extract a Context value type from a Context type
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type ContextType<T extends UnknownContext> = T extends Context<infer Y> ? Y : never;
|
|
20
20
|
/**
|
|
21
21
|
* A function which creates a Context value object
|
|
22
22
|
*/
|
|
@@ -25,7 +25,7 @@ export declare function createContext<T>(name: string, initialValue?: T): Readon
|
|
|
25
25
|
* A callback which is provided by a context requester and is called with the value satisfying the request.
|
|
26
26
|
* This callback can be called multiple times by context providers as the requested value is changed.
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export type ContextCallback<ValueType> = (value: ValueType, dispose?: () => void) => void;
|
|
29
29
|
/**
|
|
30
30
|
* An event fired by a context requester to signal it desires a named context.
|
|
31
31
|
*
|
|
@@ -10,13 +10,13 @@ import { StyleController } from './style-controller.js';
|
|
|
10
10
|
*
|
|
11
11
|
* `ColorPalette` is associated with the `color-palette` attribute
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type ColorPalette = ('base' | 'accent' | 'complement' | 'lighter' | 'lightest' | 'darker' | 'darkest');
|
|
14
14
|
/**
|
|
15
15
|
* A Color theme is a context-specific restriction on the available color palettes
|
|
16
16
|
*
|
|
17
17
|
* `ColorTheme` is associated with the `on` attribute and the `--context` css property
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type ColorTheme = ('dark' | 'light' | 'saturated');
|
|
20
20
|
export interface ColorContextOptions {
|
|
21
21
|
prefix?: string;
|
|
22
22
|
attribute?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Direction = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
type Alignment = 'start' | 'end';
|
|
4
4
|
/**
|
|
5
5
|
* Represents the placement of floating DOM
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Placement = Direction | `${Direction}-${Alignment}`;
|
|
8
8
|
/**
|
|
9
9
|
* Controls floating DOM within a web component, e.g. tooltips and popovers
|
|
10
10
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
export declare class InternalsController implements ReactiveController {
|
|
3
|
+
#private;
|
|
4
|
+
host: ReactiveControllerHost & HTMLElement;
|
|
5
|
+
constructor(host: ReactiveControllerHost & HTMLElement);
|
|
6
|
+
hostConnected?(): void;
|
|
7
|
+
submit(): void;
|
|
8
|
+
reset(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var l=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var s=(t,e,o)=>(l(t,e,"read from private field"),o?o.call(t):e.get(t)),n=(t,e,o)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,o)},c=(t,e,o,i)=>(l(t,e,"write to private field"),i?i.call(t,o):e.set(t,o),o);var r,m=class{constructor(e){this.host=e;n(this,r,void 0);c(this,r,e.attachInternals())}submit(){s(this,r).form?.requestSubmit(this.host)}reset(){s(this,r).form?.reset()}};r=new WeakMap;export{m as InternalsController};
|
|
2
|
+
//# sourceMappingURL=internals-controller.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["internals-controller.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nexport class InternalsController implements ReactiveController {\n #internals: ElementInternals;\n\n constructor(\n public host: ReactiveControllerHost & HTMLElement,\n ) {\n this.#internals = host.attachInternals();\n }\n\n hostConnected?(): void\n\n submit() {\n this.#internals.form?.requestSubmit(this.host);\n }\n\n reset() {\n this.#internals.form?.reset();\n }\n}\n"],
|
|
5
|
+
"mappings": "mVAAA,IAAAA,EAEaC,EAAN,KAAwD,CAG7D,YACSC,EACP,CADO,UAAAA,EAHTC,EAAA,KAAAH,EAAA,QAKEI,EAAA,KAAKJ,EAAaE,EAAK,gBAAgB,EACzC,CAIA,QAAS,CACPG,EAAA,KAAKL,GAAW,MAAM,cAAc,KAAK,IAAI,CAC/C,CAEA,OAAQ,CACNK,EAAA,KAAKL,GAAW,MAAM,MAAM,CAC9B,CACF,EAjBEA,EAAA",
|
|
6
|
+
"names": ["_internals", "InternalsController", "host", "__privateAdd", "__privateSet", "__privateGet"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactiveController, ReactiveElement } from 'lit';
|
|
2
2
|
export declare const observedController: unique symbol;
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export type ChangeCallback<T = ReactiveElement> = (this: T, old?: T[keyof T], newV?: T[keyof T]) => void;
|
|
4
|
+
export type ChangeCallbackName = `_${string}Changed`;
|
|
5
|
+
export type PropertyObserverHost<T> = T & Record<ChangeCallbackName, ChangeCallback<T>> & {
|
|
6
6
|
[observedController]: PropertyObserverController;
|
|
7
7
|
};
|
|
8
8
|
/** This controller holds a cache of observed property values which were set before the element updated */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactiveElement, PropertyDeclaration } from 'lit';
|
|
2
|
-
export
|
|
2
|
+
export type DeprecationDeclaration<K extends PropertyKey> = PropertyDeclaration & {
|
|
3
3
|
alias: string & K;
|
|
4
4
|
attribute: string;
|
|
5
5
|
};
|
package/decorators/observed.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactiveElement } from 'lit';
|
|
2
2
|
import type { ChangeCallback } from '../controllers/property-observer-controller.js';
|
|
3
|
-
|
|
3
|
+
type TypedFieldDecorator<T> = (proto: T, key: string | keyof T) => void;
|
|
4
4
|
/**
|
|
5
5
|
* Calls a _fooChanged method on the instance when the value changes.
|
|
6
6
|
* Works on any class field. When using on lit observed properties,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function returns whether or not an element is within the viewable area of a container. If partial is true,
|
|
3
|
+
* then this function will return true even if only part of the element is in view.
|
|
4
|
+
*
|
|
5
|
+
* @param container The container to check if the element is in view of.
|
|
6
|
+
* @param element The element to check if it is view
|
|
7
|
+
* @param partial true if partial view is allowed
|
|
8
|
+
* @param strict true if strict mode is set, never consider the container width and element width
|
|
9
|
+
*
|
|
10
|
+
* @returns True if the component is in View.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isElementInView(container: HTMLElement, element: HTMLElement, partial?: boolean, strict?: boolean): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function d(s,c,a=!1,r=!1){if(!s||!c)return!1;let t=s.getBoundingClientRect(),n=c.getBoundingClientRect(),e=Math.ceil(t.left),o=Math.floor(t.right),i=Math.ceil(n.left),l=Math.floor(n.right),f=i>=e&&l<=o,u=(a||!r&&t.width<n.width)&&(i<e&&l>e||l>o&&i<o);return f||u}export{d as isElementInView};
|
|
2
|
+
//# sourceMappingURL=isElementInView.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["isElementInView.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * This function returns whether or not an element is within the viewable area of a container. If partial is true,\n * then this function will return true even if only part of the element is in view.\n *\n * @param container The container to check if the element is in view of.\n * @param element The element to check if it is view\n * @param partial true if partial view is allowed\n * @param strict true if strict mode is set, never consider the container width and element width\n *\n * @returns True if the component is in View.\n */\nexport function isElementInView(\n container: HTMLElement,\n element: HTMLElement,\n partial = false,\n strict = false\n): boolean {\n if (!container || !element) {\n return false;\n }\n const containerBounds = container.getBoundingClientRect();\n const elementBounds = element.getBoundingClientRect();\n const containerBoundsLeft = Math.ceil(containerBounds.left);\n const containerBoundsRight = Math.floor(containerBounds.right);\n const elementBoundsLeft = Math.ceil(elementBounds.left);\n const elementBoundsRight = Math.floor(elementBounds.right);\n\n // Check if in view\n const isTotallyInView =\n elementBoundsLeft >= containerBoundsLeft &&\n elementBoundsRight <= containerBoundsRight;\n const isPartiallyInView =\n (partial || (!strict && containerBounds.width < elementBounds.width)) &&\n ((elementBoundsLeft < containerBoundsLeft && elementBoundsRight > containerBoundsLeft) ||\n (elementBoundsRight > containerBoundsRight && elementBoundsLeft < containerBoundsRight));\n\n // Return outcome\n return isTotallyInView || isPartiallyInView;\n}\n"],
|
|
5
|
+
"mappings": "AAWO,SAASA,EACdC,EACAC,EACAC,EAAU,GACVC,EAAS,GACA,CACT,GAAI,CAACH,GAAa,CAACC,EACjB,MAAO,GAET,IAAMG,EAAkBJ,EAAU,sBAAsB,EAClDK,EAAgBJ,EAAQ,sBAAsB,EAC9CK,EAAsB,KAAK,KAAKF,EAAgB,IAAI,EACpDG,EAAuB,KAAK,MAAMH,EAAgB,KAAK,EACvDI,EAAoB,KAAK,KAAKH,EAAc,IAAI,EAChDI,EAAqB,KAAK,MAAMJ,EAAc,KAAK,EAGnDK,EACJF,GAAqBF,GACrBG,GAAsBF,EAClBI,GACHT,GAAY,CAACC,GAAUC,EAAgB,MAAQC,EAAc,SAC5DG,EAAoBF,GAAuBG,EAAqBH,GAC/DG,EAAqBF,GAAwBC,EAAoBD,GAGtE,OAAOG,GAAmBC,CAC5B",
|
|
6
|
+
"names": ["isElementInView", "container", "element", "partial", "strict", "containerBounds", "elementBounds", "containerBoundsLeft", "containerBoundsRight", "elementBoundsLeft", "elementBoundsRight", "isTotallyInView", "isPartiallyInView"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/pfe-core",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "PatternFly Elements Core Library",
|
|
6
6
|
"customElements": "custom-elements.json",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"./controllers/css-variable-controller.js": "./controllers/css-variable-controller.js",
|
|
19
19
|
"./controllers/light-dom-controller.js": "./controllers/light-dom-controller.js",
|
|
20
20
|
"./controllers/logger.js": "./controllers/logger.js",
|
|
21
|
+
"./controllers/internals-controller.js": "./controllers/internals-controller.js",
|
|
21
22
|
"./controllers/perf-controller.js": "./controllers/perf-controller.js",
|
|
22
23
|
"./controllers/property-observer-controller.js": "./controllers/property-observer-controller.js",
|
|
23
24
|
"./controllers/slot-controller.js": "./controllers/slot-controller.js",
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
"./decorators/trace.js": "./decorators/trace.js",
|
|
35
36
|
"./functions/debounce.js": "./functions/debounce.js",
|
|
36
37
|
"./functions/deprecatedCustomEvent.js": "./functions/deprecatedCustomEvent.js",
|
|
37
|
-
"./functions/random.js": "./functions/random.js"
|
|
38
|
+
"./functions/random.js": "./functions/random.js",
|
|
39
|
+
"./functions/isElementInView.js": "./functions/isElementInView.js"
|
|
38
40
|
},
|
|
39
41
|
"publishConfig": {
|
|
40
42
|
"access": "public",
|