@seedgrid/fe-components 2026.11.1 → 2026.11.3
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/dist/ai/seedgrid-components.manifest.json +1527 -89
- package/dist/buttons/SgButton.d.ts +6 -2
- package/dist/buttons/SgButton.d.ts.map +1 -1
- package/dist/buttons/SgButton.js +2 -2
- package/dist/buttons/SgButton.meta.js +3 -3
- package/dist/buttons/SgFloatActionButton.d.ts +2 -2
- package/dist/buttons/SgFloatActionButton.d.ts.map +1 -1
- package/dist/buttons/SgFloatActionButton.js +7 -7
- package/dist/buttons/SgFloatActionButton.meta.js +2 -2
- package/dist/buttons/SgSplitButton.d.ts +2 -2
- package/dist/buttons/SgSplitButton.d.ts.map +1 -1
- package/dist/buttons/SgSplitButton.js +4 -4
- package/dist/buttons/SgSplitButton.meta.js +3 -3
- package/dist/commons/SgAvatar.d.ts +2 -2
- package/dist/commons/SgAvatar.d.ts.map +1 -1
- package/dist/commons/SgAvatar.js +3 -3
- package/dist/commons/SgBadge.d.ts +1 -1
- package/dist/commons/SgBadge.d.ts.map +1 -1
- package/dist/commons/SgBadge.js +3 -3
- package/dist/generated/compiledStyles.d.ts +1 -1
- package/dist/generated/compiledStyles.d.ts.map +1 -1
- package/dist/generated/compiledStyles.js +1 -1
- package/dist/i18n/en-US.d.ts.map +1 -1
- package/dist/i18n/en-US.js +55 -0
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +55 -0
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +55 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -1
- package/dist/i18n/pt-BR.js +55 -0
- package/dist/i18n/pt-PT.d.ts.map +1 -1
- package/dist/i18n/pt-PT.js +55 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/inputs/SgAutocomplete.d.ts +1 -1
- package/dist/inputs/SgAutocomplete.d.ts.map +1 -1
- package/dist/inputs/SgAutocomplete.js +3 -3
- package/dist/inputs/SgCameraCapture.d.ts +25 -0
- package/dist/inputs/SgCameraCapture.d.ts.map +1 -0
- package/dist/inputs/SgCameraCapture.js +114 -0
- package/dist/inputs/SgCameraCapture.meta.d.ts +4 -0
- package/dist/inputs/SgCameraCapture.meta.d.ts.map +1 -0
- package/dist/inputs/SgCameraCapture.meta.js +63 -0
- package/dist/inputs/SgCheckboxGroup.d.ts +2 -2
- package/dist/inputs/SgCheckboxGroup.d.ts.map +1 -1
- package/dist/inputs/SgCheckboxGroup.js +12 -12
- package/dist/inputs/SgCombobox.js +5 -5
- package/dist/inputs/SgDatatable.js +11 -11
- package/dist/inputs/SgDatatable.meta.d.ts.map +1 -1
- package/dist/inputs/SgDatatable.meta.js +4 -1
- package/dist/inputs/SgFileUpload.d.ts +69 -0
- package/dist/inputs/SgFileUpload.d.ts.map +1 -0
- package/dist/inputs/SgFileUpload.js +234 -0
- package/dist/inputs/SgFileUpload.meta.d.ts +4 -0
- package/dist/inputs/SgFileUpload.meta.d.ts.map +1 -0
- package/dist/inputs/SgFileUpload.meta.js +71 -0
- package/dist/inputs/SgImageUpload.d.ts +20 -0
- package/dist/inputs/SgImageUpload.d.ts.map +1 -0
- package/dist/inputs/SgImageUpload.js +74 -0
- package/dist/inputs/SgImageUpload.meta.d.ts +4 -0
- package/dist/inputs/SgImageUpload.meta.d.ts.map +1 -0
- package/dist/inputs/SgImageUpload.meta.js +73 -0
- package/dist/inputs/SgInputCurrency.d.ts.map +1 -1
- package/dist/inputs/SgInputCurrency.js +6 -4
- package/dist/inputs/SgInputDate.d.ts.map +1 -1
- package/dist/inputs/SgInputDate.js +3 -4
- package/dist/inputs/SgInputDateTime.d.ts +29 -0
- package/dist/inputs/SgInputDateTime.d.ts.map +1 -0
- package/dist/inputs/SgInputDateTime.js +141 -0
- package/dist/inputs/SgInputDateTime.meta.d.ts +4 -0
- package/dist/inputs/SgInputDateTime.meta.d.ts.map +1 -0
- package/dist/inputs/SgInputDateTime.meta.js +73 -0
- package/dist/inputs/SgInputNumber.d.ts.map +1 -1
- package/dist/inputs/SgInputNumber.js +6 -4
- package/dist/inputs/SgInputText.d.ts.map +1 -1
- package/dist/inputs/SgInputText.js +6 -4
- package/dist/inputs/SgInputTextArea.d.ts.map +1 -1
- package/dist/inputs/SgInputTextArea.js +4 -2
- package/dist/inputs/SgMultiSelect.meta.js +1 -1
- package/dist/inputs/SgMultiSelectChips.meta.js +1 -1
- package/dist/inputs/SgMultiSelectDropdown.js +1 -1
- package/dist/inputs/SgOrderList.d.ts +3 -3
- package/dist/inputs/SgOrderList.d.ts.map +1 -1
- package/dist/inputs/SgOrderList.js +13 -13
- package/dist/inputs/SgOrderList.meta.js +1 -1
- package/dist/inputs/SgPeriodSelector.d.ts +1 -1
- package/dist/inputs/SgPeriodSelector.d.ts.map +1 -1
- package/dist/inputs/SgPeriodSelector.js +3 -3
- package/dist/inputs/SgPickList.d.ts +3 -3
- package/dist/inputs/SgPickList.d.ts.map +1 -1
- package/dist/inputs/SgPickList.js +28 -28
- package/dist/inputs/SgPickList.meta.js +1 -1
- package/dist/inputs/SgRadioGroup.d.ts +2 -2
- package/dist/inputs/SgRadioGroup.d.ts.map +1 -1
- package/dist/inputs/SgRadioGroup.js +5 -5
- package/dist/inputs/SgRating.d.ts +1 -1
- package/dist/inputs/SgRating.d.ts.map +1 -1
- package/dist/inputs/SgRating.js +7 -7
- package/dist/inputs/SgRating.meta.js +1 -1
- package/dist/inputs/SgSlider.d.ts +1 -1
- package/dist/inputs/SgSlider.d.ts.map +1 -1
- package/dist/inputs/SgSlider.js +3 -3
- package/dist/inputs/SgSlider.meta.js +1 -1
- package/dist/inputs/SgStepperInput.d.ts +2 -2
- package/dist/inputs/SgStepperInput.d.ts.map +1 -1
- package/dist/inputs/SgStepperInput.js +4 -4
- package/dist/inputs/SgStepperInput.meta.js +1 -1
- package/dist/inputs/SgTextEditor.d.ts +1 -1
- package/dist/inputs/SgTextEditor.d.ts.map +1 -1
- package/dist/inputs/SgTextEditor.js +14 -14
- package/dist/inputs/SgToggleSwitch.meta.js +1 -1
- package/dist/inputs/SgYearPartSelector.d.ts +1 -1
- package/dist/inputs/SgYearPartSelector.d.ts.map +1 -1
- package/dist/inputs/SgYearPartSelector.js +1 -2
- package/dist/inputs/SgYearPartSelector.meta.js +2 -2
- package/dist/inputs/cameraLogic.d.ts +27 -0
- package/dist/inputs/cameraLogic.d.ts.map +1 -0
- package/dist/inputs/cameraLogic.js +57 -0
- package/dist/inputs/dateTimeLogic.d.ts +28 -0
- package/dist/inputs/dateTimeLogic.d.ts.map +1 -0
- package/dist/inputs/dateTimeLogic.js +153 -0
- package/dist/inputs/fileUploadLogic.d.ts +62 -0
- package/dist/inputs/fileUploadLogic.d.ts.map +1 -0
- package/dist/inputs/fileUploadLogic.js +254 -0
- package/dist/inputs/imageUploadLogic.d.ts +31 -0
- package/dist/inputs/imageUploadLogic.d.ts.map +1 -0
- package/dist/inputs/imageUploadLogic.js +70 -0
- package/dist/inputs/useSgMultiSelect.d.ts +1 -1
- package/dist/inputs/useSgMultiSelect.d.ts.map +1 -1
- package/dist/inputs/useSgMultiSelect.js +1 -1
- package/dist/layout/SgAccordion.d.ts +1 -1
- package/dist/layout/SgAccordion.d.ts.map +1 -1
- package/dist/layout/SgAccordion.js +3 -3
- package/dist/layout/SgBreadcrumb.d.ts +1 -1
- package/dist/layout/SgBreadcrumb.d.ts.map +1 -1
- package/dist/layout/SgBreadcrumb.js +1 -1
- package/dist/layout/SgCard.d.ts +1 -1
- package/dist/layout/SgCard.d.ts.map +1 -1
- package/dist/layout/SgCard.js +14 -14
- package/dist/layout/SgMenu.d.ts +1 -1
- package/dist/layout/SgMenu.d.ts.map +1 -1
- package/dist/layout/SgMenu.js +15 -15
- package/dist/layout/SgPageControl.d.ts +1 -1
- package/dist/layout/SgPageControl.d.ts.map +1 -1
- package/dist/layout/SgPageControl.js +4 -4
- package/dist/layout/SgPageControlPage.meta.js +2 -2
- package/dist/layout/SgToolBar.d.ts +1 -1
- package/dist/layout/SgToolBar.d.ts.map +1 -1
- package/dist/layout/SgToolBar.js +4 -4
- package/dist/layout/SgToolbarIconButton.meta.js +2 -2
- package/dist/layout/SgTreeView.d.ts +4 -4
- package/dist/layout/SgTreeView.d.ts.map +1 -1
- package/dist/layout/SgTreeView.js +6 -6
- package/dist/menus/SgDockMenu.d.ts +1 -1
- package/dist/menus/SgDockMenu.d.ts.map +1 -1
- package/dist/menus/SgDockMenu.js +6 -4
- package/dist/notifications/SgNotificationBell.d.ts +51 -0
- package/dist/notifications/SgNotificationBell.d.ts.map +1 -0
- package/dist/notifications/SgNotificationBell.js +348 -0
- package/dist/notifications/SgNotificationBell.meta.d.ts +4 -0
- package/dist/notifications/SgNotificationBell.meta.d.ts.map +1 -0
- package/dist/notifications/SgNotificationBell.meta.js +75 -0
- package/dist/notifications/notificationBellLogic.d.ts +148 -0
- package/dist/notifications/notificationBellLogic.d.ts.map +1 -0
- package/dist/notifications/notificationBellLogic.js +244 -0
- package/dist/overlay/SgConfirmationDialog.d.ts +1 -1
- package/dist/overlay/SgConfirmationDialog.d.ts.map +1 -1
- package/dist/overlay/SgConfirmationDialog.js +1 -1
- package/dist/overlay/SgPopup.d.ts +1 -1
- package/dist/overlay/SgPopup.d.ts.map +1 -1
- package/dist/overlay/SgPopup.js +1 -1
- package/dist/realtime/SgRealtimeProvider.d.ts +5 -0
- package/dist/realtime/SgRealtimeProvider.d.ts.map +1 -1
- package/dist/realtime/SgRealtimeProvider.js +31 -8
- package/dist/sandbox.cjs +77 -66
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -7,7 +7,7 @@ export interface SgRadioGroupOption {
|
|
|
7
7
|
label: string;
|
|
8
8
|
value: string | number;
|
|
9
9
|
icon?: React.ReactNode;
|
|
10
|
-
|
|
10
|
+
enabled?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface SgRadioGroupProps extends RhfFieldProps {
|
|
13
13
|
id?: string;
|
|
@@ -17,7 +17,7 @@ export interface SgRadioGroupProps extends RhfFieldProps {
|
|
|
17
17
|
orientation?: SgRadioGroupOrientation;
|
|
18
18
|
selectionStyle?: SgRadioGroupSelectionStyle;
|
|
19
19
|
iconOnly?: boolean;
|
|
20
|
-
|
|
20
|
+
enabled?: boolean;
|
|
21
21
|
readOnly?: boolean;
|
|
22
22
|
required?: boolean;
|
|
23
23
|
onChange?: (value: string | number | null) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgRadioGroup.d.ts","sourceRoot":"","sources":["../../src/inputs/SgRadioGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAElF,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,UAAU,CAAC;AAChE,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,WAAW,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"SgRadioGroup.d.ts","sourceRoot":"","sources":["../../src/inputs/SgRadioGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAElF,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,UAAU,CAAC;AAChE,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,WAAW,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC,cAAc,CAAC,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAGnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3F;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAmPpD"}
|
|
@@ -7,7 +7,7 @@ import { t, useComponentsI18n } from "../i18n";
|
|
|
7
7
|
import { mergeRequiredRule, resolveFieldError } from "../rhf";
|
|
8
8
|
export function SgRadioGroup(props) {
|
|
9
9
|
const i18n = useComponentsI18n();
|
|
10
|
-
const { id, title, source, value: controlledValue, orientation = "vertical", selectionStyle = "radio", iconOnly = false,
|
|
10
|
+
const { id, title, source, value: controlledValue, orientation = "vertical", selectionStyle = "radio", iconOnly = false, enabled = true, readOnly = false, required = false, onChange, name, control, register, rules, error, className = "", style, optionClassName = "", groupBoxProps = {} } = props;
|
|
11
11
|
const resolvedGroupBoxTitle = (() => {
|
|
12
12
|
const baseTitle = groupBoxProps.title ?? title ?? "";
|
|
13
13
|
if (!required || !baseTitle.trim())
|
|
@@ -19,7 +19,7 @@ export function SgRadioGroup(props) {
|
|
|
19
19
|
const currentValue = isControlled ? controlledValue : internalValue;
|
|
20
20
|
const isHighlightSelection = selectionStyle === "highlight";
|
|
21
21
|
const handleChange = (newValue) => {
|
|
22
|
-
if (
|
|
22
|
+
if (!enabled || readOnly)
|
|
23
23
|
return;
|
|
24
24
|
if (!isControlled) {
|
|
25
25
|
setInternalValue(newValue);
|
|
@@ -28,7 +28,7 @@ export function SgRadioGroup(props) {
|
|
|
28
28
|
};
|
|
29
29
|
const renderRadioOption = (option, index, registration) => {
|
|
30
30
|
const isSelected = currentValue === option.value;
|
|
31
|
-
const isDisabled =
|
|
31
|
+
const isDisabled = !enabled || (option.enabled === false);
|
|
32
32
|
const inputClassName = isHighlightSelection
|
|
33
33
|
? "sr-only"
|
|
34
34
|
: "w-4 h-4 text-[rgb(var(--sg-primary-500))] border-[rgb(var(--sg-border))] focus:ring-[rgb(var(--sg-ring))] focus:ring-2 cursor-pointer disabled:cursor-not-allowed";
|
|
@@ -75,7 +75,7 @@ export function SgRadioGroup(props) {
|
|
|
75
75
|
const content = (_jsxs("div", { className: className, style: style, children: [_jsx(SgGroupBox, { ...groupBoxProps, title: resolvedGroupBoxTitle || " ", className: groupBoxProps.className || "", children: _jsx("div", { className: `
|
|
76
76
|
flex ${isHighlightSelection ? "gap-0" : "gap-4"}
|
|
77
77
|
${orientation === "vertical" ? "flex-col" : "flex-row flex-wrap"}
|
|
78
|
-
`, role: "radiogroup", "aria-disabled":
|
|
78
|
+
`, role: "radiogroup", "aria-disabled": !enabled || undefined, "aria-readonly": readOnly || undefined, "aria-required": required || undefined, children: source.map((option, index) => renderRadioOption(option, index)) }) }), error && (_jsx("div", { className: "mt-1 text-sm text-red-500", children: error }))] }));
|
|
79
79
|
const resolvedRules = mergeRequiredRule(rules, required, t(i18n, "components.inputs.required"));
|
|
80
80
|
// React Hook Form integration
|
|
81
81
|
if (control && name) {
|
|
@@ -89,7 +89,7 @@ export function SgRadioGroup(props) {
|
|
|
89
89
|
return (_jsxs("div", { className: className, style: style, children: [_jsx(SgGroupBox, { ...groupBoxProps, title: resolvedGroupBoxTitle || " ", children: _jsx("div", { className: `
|
|
90
90
|
flex ${isHighlightSelection ? "gap-0" : "gap-4"}
|
|
91
91
|
${orientation === "vertical" ? "flex-col" : "flex-row flex-wrap"}
|
|
92
|
-
`, role: "radiogroup", "aria-disabled":
|
|
92
|
+
`, role: "radiogroup", "aria-disabled": !enabled || undefined, "aria-readonly": readOnly || undefined, "aria-required": required || undefined, children: source.map((option, index) => renderRadioOption(option, index, registration)) }) }), error && (_jsx("div", { className: "mt-1 text-sm text-red-500", children: error }))] }));
|
|
93
93
|
}
|
|
94
94
|
return content;
|
|
95
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgRating.d.ts","sourceRoot":"","sources":["../../src/inputs/SgRating.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGlF,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAErD,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,wBAAwB;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,
|
|
1
|
+
{"version":3,"file":"SgRating.d.ts","sourceRoot":"","sources":["../../src/inputs/SgRating.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGlF,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAErD,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,wBAAwB;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wBAAwB;IACxB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,mCAAmC;IACnC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,kCAAkC;IAClC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,oCAAoC;IACpC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,wCAAwC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA+QD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAyC5C"}
|
package/dist/inputs/SgRating.js
CHANGED
|
@@ -23,7 +23,7 @@ function ErrorText(props) {
|
|
|
23
23
|
}
|
|
24
24
|
function SgRatingBase(props) {
|
|
25
25
|
const i18n = useComponentsI18n();
|
|
26
|
-
const { id, label, value = 0, stars = 5, allowHalf = false, cancel = true,
|
|
26
|
+
const { id, label, value = 0, stars = 5, allowHalf = false, cancel = true, enabled = true, readOnly = false, size = "md", className = "", style, onIcon, offIcon, cancelIcon, color = "hsl(var(--primary))", emptyColor = "hsl(var(--muted-foreground))", showTooltip = false, onChange, onHover, error, required = false, requiredMessage } = props;
|
|
27
27
|
const [hoverValue, setHoverValue] = React.useState(null);
|
|
28
28
|
const [internalValue, setInternalValue] = React.useState(value);
|
|
29
29
|
const [internalError, setInternalError] = React.useState(null);
|
|
@@ -31,7 +31,7 @@ function SgRatingBase(props) {
|
|
|
31
31
|
setInternalValue(value);
|
|
32
32
|
}, [value]);
|
|
33
33
|
const handleStarClick = (starIndex, isHalf) => {
|
|
34
|
-
if (
|
|
34
|
+
if (!enabled || readOnly)
|
|
35
35
|
return;
|
|
36
36
|
const newValue = allowHalf && isHalf ? starIndex + 0.5 : starIndex + 1;
|
|
37
37
|
setInternalValue(newValue);
|
|
@@ -46,7 +46,7 @@ function SgRatingBase(props) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
const handleStarHover = (starIndex, isHalf) => {
|
|
49
|
-
if (
|
|
49
|
+
if (!enabled || readOnly)
|
|
50
50
|
return;
|
|
51
51
|
const newHoverValue = allowHalf && isHalf ? starIndex + 0.5 : starIndex + 1;
|
|
52
52
|
setHoverValue(newHoverValue);
|
|
@@ -57,7 +57,7 @@ function SgRatingBase(props) {
|
|
|
57
57
|
onHover?.(null);
|
|
58
58
|
};
|
|
59
59
|
const handleCancel = () => {
|
|
60
|
-
if (
|
|
60
|
+
if (!enabled || readOnly)
|
|
61
61
|
return;
|
|
62
62
|
setInternalValue(0);
|
|
63
63
|
onChange?.(0);
|
|
@@ -71,7 +71,7 @@ function SgRatingBase(props) {
|
|
|
71
71
|
};
|
|
72
72
|
const displayValue = hoverValue ?? internalValue;
|
|
73
73
|
const starSize = STAR_SIZES[size];
|
|
74
|
-
const isInteractive =
|
|
74
|
+
const isInteractive = enabled && !readOnly;
|
|
75
75
|
const getStarFillPercentage = (starIndex) => {
|
|
76
76
|
const starValue = starIndex + 1;
|
|
77
77
|
if (displayValue >= starValue)
|
|
@@ -82,9 +82,9 @@ function SgRatingBase(props) {
|
|
|
82
82
|
return 0;
|
|
83
83
|
};
|
|
84
84
|
return (_jsxs("div", { className: `sg-rating ${className}`, style: style, children: [label && (_jsxs("label", { htmlFor: id, className: "mb-2 block text-sm font-medium", children: [label, required && _jsx("span", { className: "ml-1 text-red-600", children: "*" })] })), _jsxs("div", { className: "flex items-center gap-1", onMouseLeave: handleMouseLeave, style: {
|
|
85
|
-
opacity:
|
|
85
|
+
opacity: !enabled ? 0.5 : 1,
|
|
86
86
|
cursor: isInteractive ? "pointer" : "default"
|
|
87
|
-
}, children: [cancel && (_jsx("button", { type: "button", onClick: handleCancel, disabled:
|
|
87
|
+
}, children: [cancel && (_jsx("button", { type: "button", onClick: handleCancel, disabled: !enabled || readOnly, className: "mr-1 transition-opacity hover:opacity-80", style: {
|
|
88
88
|
color: emptyColor,
|
|
89
89
|
cursor: isInteractive ? "pointer" : "default"
|
|
90
90
|
}, title: t(i18n, "components.rating.cancel"), children: cancelIcon ?? _jsx(CancelIcon, { size: starSize }) })), Array.from({ length: stars }).map((_, index) => {
|
|
@@ -16,7 +16,7 @@ export const sgMeta = {
|
|
|
16
16
|
{ name: "label", type: "string", description: "Rotulo do campo.", semanticRole: "label", bindable: true },
|
|
17
17
|
{ name: "value", type: "number", description: "Nota atual.", semanticRole: "value", bindable: true },
|
|
18
18
|
{ name: "readOnly", type: "boolean", default: false, description: "Impede alteracao da nota.", semanticRole: "behavior", bindable: true },
|
|
19
|
-
{ name: "
|
|
19
|
+
{ name: "enabled", type: "boolean", default: true, description: "Desabilita interacao.", semanticRole: "behavior", bindable: true },
|
|
20
20
|
{ name: "size", type: "\"sm\" | \"md\" | \"lg\" | \"xl\"", description: "Tamanho visual do controle.", semanticRole: "appearance", bindable: true },
|
|
21
21
|
{ name: "onChange", type: "(value: number) => void", description: "Callback de mudanca.", semanticRole: "event", bindable: false }
|
|
22
22
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgSlider.d.ts","sourceRoot":"","sources":["../../src/inputs/SgSlider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAiB/D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EACzC,MAAM,GACN,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,CACf,GAAG;IACF,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"SgSlider.d.ts","sourceRoot":"","sources":["../../src/inputs/SgSlider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAiB/D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EACzC,MAAM,GACN,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,CACf,GAAG;IACF,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,GAAG,aAAa,CAAC;AA2FlB,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,2CAqDtD;yBArDe,QAAQ"}
|
package/dist/inputs/SgSlider.js
CHANGED
|
@@ -34,7 +34,7 @@ function mergeInputRefs(primary, secondary) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function SgSliderBase(props) {
|
|
37
|
-
const { id, minValue, maxValue, value, defaultValue, step = 1,
|
|
37
|
+
const { id, minValue, maxValue, value, defaultValue, step = 1, enabled = true, onChange, ariaLabel, className, width, error, inputProps } = props;
|
|
38
38
|
const safeMin = Number.isFinite(minValue) ? minValue : 0;
|
|
39
39
|
const rawMax = Number.isFinite(maxValue) ? maxValue : safeMin;
|
|
40
40
|
const safeMax = Math.max(safeMin, rawMax);
|
|
@@ -47,7 +47,7 @@ function SgSliderBase(props) {
|
|
|
47
47
|
setInternalValue((prev) => clamp(prev, safeMin, safeMax));
|
|
48
48
|
}, [isControlled, safeMin, safeMax]);
|
|
49
49
|
const currentValue = clamp(isControlled ? value : internalValue, safeMin, safeMax);
|
|
50
|
-
return (_jsxs("div", { style: { width: toCssSize(width) }, children: [_jsx("input", { id: id, type: "range", min: safeMin, max: safeMax, step: safeStep, value: currentValue, disabled:
|
|
50
|
+
return (_jsxs("div", { style: { width: toCssSize(width) }, children: [_jsx("input", { id: id, type: "range", min: safeMin, max: safeMax, step: safeStep, value: currentValue, disabled: !enabled, "aria-label": ariaLabel, "aria-invalid": error ? true : undefined, onChange: (event) => {
|
|
51
51
|
const nextRaw = Number(event.currentTarget.value);
|
|
52
52
|
const next = clamp(Number.isFinite(nextRaw) ? nextRaw : safeMin, safeMin, safeMax);
|
|
53
53
|
if (!isControlled)
|
|
@@ -56,7 +56,7 @@ function SgSliderBase(props) {
|
|
|
56
56
|
inputProps?.onChange?.(event);
|
|
57
57
|
}, onBlur: (event) => {
|
|
58
58
|
inputProps?.onBlur?.(event);
|
|
59
|
-
}, className: cn("h-5 w-full cursor-pointer",
|
|
59
|
+
}, className: cn("h-5 w-full cursor-pointer", !enabled ? "cursor-not-allowed opacity-60" : "", className), ...inputProps }), error ? _jsx("p", { className: "mt-1 text-xs text-red-600", children: error }) : null] }));
|
|
60
60
|
}
|
|
61
61
|
export function SgSlider(props) {
|
|
62
62
|
const { control, name, register, rules, ...rest } = props;
|
|
@@ -17,7 +17,7 @@ export const sgMeta = {
|
|
|
17
17
|
{ name: "maxValue", type: "number", required: true, description: "Valor maximo do intervalo.", semanticRole: "validation", bindable: true },
|
|
18
18
|
{ name: "value", type: "number", description: "Valor atual controlado.", semanticRole: "value", bindable: true },
|
|
19
19
|
{ name: "step", type: "number", description: "Passo entre valores.", semanticRole: "behavior", bindable: true },
|
|
20
|
-
{ name: "
|
|
20
|
+
{ name: "enabled", type: "boolean", default: true, description: "Desabilita interacao.", semanticRole: "behavior", bindable: true },
|
|
21
21
|
{ name: "width", type: "number | string", description: "Largura do componente.", semanticRole: "appearance", bindable: true },
|
|
22
22
|
{ name: "onChange", type: "(value: number) => void", description: "Callback de mudanca.", semanticRole: "event", bindable: false }
|
|
23
23
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type RhfFieldProps } from "../rhf";
|
|
3
|
-
type StepperInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "id" | "min" | "max" | "step" | "value" | "defaultValue" | "
|
|
3
|
+
type StepperInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "id" | "min" | "max" | "step" | "value" | "defaultValue" | "readOnly" | "aria-label"> & {
|
|
4
4
|
ref?: React.Ref<HTMLInputElement>;
|
|
5
5
|
};
|
|
6
6
|
export type SgStepperInputProps = {
|
|
@@ -10,7 +10,7 @@ export type SgStepperInputProps = {
|
|
|
10
10
|
step?: number;
|
|
11
11
|
value?: number;
|
|
12
12
|
defaultValue?: number;
|
|
13
|
-
|
|
13
|
+
enabled?: boolean;
|
|
14
14
|
readOnly?: boolean;
|
|
15
15
|
onChange?: (value: number) => void;
|
|
16
16
|
ariaLabel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgStepperInput.d.ts","sourceRoot":"","sources":["../../src/inputs/SgStepperInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAkB/D,KAAK,iBAAiB,GAAG,IAAI,CAC3B,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EACzC,MAAM,GACN,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,cAAc,GACd,UAAU,GACV,
|
|
1
|
+
{"version":3,"file":"SgStepperInput.d.ts","sourceRoot":"","sources":["../../src/inputs/SgStepperInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAkB/D,KAAK,iBAAiB,GAAG,IAAI,CAC3B,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EACzC,MAAM,GACN,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,CACf,GAAG;IACF,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC,GAAG,aAAa,CAAC;AAoJlB,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,2CAqDlE;yBArDe,cAAc"}
|
|
@@ -36,7 +36,7 @@ function mergeInputRefs(primary, secondary) {
|
|
|
36
36
|
}
|
|
37
37
|
function SgStepperInputBase(props) {
|
|
38
38
|
const i18n = useComponentsI18n();
|
|
39
|
-
const { id, minValue, maxValue, step = 1, value, defaultValue,
|
|
39
|
+
const { id, minValue, maxValue, step = 1, value, defaultValue, enabled = true, readOnly = false, onChange, ariaLabel, className, inputClassName, width, error, inputProps } = props;
|
|
40
40
|
const safeMin = Number.isFinite(minValue) ? minValue : 0;
|
|
41
41
|
const rawMax = Number.isFinite(maxValue) ? maxValue : safeMin;
|
|
42
42
|
const safeMax = Math.max(safeMin, rawMax);
|
|
@@ -55,9 +55,9 @@ function SgStepperInputBase(props) {
|
|
|
55
55
|
setInternalValue(next);
|
|
56
56
|
onChange?.(next);
|
|
57
57
|
}, [isControlled, onChange, safeMax, safeMin]);
|
|
58
|
-
const canDecrease =
|
|
59
|
-
const canIncrease =
|
|
60
|
-
return (_jsxs("div", { style: { width: toCssSize(width) }, children: [_jsxs("div", { className: cn("inline-flex h-10 w-full overflow-hidden rounded-md border border-border bg-background",
|
|
58
|
+
const canDecrease = enabled && !readOnly && currentValue > safeMin;
|
|
59
|
+
const canIncrease = enabled && !readOnly && currentValue < safeMax;
|
|
60
|
+
return (_jsxs("div", { style: { width: toCssSize(width) }, children: [_jsxs("div", { className: cn("inline-flex h-10 w-full overflow-hidden rounded-md border border-border bg-background", !enabled ? "opacity-60" : "", error ? "border-[hsl(var(--destructive))]" : "", className), children: [_jsx("input", { id: id, type: "number", min: safeMin, max: safeMax, step: safeStep, value: currentValue, disabled: !enabled, readOnly: readOnly, "aria-label": ariaLabel, "aria-invalid": error ? true : undefined, onChange: (event) => {
|
|
61
61
|
const inputNext = Number(event.currentTarget.value);
|
|
62
62
|
if (!Number.isFinite(inputNext))
|
|
63
63
|
return;
|
|
@@ -18,7 +18,7 @@ export const sgMeta = {
|
|
|
18
18
|
{ name: "step", type: "number", default: 1, description: "Incremento e decremento aplicados.", semanticRole: "behavior", bindable: true },
|
|
19
19
|
{ name: "value", type: "number", description: "Valor atual controlado.", semanticRole: "value", bindable: true },
|
|
20
20
|
{ name: "readOnly", type: "boolean", default: false, description: "Permite visualizacao sem edicao direta.", semanticRole: "behavior", bindable: true },
|
|
21
|
-
{ name: "
|
|
21
|
+
{ name: "enabled", type: "boolean", default: true, description: "Desabilita interacao.", semanticRole: "behavior", bindable: true },
|
|
22
22
|
{ name: "onChange", type: "(value: number) => void", description: "Callback de mudanca.", semanticRole: "event", bindable: false }
|
|
23
23
|
],
|
|
24
24
|
states: ["default", "disabled", "readOnly", "error"],
|
|
@@ -18,7 +18,7 @@ export type SgTextEditorProps = {
|
|
|
18
18
|
onLoad?: (meta: SgTextEditorSaveMeta) => void;
|
|
19
19
|
height?: number;
|
|
20
20
|
placeholder?: string;
|
|
21
|
-
|
|
21
|
+
enabled?: boolean;
|
|
22
22
|
borderRadius?: number | string;
|
|
23
23
|
showCssEditor?: boolean;
|
|
24
24
|
cssEditorLabel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgTextEditor.d.ts","sourceRoot":"","sources":["../../src/inputs/SgTextEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AA4B/D,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAE9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"SgTextEditor.d.ts","sourceRoot":"","sources":["../../src/inputs/SgTextEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AA4B/D,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAE9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,aAAa,CAAC;AA+clB,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAsB9D;yBAtBe,YAAY"}
|
|
@@ -72,7 +72,7 @@ function canRun(editor, fn) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
function SgTextEditorBase(props) {
|
|
75
|
-
const { id, valueHtml, defaultValueHtml, onChangeHtml, cssText = "", onCssTextChange, fileName, onSave, onLoad, height = 320, placeholder: placeholderProp,
|
|
75
|
+
const { id, valueHtml, defaultValueHtml, onChangeHtml, cssText = "", onCssTextChange, fileName, onSave, onLoad, height = 320, placeholder: placeholderProp, enabled = true, borderRadius, showCssEditor = false, cssEditorLabel: cssEditorLabelProp, className, style, error } = props;
|
|
76
76
|
const i18n = useComponentsI18n();
|
|
77
77
|
const placeholder = placeholderProp ?? t(i18n, "components.textEditor.placeholder");
|
|
78
78
|
const cssEditorLabel = cssEditorLabelProp ?? t(i18n, "components.textEditor.cssEditorLabel");
|
|
@@ -85,7 +85,7 @@ function SgTextEditorBase(props) {
|
|
|
85
85
|
const isControlled = typeof valueHtml === "string";
|
|
86
86
|
const editor = useEditor({
|
|
87
87
|
immediatelyRender: false,
|
|
88
|
-
editable:
|
|
88
|
+
editable: enabled,
|
|
89
89
|
extensions: [
|
|
90
90
|
StarterKit.configure({ codeBlock: {} }),
|
|
91
91
|
Underline,
|
|
@@ -104,7 +104,7 @@ function SgTextEditorBase(props) {
|
|
|
104
104
|
attributes: {
|
|
105
105
|
id,
|
|
106
106
|
"aria-label": editorAriaLabel,
|
|
107
|
-
class: cn("prose max-w-none focus:outline-none min-h-[120px]",
|
|
107
|
+
class: cn("prose max-w-none focus:outline-none min-h-[120px]", !enabled ? "opacity-60" : ""),
|
|
108
108
|
"data-placeholder": placeholder
|
|
109
109
|
}
|
|
110
110
|
},
|
|
@@ -161,7 +161,7 @@ function SgTextEditorBase(props) {
|
|
|
161
161
|
const cssTextareaStyle = resolvedBorderRadius
|
|
162
162
|
? { borderRadius: resolvedBorderRadius }
|
|
163
163
|
: undefined;
|
|
164
|
-
return (_jsxs("div", { className: cn("w-full", className), style: style, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2 rounded-t-lg border border-b-0 bg-background p-2", style: toolbarStyle, children: [_jsxs("select", { className: "h-9 rounded-md border px-2 text-sm bg-background", disabled: !editor ||
|
|
164
|
+
return (_jsxs("div", { className: cn("w-full", className), style: style, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2 rounded-t-lg border border-b-0 bg-background p-2", style: toolbarStyle, children: [_jsxs("select", { className: "h-9 rounded-md border px-2 text-sm bg-background", disabled: !editor || !enabled, value: active("heading", { level: 1 })
|
|
165
165
|
? "h1"
|
|
166
166
|
: active("heading", { level: 2 })
|
|
167
167
|
? "h2"
|
|
@@ -180,17 +180,17 @@ function SgTextEditorBase(props) {
|
|
|
180
180
|
editor.commands.toggleHeading({ level: 2 });
|
|
181
181
|
if (v === "h3")
|
|
182
182
|
editor.commands.toggleHeading({ level: 3 });
|
|
183
|
-
}, children: [_jsx("option", { value: "h1", children: t(i18n, "components.textEditor.toolbar.heading") }), _jsx("option", { value: "h2", children: t(i18n, "components.textEditor.toolbar.subheading") }), _jsx("option", { value: "p", children: t(i18n, "components.textEditor.toolbar.normal") }), _jsx("option", { value: "h3", children: t(i18n, "components.textEditor.toolbar.heading3") })] }), _jsxs("select", { className: "h-9 rounded-md border px-2 text-sm bg-background", disabled: !editor ||
|
|
183
|
+
}, children: [_jsx("option", { value: "h1", children: t(i18n, "components.textEditor.toolbar.heading") }), _jsx("option", { value: "h2", children: t(i18n, "components.textEditor.toolbar.subheading") }), _jsx("option", { value: "p", children: t(i18n, "components.textEditor.toolbar.normal") }), _jsx("option", { value: "h3", children: t(i18n, "components.textEditor.toolbar.heading3") })] }), _jsxs("select", { className: "h-9 rounded-md border px-2 text-sm bg-background", disabled: !editor || !enabled, onChange: (e) => {
|
|
184
184
|
const v = e.target.value;
|
|
185
185
|
if (!editor)
|
|
186
186
|
return;
|
|
187
187
|
editor.chain().focus().setFontFamily(v).run();
|
|
188
|
-
}, defaultValue: "inherit", children: [_jsx("option", { value: "inherit", children: t(i18n, "components.textEditor.toolbar.defaultFont") }), _jsx("option", { value: "Arial", children: "Arial" }), _jsx("option", { value: "Georgia", children: "Georgia" }), _jsx("option", { value: "Times New Roman", children: "Times" }), _jsx("option", { value: "Courier New", children: "Courier" })] }), _jsxs("select", { className: "h-9 rounded-md border px-2 text-sm bg-background", disabled: !editor ||
|
|
188
|
+
}, defaultValue: "inherit", children: [_jsx("option", { value: "inherit", children: t(i18n, "components.textEditor.toolbar.defaultFont") }), _jsx("option", { value: "Arial", children: "Arial" }), _jsx("option", { value: "Georgia", children: "Georgia" }), _jsx("option", { value: "Times New Roman", children: "Times" }), _jsx("option", { value: "Courier New", children: "Courier" })] }), _jsxs("select", { className: "h-9 rounded-md border px-2 text-sm bg-background", disabled: !editor || !enabled, defaultValue: "16px", onChange: (e) => {
|
|
189
189
|
const size = e.target.value;
|
|
190
190
|
if (!editor)
|
|
191
191
|
return;
|
|
192
192
|
editor.chain().focus().setMark("textStyle", { fontSize: size }).run();
|
|
193
|
-
}, children: [_jsx("option", { value: "12px", children: "12" }), _jsx("option", { value: "14px", children: "14" }), _jsx("option", { value: "16px", children: "16" }), _jsx("option", { value: "18px", children: "18" }), _jsx("option", { value: "24px", children: "24" }), _jsx("option", { value: "32px", children: "32" })] }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.bold"), icon: _jsx("span", { className: "font-bold leading-none", "aria-hidden": "true", children: "B" }), active: active("bold"),
|
|
193
|
+
}, children: [_jsx("option", { value: "12px", children: "12" }), _jsx("option", { value: "14px", children: "14" }), _jsx("option", { value: "16px", children: "16" }), _jsx("option", { value: "18px", children: "18" }), _jsx("option", { value: "24px", children: "24" }), _jsx("option", { value: "32px", children: "32" })] }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.bold"), icon: _jsx("span", { className: "font-bold leading-none", "aria-hidden": "true", children: "B" }), active: active("bold"), enabled: !(!canRun(editor, (ed) => ed.can().chain().focus().toggleBold().run()) || !enabled), onClick: () => exec(() => editor.chain().toggleBold().run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.italic"), icon: _jsx("span", { className: "italic leading-none", "aria-hidden": "true", children: "I" }), active: active("italic"), enabled: !(!canRun(editor, (ed) => ed.can().chain().focus().toggleItalic().run()) || !enabled), onClick: () => exec(() => editor.chain().toggleItalic().run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.underline"), icon: _jsx("span", { className: "underline leading-none", "aria-hidden": "true", children: "U" }), active: active("underline"), enabled: !(!canRun(editor, (ed) => ed.can().chain().focus().toggleUnderline().run()) || !enabled), onClick: () => exec(() => editor.chain().toggleUnderline().run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.strike"), icon: _jsx("span", { className: "line-through leading-none", "aria-hidden": "true", children: "S" }), active: active("strike"), enabled: !(!canRun(editor, (ed) => ed.can().chain().focus().toggleStrike().run()) || !enabled), onClick: () => exec(() => editor.chain().toggleStrike().run()) }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ColorPickerButton, { label: t(i18n, "components.textEditor.toolbar.textColor"), hint: t(i18n, "components.textEditor.toolbar.textColor"), icon: _jsx(Palette, { size: 14, "aria-hidden": "true" }), enabled: !(!editor || !enabled), onChange: (color) => editor?.chain().focus().setColor(color).run() }), _jsx(ColorPickerButton, { label: t(i18n, "components.textEditor.toolbar.highlightColor"), hint: t(i18n, "components.textEditor.toolbar.highlightColor"), icon: _jsx(Highlighter, { size: 14, "aria-hidden": "true" }), enabled: !(!editor || !enabled), onChange: (color) => editor?.chain().focus().toggleHighlight({ color }).run() }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.subscript"), text: "x2", active: active("subscript"), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().toggleSubscript().run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.superscript"), text: "x^", active: active("superscript"), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().toggleSuperscript().run()) }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.bullets"), icon: _jsx(List, { size: 14, "aria-hidden": "true" }), active: active("bulletList"), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().toggleBulletList().run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.numbered"), icon: _jsx(ListOrdered, { size: 14, "aria-hidden": "true" }), active: active("orderedList"), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().toggleOrderedList().run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.outdent"), icon: _jsx(IndentDecrease, { size: 14, "aria-hidden": "true" }), active: false, enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().liftListItem("listItem").run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.indent"), icon: _jsx(IndentIncrease, { size: 14, "aria-hidden": "true" }), active: false, enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().sinkListItem("listItem").run()) }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.alignLeft"), icon: _jsx(AlignLeft, { size: 14, "aria-hidden": "true" }), active: active("paragraph", { textAlign: "left" }) || active("heading", { textAlign: "left" }), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().setTextAlign("left").run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.alignCenter"), icon: _jsx(AlignCenter, { size: 14, "aria-hidden": "true" }), active: active("paragraph", { textAlign: "center" }) || active("heading", { textAlign: "center" }), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().setTextAlign("center").run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.alignRight"), icon: _jsx(AlignRight, { size: 14, "aria-hidden": "true" }), active: active("paragraph", { textAlign: "right" }) || active("heading", { textAlign: "right" }), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().setTextAlign("right").run()) }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.justify"), icon: _jsx(AlignJustify, { size: 14, "aria-hidden": "true" }), active: active("paragraph", { textAlign: "justify" }) || active("heading", { textAlign: "justify" }), enabled: !(!editor || !enabled), onClick: () => exec(() => editor.chain().setTextAlign("justify").run()) }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.link"), text: t(i18n, "components.textEditor.toolbar.link"), active: active("link"), enabled: !(!editor || !enabled), onClick: () => {
|
|
194
194
|
if (!editor)
|
|
195
195
|
return;
|
|
196
196
|
const prev = editor.getAttributes("link").href;
|
|
@@ -200,18 +200,18 @@ function SgTextEditorBase(props) {
|
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
editor.chain().focus().setLink({ href: url }).run();
|
|
203
|
-
} }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.image"), icon: _jsx(FileImage, { size: 14, "aria-hidden": "true" }), active: false,
|
|
203
|
+
} }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.image"), icon: _jsx(FileImage, { size: 14, "aria-hidden": "true" }), active: false, enabled: !(!editor || !enabled), onClick: () => {
|
|
204
204
|
if (!editor)
|
|
205
205
|
return;
|
|
206
206
|
const src = window.prompt(t(i18n, "components.textEditor.prompt.imageUrl"));
|
|
207
207
|
if (!src)
|
|
208
208
|
return;
|
|
209
209
|
editor.chain().focus().setImage({ src }).run();
|
|
210
|
-
} }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.clear"), text: "X", active: false,
|
|
210
|
+
} }), _jsx("div", { className: "mx-1 h-6 w-px bg-border" }), _jsx(ToolbarButton, { label: t(i18n, "components.textEditor.toolbar.clear"), text: "X", active: false, enabled: !(!editor || !enabled), onClick: () => {
|
|
211
211
|
if (!editor)
|
|
212
212
|
return;
|
|
213
213
|
editor.chain().focus().unsetAllMarks().clearNodes().run();
|
|
214
|
-
} }), _jsxs("div", { className: "ml-auto flex items-center gap-2", children: [_jsx("button", { type: "button", className: "h-9 rounded-md border bg-muted px-3 text-sm hover:bg-muted/80 disabled:opacity-50", disabled: !editor ||
|
|
214
|
+
} }), _jsxs("div", { className: "ml-auto flex items-center gap-2", children: [_jsx("button", { type: "button", className: "h-9 rounded-md border bg-muted px-3 text-sm hover:bg-muted/80 disabled:opacity-50", disabled: !editor || !enabled, onClick: doSave, children: t(i18n, "components.actions.save") }), _jsxs("label", { className: "h-9 cursor-pointer rounded-md border bg-muted px-3 text-sm leading-9 hover:bg-muted/80", children: [t(i18n, "components.actions.loadHtml"), _jsx("input", { type: "file", accept: "text/html,.html", className: "hidden", onChange: (e) => {
|
|
215
215
|
const f = e.target.files?.[0];
|
|
216
216
|
if (!f)
|
|
217
217
|
return;
|
|
@@ -227,11 +227,11 @@ export function SgTextEditor(props) {
|
|
|
227
227
|
return _jsx(SgTextEditorBase, { ...rest });
|
|
228
228
|
}
|
|
229
229
|
function ToolbarButton(props) {
|
|
230
|
-
const { label, text, icon, active,
|
|
231
|
-
return (_jsx("button", { type: "button", title: label, "aria-label": label, disabled:
|
|
230
|
+
const { label, text, icon, active, enabled = true, onClick } = props;
|
|
231
|
+
return (_jsx("button", { type: "button", title: label, "aria-label": label, disabled: !enabled, onClick: onClick, className: cn("inline-flex h-9 min-w-9 items-center justify-center rounded-md border px-2 text-sm", "hover:bg-muted/80 disabled:opacity-50", active ? "bg-muted" : "bg-background"), children: icon ?? text }));
|
|
232
232
|
}
|
|
233
233
|
function ColorPickerButton(props) {
|
|
234
|
-
const { label, hint, icon,
|
|
235
|
-
return (_jsxs("label", { title: hint ?? label, "aria-label": label, className: cn("relative inline-flex h-9 min-w-9 items-center justify-center rounded-md border px-2 text-sm", "bg-background hover:bg-muted/80",
|
|
234
|
+
const { label, hint, icon, enabled = true, onChange } = props;
|
|
235
|
+
return (_jsxs("label", { title: hint ?? label, "aria-label": label, className: cn("relative inline-flex h-9 min-w-9 items-center justify-center rounded-md border px-2 text-sm", "bg-background hover:bg-muted/80", !enabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"), children: [icon, _jsx("input", { type: "color", disabled: !enabled, onChange: (e) => onChange(e.target.value), className: cn("absolute inset-0 h-full w-full opacity-0", !enabled ? "cursor-not-allowed" : "cursor-pointer"), "aria-label": label })] }));
|
|
236
236
|
}
|
|
237
237
|
SgTextEditor.displayName = "SgTextEditor";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgYearPartSelector.d.ts","sourceRoot":"","sources":["../../src/inputs/SgYearPartSelector.tsx"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EAMZ,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,oFAAoF;IACpF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAChD,wFAAwF;IACxF,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"SgYearPartSelector.d.ts","sourceRoot":"","sources":["../../src/inputs/SgYearPartSelector.tsx"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EAMZ,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,oFAAoF;IACpF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAChD,wFAAwF;IACxF,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA2BF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,2CA4J1E"}
|
|
@@ -19,7 +19,7 @@ function pickLocale(map, locale) {
|
|
|
19
19
|
const DEFAULT_KIND = YearPartKind.SEMESTER;
|
|
20
20
|
const ALL_KINDS = [DEFAULT_KIND, YearPartKind.QUARTER, YearPartKind.BIMESTER];
|
|
21
21
|
export function SgYearPartSelector(props) {
|
|
22
|
-
const { id = "sg-year-part-selector", label, value, onChange, allowedKinds, minYear, maxYear, locale = "pt-BR",
|
|
22
|
+
const { id = "sg-year-part-selector", label, value, onChange, allowedKinds, minYear, maxYear, locale = "pt-BR", enabled = true, required, className } = props;
|
|
23
23
|
// Array vazio cai no default: um combo de recorte sem opcao nenhuma seria controle morto na tela.
|
|
24
24
|
const kinds = React.useMemo(() => (allowedKinds && allowedKinds.length > 0 ? allowedKinds : ALL_KINDS), [allowedKinds]);
|
|
25
25
|
const isControlled = value !== undefined;
|
|
@@ -63,7 +63,6 @@ export function SgYearPartSelector(props) {
|
|
|
63
63
|
// Depende do recorte: trocar de trimestre para semestre troca 4 opcoes por 2.
|
|
64
64
|
const partItems = React.useMemo(() => yearPartOptions(current.kind, locale).map((option) => ({ id: option.value, label: option.label })), [current.kind, locale]);
|
|
65
65
|
const showKind = kinds.length > 1;
|
|
66
|
-
const enabled = disabled ? false : undefined;
|
|
67
66
|
/*
|
|
68
67
|
* Flex em vez de grid de 3 colunas: com o combo de recorte escondido a linha reflui para dois
|
|
69
68
|
* controles, em vez de deixar uma coluna vazia no meio.
|
|
@@ -28,7 +28,7 @@ export const sgMeta = {
|
|
|
28
28
|
{ name: "minYear", type: "number", default: "ano corrente - 30", description: "Primeiro ano oferecido na lista de anos.", semanticRole: "behavior", bindable: true },
|
|
29
29
|
{ name: "maxYear", type: "number", default: "ano corrente + 10", description: "Ultimo ano oferecido na lista de anos.", semanticRole: "behavior", bindable: true },
|
|
30
30
|
{ name: "locale", type: "string", default: "pt-BR", description: "Locale dos rotulos de recorte e fatia. A sigla entre parenteses acompanha o idioma: Q1..Q4 em pt-BR e en-US, T1..T4 em es, fr e pt-PT; bimestre nao tem sigla e sai sem parenteses.", semanticRole: "behavior", bindable: true },
|
|
31
|
-
{ name: "
|
|
31
|
+
{ name: "enabled", type: "boolean", default: true, description: "Desabilita os tres combos (ano, recorte e fatia).", semanticRole: "behavior", bindable: true },
|
|
32
32
|
{ name: "required", type: "boolean", default: false, description: "Marca o campo como obrigatorio.", semanticRole: "validation", bindable: true },
|
|
33
33
|
{ name: "className", type: "string", description: "Classes extras aplicadas ao container do campo.", semanticRole: "appearance", bindable: false }
|
|
34
34
|
],
|
|
@@ -44,7 +44,7 @@ export const sgMeta = {
|
|
|
44
44
|
defaultProps: {
|
|
45
45
|
allowedKinds: ["SEMESTER", "QUARTER", "BIMESTER"],
|
|
46
46
|
locale: "pt-BR",
|
|
47
|
-
|
|
47
|
+
enabled: true,
|
|
48
48
|
required: false
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type CameraFacing = "user" | "environment";
|
|
2
|
+
export type CameraGuide = "none" | "oval" | "rect";
|
|
3
|
+
export type CameraResolution = "low" | "medium" | "high";
|
|
4
|
+
export type CameraErrorCode = "permission" | "noCamera" | "failed";
|
|
5
|
+
export type GuideBox = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
/** Resolucao pedida ao dispositivo (largura x altura, paisagem). */
|
|
12
|
+
export declare function resolutionSize(resolution: CameraResolution): {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Caixa do guia de enquadramento, centralizada na area de pre-visualizacao `viewW` x `viewH` (px).
|
|
18
|
+
* `oval`: elipse em pe (largura/altura = 3/4), ate 70% da largura e 70% da altura.
|
|
19
|
+
* `rect`: retangulo deitado (largura/altura = 4/3), ate 90% da largura e 70% da altura.
|
|
20
|
+
* `none` => null. Valores arredondados ao pixel.
|
|
21
|
+
*/
|
|
22
|
+
export declare function guideBox(guide: CameraGuide, viewW: number, viewH: number): GuideBox | null;
|
|
23
|
+
/** Nome do erro da plataforma (`NotAllowedError`, `CameraAccessDenied`...) => codigo do componente. */
|
|
24
|
+
export declare function classifyCameraError(name: string): CameraErrorCode;
|
|
25
|
+
/** Alterna entre frontal (`user`) e traseira (`environment`). */
|
|
26
|
+
export declare function nextFacing(facing: CameraFacing): CameraFacing;
|
|
27
|
+
//# sourceMappingURL=cameraLogic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraLogic.d.ts","sourceRoot":"","sources":["../../src/inputs/cameraLogic.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,aAAa,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,UAAU,EAAE,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAS9F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAa1F;AAYD,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAKjE;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE7D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Logica pura do SgCameraCapture (P134): resolucao, guia de enquadramento, classificacao de erro e troca de camera.
|
|
2
|
+
// Sem DOM: os vetores de paridade com o Flutter (`seedgrid_components/test/widgets/camera_vectors`) sao gerados
|
|
3
|
+
// DESTE modulo. O contrato das props e o mesmo nas duas plataformas.
|
|
4
|
+
/** Resolucao pedida ao dispositivo (largura x altura, paisagem). */
|
|
5
|
+
export function resolutionSize(resolution) {
|
|
6
|
+
switch (resolution) {
|
|
7
|
+
case "low":
|
|
8
|
+
return { width: 640, height: 480 };
|
|
9
|
+
case "high":
|
|
10
|
+
return { width: 1920, height: 1080 };
|
|
11
|
+
default:
|
|
12
|
+
return { width: 1280, height: 720 };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Caixa do guia de enquadramento, centralizada na area de pre-visualizacao `viewW` x `viewH` (px).
|
|
17
|
+
* `oval`: elipse em pe (largura/altura = 3/4), ate 70% da largura e 70% da altura.
|
|
18
|
+
* `rect`: retangulo deitado (largura/altura = 4/3), ate 90% da largura e 70% da altura.
|
|
19
|
+
* `none` => null. Valores arredondados ao pixel.
|
|
20
|
+
*/
|
|
21
|
+
export function guideBox(guide, viewW, viewH) {
|
|
22
|
+
if (guide === "none" || viewW <= 0 || viewH <= 0)
|
|
23
|
+
return null;
|
|
24
|
+
const ratio = guide === "oval" ? 3 / 4 : 4 / 3;
|
|
25
|
+
const maxW = viewW * (guide === "oval" ? 0.7 : 0.9);
|
|
26
|
+
const maxH = viewH * 0.7;
|
|
27
|
+
const width = Math.min(maxW, maxH * ratio);
|
|
28
|
+
const height = width / ratio;
|
|
29
|
+
return {
|
|
30
|
+
x: Math.round((viewW - width) / 2),
|
|
31
|
+
y: Math.round((viewH - height) / 2),
|
|
32
|
+
width: Math.round(width),
|
|
33
|
+
height: Math.round(height)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const PERMISSION_NAMES = new Set([
|
|
37
|
+
"notallowederror",
|
|
38
|
+
"permissiondeniederror",
|
|
39
|
+
"securityerror",
|
|
40
|
+
"cameraaccessdenied",
|
|
41
|
+
"cameraaccessdeniedwithoutprompt",
|
|
42
|
+
"cameraaccessrestricted"
|
|
43
|
+
]);
|
|
44
|
+
const NO_CAMERA_NAMES = new Set(["notfounderror", "devicesnotfounderror", "nocamera", "notreadableerror_nocamera"]);
|
|
45
|
+
/** Nome do erro da plataforma (`NotAllowedError`, `CameraAccessDenied`...) => codigo do componente. */
|
|
46
|
+
export function classifyCameraError(name) {
|
|
47
|
+
const key = name.trim().toLowerCase();
|
|
48
|
+
if (PERMISSION_NAMES.has(key))
|
|
49
|
+
return "permission";
|
|
50
|
+
if (NO_CAMERA_NAMES.has(key))
|
|
51
|
+
return "noCamera";
|
|
52
|
+
return "failed";
|
|
53
|
+
}
|
|
54
|
+
/** Alterna entre frontal (`user`) e traseira (`environment`). */
|
|
55
|
+
export function nextFacing(facing) {
|
|
56
|
+
return facing === "user" ? "environment" : "user";
|
|
57
|
+
}
|