Skip to content

Commit b324334

Browse files
authored
Merge branch 'develop' into dnn-autocomplete
2 parents 690930a + aa6e685 commit b324334

File tree

27 files changed

+381
-57
lines changed

27 files changed

+381
-57
lines changed

package-lock.json

+19-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stencil-library/custom-elements.json

+7
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,13 @@
10581058
"text": "string"
10591059
},
10601060
"description": "When the image crop changes, emits the dataurl for the new cropped image."
1061+
},
1062+
{
1063+
"name": "imageFileCropChanged",
1064+
"type": {
1065+
"text": "File"
1066+
},
1067+
"description": "Emits both when a file is initially select and when the crop has changed.\r\nCompared to imageCropChanged, this event emits the file itself, which can be useful for uploading the file to a server including its name."
10611068
}
10621069
],
10631070
"slots": [],

packages/stencil-library/src/components.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ declare global {
980980
};
981981
interface HTMLDnnImageCropperElementEventMap {
982982
"imageCropChanged": string;
983+
"imageFileCropChanged": File;
983984
}
984985
/**
985986
* Allows cropping an image in-browser with the option to enforce a specific final size.
@@ -1612,6 +1613,10 @@ declare namespace LocalJSX {
16121613
* When the image crop changes, emits the dataurl for the new cropped image.
16131614
*/
16141615
"onImageCropChanged"?: (event: DnnImageCropperCustomEvent<string>) => void;
1616+
/**
1617+
* Emits both when a file is initially select and when the crop has changed. Compared to imageCropChanged, this event emits the file itself, which can be useful for uploading the file to a server including its name.
1618+
*/
1619+
"onImageFileCropChanged"?: (event: DnnImageCropperCustomEvent<File>) => void;
16151620
/**
16161621
* When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry.
16171622
*/

packages/stencil-library/src/components/dnn-color-picker/readme.md

+25
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@
99

1010
Color Picker for Dnn
1111

12+
## Usage
13+
14+
### HTML
15+
16+
```html
17+
<dnn-color-picker
18+
color="FFFFFF"
19+
color-box-height="50%"
20+
>
21+
</dnn-color-picker>
22+
```
23+
24+
25+
### JSX-TSX
26+
27+
```tsx
28+
<dnn-color-picker
29+
color="FFFFFF"
30+
colorBoxHeight="50%"
31+
>
32+
</dnn-color-picker>
33+
```
34+
35+
36+
1237
## Properties
1338

1439
| Property | Attribute | Description | Type | Default |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```html
2+
<dnn-color-picker
3+
color="FFFFFF"
4+
color-box-height="50%"
5+
>
6+
</dnn-color-picker>
7+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```tsx
2+
<dnn-color-picker
3+
color="FFFFFF"
4+
colorBoxHeight="50%"
5+
>
6+
</dnn-color-picker>
7+
```

packages/stencil-library/src/components/dnn-fieldset/dnn-fieldset.scss

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
position: relative;
3535
width: 100%;
3636
background-color: var(--fieldset-background);
37-
max-width: calc(100% - 1em);
3837
height: calc(100% - 1em);
3938
}
4039
label{

packages/stencil-library/src/components/dnn-image-cropper/dnn-image-cropper.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, Element, Host, h, State, Prop, Event, EventEmitter, Method,
22
import { CornerType } from './CornerType';
33
import { getMovementFromEvent } from "../../utilities/mouseUtilities";
44
import { ImageCropperResx } from './types';
5+
import { dataURLtoFile } from '../../utilities/fileUtilities';
56

67
/**
78
* Allows cropping an image in-browser with the option to enforce a specific final size.
@@ -38,14 +39,20 @@ export class DnnImageCropper {
3839
/** When the image crop changes, emits the dataurl for the new cropped image. */
3940
@Event() imageCropChanged: EventEmitter<string>;
4041

42+
/** Emits both when a file is initially select and when the crop has changed.
43+
* Compared to imageCropChanged, this event emits the file itself, which can be useful for uploading the file to a server including its name.
44+
*/
45+
@Event() imageFileCropChanged: EventEmitter<File>;
46+
4147
/** Clears the current image and crop (resets the component). */
4248
@Method()
4349
public async clear(){
4450
this.setView("noPictureView");
4551
}
46-
52+
4753
@State() view: IComponentInterfaces["View"];
4854
@State() localResx: ImageCropperResx;
55+
@State() fileName: string;
4956

5057
@Element() host: HTMLDnnImageCropperElement;
5158

@@ -83,6 +90,7 @@ export class DnnImageCropper {
8390
this.mergeResx();
8491
}
8592

93+
// eslint-disable-next-line @stencil-community/own-methods-must-be-private
8694
formResetCallback(){
8795
this.clear();
8896
this.internals.setValidity({});
@@ -149,6 +157,8 @@ export class DnnImageCropper {
149157
return;
150158
}
151159

160+
this.fileName = file.name;
161+
152162
var reader = new FileReader();
153163
reader.onload = readerLoadEvent => {
154164
var img = new Image();
@@ -278,9 +288,11 @@ export class DnnImageCropper {
278288

279289
var dataUrl = this.generateCroppedImage(x, y, width, height, this.width ?? width, this.height ?? height);
280290
this.imageCropChanged.emit(dataUrl);
281-
if (this.name) {
291+
var file = dataURLtoFile(dataUrl, this.fileName);
292+
this.imageFileCropChanged.emit(file);
293+
if (this.name != undefined) {
282294
var data = new FormData();
283-
data.append(this.name, dataUrl);
295+
data.append(this.name, file);
284296
this.internals.setFormValue(data);
285297
}
286298
}

packages/stencil-library/src/components/dnn-image-cropper/readme.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ in an event that has a data-url of the image.
2525

2626
## Events
2727

28-
| Event | Description | Type |
29-
| ------------------ | ------------------------------------------------------------------------- | --------------------- |
30-
| `imageCropChanged` | When the image crop changes, emits the dataurl for the new cropped image. | `CustomEvent<string>` |
28+
| Event | Description | Type |
29+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
30+
| `imageCropChanged` | When the image crop changes, emits the dataurl for the new cropped image. | `CustomEvent<string>` |
31+
| `imageFileCropChanged` | Emits both when a file is initially select and when the crop has changed. Compared to imageCropChanged, this event emits the file itself, which can be useful for uploading the file to a server including its name. | `CustomEvent<File>` |
3132

3233

3334
## Methods

packages/stencil-library/src/components/dnn-input/dnn-input.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ export class DnnInput {
7878
async checkValidity(): Promise<ValidityState> {
7979
return this.inputField.validity;
8080
}
81-
81+
8282
/** Can be used to set a custom validity message. */
8383
@Method()
8484
async setCustomValidity(message: string): Promise<void> {
85-
this.customValidityMessage = message;
86-
return this.inputField.setCustomValidity(message);
85+
this.inputField.setCustomValidity(message);
86+
this.fieldset.setValidity(false, message);
8787
}
8888

8989
@State() focused = false;
9090
@State() valid = true;
91-
@State() customValidityMessage: string;
92-
91+
9392
@AttachInternals() internals: ElementInternals;
9493

9594
private inputField!: HTMLInputElement;
95+
private fieldset: HTMLDnnFieldsetElement;
9696
private labelId: string;
9797

9898
componentWillLoad() {
@@ -116,10 +116,7 @@ export class DnnInput {
116116
}
117117

118118
private handleInvalid(): void {
119-
this.valid = false;
120-
if (this.customValidityMessage == undefined){
121-
this.customValidityMessage = this.inputField.validationMessage;
122-
}
119+
this.fieldset.setValidity(false, this.inputField.validationMessage);
123120
}
124121

125122
private handleChange() {
@@ -164,6 +161,7 @@ export class DnnInput {
164161
return (
165162
<Host>
166163
<dnn-fieldset
164+
ref={el => this.fieldset = el}
167165
invalid={!this.valid}
168166
focused={this.focused}
169167
label={`${this.label ?? ""}${this.required ? " *" : ""}`}

packages/stencil-library/src/components/dnn-monaco-editor/readme.md

+31
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@
55
<!-- Auto Generated Below -->
66

77

8+
## Usage
9+
10+
### HTML
11+
12+
```html
13+
<dnn-monaco-editor
14+
language="html"
15+
value="<h1>Hello World</h1>
16+
<div class=&quot;card&quot;>
17+
<p>Some text</p>
18+
</div>"
19+
>
20+
</dnn-monaco-editor>
21+
```
22+
23+
24+
### JSX-TSX
25+
26+
```tsx
27+
<dnn-monaco-editor
28+
language="html"
29+
value="<h1>Hello World</h1>
30+
<div class=&quot;card&quot;>
31+
<p>Some text</p>
32+
</div>"
33+
>
34+
</dnn-monaco-editor>
35+
```
36+
37+
38+
839
## Properties
940

1041
| Property | Attribute | Description | Type | Default |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```html
2+
<dnn-monaco-editor
3+
language="html"
4+
value="<h1>Hello World</h1>
5+
<div class=&quot;card&quot;>
6+
<p>Some text</p>
7+
</div>"
8+
>
9+
</dnn-monaco-editor>
10+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```tsx
2+
<dnn-monaco-editor
3+
language="html"
4+
value="<h1>Hello World</h1>
5+
<div class=&quot;card&quot;>
6+
<p>Some text</p>
7+
</div>"
8+
>
9+
</dnn-monaco-editor>
10+
```

0 commit comments

Comments
 (0)