@xtia/jel 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -89,7 +89,7 @@ Element classes can be specified as string, `{ [className]: boolean }` and arbit
89
89
  function renderFancyButton(
90
90
  caption: DOMContent,
91
91
  onClick: () => void,
92
- classes: ElementClassDefinition = []
92
+ classes: ElementClassDescriptor = []
93
93
  ) {
94
94
  return $.button({
95
95
  content: caption,
@@ -118,8 +118,8 @@ Jel wraps its elements in an interface for common operations plus an `append()`
118
118
  For other operations the element is accessible via `ent.element`:
119
119
 
120
120
  ```ts
121
- const button = $.button();
122
- const rect = button.element.getBoundingClientRect();
121
+ const div = $.div();
122
+ div.element.requestFullscreen();
123
123
  ```
124
124
 
125
125
  ## Shorthand
package/index.d.ts CHANGED
@@ -47,8 +47,20 @@ type ElementAPI<T extends HTMLElement> = {
47
47
  qsa(selector: string): DomEntity<any>[];
48
48
  append(...content: DOMContent[]): void;
49
49
  remove(): void;
50
+ getRect(): DOMRect;
51
+ focus(): void;
52
+ blur(): void;
50
53
  } & (T extends HTMLInputElement ? {
51
54
  value: string;
55
+ select(): void;
56
+ } : T extends HTMLCanvasElement ? {
57
+ width: number;
58
+ height: number;
59
+ getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D | null;
60
+ getContext(contextId: "bitmaprenderer", options?: ImageBitmapRenderingContextSettings): ImageBitmapRenderingContext | null;
61
+ getContext(contextId: "webgl", options?: WebGLContextAttributes): WebGLRenderingContext | null;
62
+ getContext(contextId: "webgl2", options?: WebGLContextAttributes): WebGL2RenderingContext | null;
63
+ getContext(contextId: string, options?: any): RenderingContext | null;
52
64
  } : {});
53
65
  type OptionalKeys<T> = {
54
66
  [K in keyof T]-?: {} extends Pick<T, K> ? K : never;
package/index.js CHANGED
@@ -129,7 +129,13 @@ var attribsProxy = {
129
129
  set: function (element, key, value) {
130
130
  element.setAttribute(key, value);
131
131
  return true;
132
- }
132
+ },
133
+ has: function (element, key) {
134
+ return element.hasAttribute(key);
135
+ },
136
+ ownKeys: function (element) {
137
+ return element.getAttributeNames();
138
+ },
133
139
  };
134
140
  var recursiveAppend = function (parent, c) {
135
141
  if (c === null)
@@ -187,6 +193,21 @@ function getWrappedElement(element) {
187
193
  _a.qsa = function (selector) {
188
194
  return [].slice.call(element.querySelectorAll(selector)).map(function (el) { return getWrappedElement(el); });
189
195
  },
196
+ _a.getRect = function () {
197
+ return element.getBoundingClientRect();
198
+ },
199
+ _a.focus = function () {
200
+ element.focus();
201
+ },
202
+ _a.blur = function () {
203
+ element.blur();
204
+ },
205
+ _a.select = function () {
206
+ element.select();
207
+ },
208
+ _a.getContext = function (mode, options) {
209
+ return element.getContext(mode, options);
210
+ },
190
211
  Object.defineProperty(_a, "content", {
191
212
  get: function () {
192
213
  return [].slice.call(element.children).map(function (child) {
@@ -223,6 +244,16 @@ function getWrappedElement(element) {
223
244
  enumerable: false,
224
245
  configurable: true
225
246
  }),
247
+ Object.defineProperty(_a, "width", {
248
+ get: function () {
249
+ return element.width;
250
+ },
251
+ set: function (v) {
252
+ element.width = v;
253
+ },
254
+ enumerable: false,
255
+ configurable: true
256
+ }),
226
257
  _a.style = new Proxy(element.style, elementProxy),
227
258
  _a);
228
259
  elementWrapCache.set(element, domEntity_1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtia/jel",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "repository": {
5
5
  "url": "https://github.com/tiadrop/jel-ts",
6
6
  "type": "github"