### Global Header Usage and Code Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/global-header
This snippet demonstrates the basic usage and provides a code example for the Jutro Global Header component. It outlines how to integrate the header into applications within the Guidewire Cloud ecosystem.
```jsx
import React from 'react';
import { GlobalHeader } from '@guidewire/jutro-design-system';
function App() {
return (
{/* Main application content */}
);
}
```
--------------------------------
### Guidewire Jutro Floorplan Override Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/page-layouts/appfloorplan
Provides an example of a `FloorPlanOverride` configuration in Guidewire Jutro, specifically disabling the right side navigation for the '/example2' path. This demonstrates how to customize individual page layouts.
```TypeScript
exportconst example2PageDefinition =():FloorPlanOverride{
return{
// Configuration override for the /example2 path only
showRightSide:false,
matches:'/example2'
}
}
```
--------------------------------
### Basic Switch Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/switch
Demonstrates the basic usage of the Switch component with a label. The Switch component allows users to toggle between an on and off state.
```jsx
```
--------------------------------
### Basic TooltipIcon Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/tooltip
Shows the basic implementation of the TooltipIcon component, used when a tooltip is associated with an icon. This example requires importing React and TooltipIcon from '@jutro/components'.
```javascript
import { TooltipIcon } from '@jutro/components';
import React from 'react';
export const TooltipIconBasic = () => {
return ;
};
```
--------------------------------
### useBreakpoint: Get All Returned Values
Source: https://docs.guidewire.com/jutro/documentation/10.11/responsiveness
This comprehensive example demonstrates retrieving all values from the `useBreakpoint` hook: `breakpointProps`, `breakpoint`, and `applyBreakpoint`. It shows how to use each of these to conditionally style and render `TextInput` components.
```javascript
const{
breakpointProps: textInputPhoneProps,
breakpoint,
applyBreakpoint,
}=useBreakpoint({
phone:{
placeholder:'Phone placeholder',
label:'Phone label',
className:'somePhoneClass',
},
});
return(
);
```
--------------------------------
### Basic Phase Progress Bar Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/progress-indicator-phase-bar
This example demonstrates a static Phase Progress Bar with predefined phases and steps. It shows how to structure the `phases` array, including icons, titles, and step visitation status, to represent completed and current progress.
```jsx
```
--------------------------------
### Typography Component Usage Examples
Source: https://docs.guidewire.com/jutro/documentation/10.11/typography-component
Demonstrates various ways to use the typography component with different variants and semantic tags. Includes examples for headings, body text, blockquotes, and separating visual style from semantic structure.
```html
Page TitleThis is a paragraph of text.Form Field LabelContextual text above headingMarketing HeadlineThis is a quoted text.Caption for an image.Inline code snippetThis is an h2 that is formatted to have medium text.This is a blockquote that is formatted to have the visual weight of a heading.
```
--------------------------------
### Render Badge Component
Source: https://docs.guidewire.com/jutro/documentation/10.11/badge
Demonstrates how to render the Badge component with a specified value. This is a basic usage example.
```HTML
```
--------------------------------
### Basic Loader Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/loader
A basic loader that displays a Guidewire branded animation until its children are ready. The children can be shown by setting the `loaded` property to `true` or by providing a `Promise`.
```HTML
Incoming content
```
--------------------------------
### Example Heading Structure
Source: https://docs.guidewire.com/jutro/documentation/10.11/building-accessible-experiences
Illustrates a hierarchical heading structure for clear document organization, prioritizing accessibility for screen reader users. This example demonstrates the correct nesting of heading levels from h1 to h6.
```HTML
Main Heading
Section 1
Subsection 1.1
Subsection 1.2
Section 2
Subsection 2.1
Sub-subsection 2.1.1
```
--------------------------------
### Basic HeaderPanel Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/page-layouts/components/header-panel
Demonstrates the basic structure of the HeaderPanel component, which wraps content to designate page header elements. It includes a sample heading within the panel.
```HTML
Sample heading text
```
--------------------------------
### Select Dropdown Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/drop-downs-overall
Demonstrates the implementation of a single-select dropdown component. It requires a label and initial value, and accepts SelectOption children for the available choices.
```jsx
```
--------------------------------
### Text Input Validation Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/text
Provides an example of implementing custom validation logic for the TextInput component. It uses the 'onChange' event and 'stateMessages' prop to handle and display validation errors.
```javascript
functionTextInputValidation(){
const[validationMessages, setValidationMessages]=useState({});
const onChange =useCallback((e, newValue)=>{
if(!newValue || newValue.indexOf('a')==-1){
setValidationMessages({});
}else{
setValidationMessages({
error:['The text cannot contain `a` character'],
});
}
},[]);
return(
);
}
```
--------------------------------
### Generic Alert Modal Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/modal-component
Provides an example of triggering a generic Alert modal using `showAlert` from `ModalNextContext`. It includes state management to capture the modal's result and demonstrates how to configure various alert properties like status, icon, title, message, and confirm button text.
```javascript
import React, { useState, useContext } from 'react';
import { ModalNextContext } from '@jutro/components';
const AlertModalExample = () => {
const [result, setResult] = useState(null);
const { showAlert } = useContext(ModalNextContext);
async function triggerAlert() {
const results = await showAlert({
status: 'info' /* status - 'info', 'warning', 'error', or 'success' */,
icon: 'gw-error-outline' /* icon - optional icon class name for the icon to display to the left of the title */,
title:
'Test Alert' /* title - string/IntlMessageShape for the title of the alert */,
message:
'Just testing an Alert!' /* message - string/IntlMessageShape for the message to display within the alert */,
confirmButtonText:
'OK' /* confirmButtonText - string/IntlMessageShape for the text to appear on the confirm button */,
});
setResult(`modal result was: ${results}`);
}
return (
{result}
);
};
```
--------------------------------
### Start Development Server with Live Preview
Source: https://docs.guidewire.com/jutro/documentation/10.11/i18n
Starts the application in live preview mode, allowing immediate reflection of code changes in the browser. Note that changes to existing source strings require a re-run of the extract-merge-pseudo cycle (`npm run i18n`) to be reflected.
```bash
npm start
```
--------------------------------
### Render InfoLabel Component
Source: https://docs.guidewire.com/jutro/documentation/10.11/info-label
This snippet shows how to render the InfoLabel component with basic content. It's a fundamental example of integrating the component into a UI.
```html
Lorem ipsum
```
--------------------------------
### Basic Checkbox Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/checkboxes
Demonstrates the usage of a single Checkbox component with a label. This component can be used independently.
```HTML
```
--------------------------------
### Jutro Unit Testing Examples
Source: https://docs.guidewire.com/jutro/documentation/10.11/testing-overview
Unit tests in Jutro verify the functionality of small, isolated parts of the application. Examples include checking for rendering without errors, validating metadata-based components, testing string manipulation functions, verifying callback invocations, and ensuring side effects are triggered correctly.
```javascript
// Example: Check if an app renders without crashing
it('should render without crashing', () => {
// Assume App is your root component
render();
});
// Example: Check if a metadata-based component has valid metadata
it('should have valid metadata', () => {
const component = render();
// Assertions for valid metadata
});
// Example: Test a function that shortens strings
it('should shorten long descriptions correctly', () => {
const longString = 'This is a very long description that needs to be shortened.';
const maxLength = 20;
const shortenedString = shortenString(longString, maxLength);
expect(shortenedString.length).toBeLessThanOrEqual(maxLength);
expect(shortenedString).toBe('This is a very lon...');
});
// Example: Check if a callback is called
it('should call the callback function', () => {
const mockCallback = jest.fn();
render();
// Simulate an event that triggers the callback
// e.g., fireEvent.click(screen.getByRole('button'));
expect(mockCallback).toHaveBeenCalledTimes(1);
});
// Example: Check if a side effect is triggered the appropriate number of times
it('should trigger side effect twice', () => {
const mockSideEffect = jest.fn();
render();
expect(mockSideEffect).toHaveBeenCalledTimes(1);
});
```
--------------------------------
### Basic Accordion Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/accordion
Demonstrates the basic structure of an Accordion component with multiple AccordionCard items. Shows how to set titles and initial expanded states.
```HTML
Test card
Card initially open
Test card 3
```
--------------------------------
### React Confirmation Modal Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/modal-component
This React component demonstrates how to use the `showConfirm` function from `ModalNextContext` to display a generic confirmation modal. It allows customization of the modal's status, icon, title, message, and button text. The example captures the modal's result and displays it to the user.
```javascript
import React, { useState, useContext } from 'react';
import { ModalNextContext } from '@jutro/components';
const ConfirmationModalExample = () => {
const [result, setResult] = useState(null);
const { showConfirm } = useContext(ModalNextContext);
async function triggerConfirmation() {
const results = await showConfirm({
status: 'info', /* status - 'info', 'warning', 'error', or 'success' */
icon: 'gw-error-outline', /* icon - optional icon class name for the icon to display to the left of the title */
title:
'Test Confirm Modal', /* title - string/IntlMessageShape for the title of the confirm modal */
message:
'Just testing a Confirmation Modal!', /* message - string/IntlMessageShape for the message to display within the confirm modal */
confirmButtonText:
'OK', /* confirmButtonText - string/IntlMessageShape for the text to appear on the confirm button */
cancelButtonText:
'Cancel', /* cancelButtonText - string/IntlMessageShape for the text to appear on the cancel button */
});
setResult(`modal result was: ${results}`);
}
return (
{result}
);
};
```
--------------------------------
### Basic Tag Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/tags
A basic tag displays a label formatted to be recognized by the reader. It's a simple string with designated styling.
```HTML
```
--------------------------------
### Switch Component Usage
Source: https://docs.guidewire.com/jutro/documentation/10.11/switch
Demonstrates the basic usage of the Switch component with a label. This is a fundamental example for integrating the Switch into an application.
```jsx
```
--------------------------------
### Basic Overflow Menu Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/overflow-menu
Demonstrates how to create a simple overflow menu using the DropdownMenu component. The trigger is a Button that toggles the menu when clicked.
```jsx
{
return(
```
--------------------------------
### Combobox with User Input Filtering
Source: https://docs.guidewire.com/jutro/documentation/10.11/drop-downs-combobox
Demonstrates how to use the Combobox component with the `useFilteredOptions` hook to filter options based on user input. This example shows a basic setup for a searchable dropdown.
```javascript
exportfunctionComboWithFilter(){
constCHARACTERS=[
{id:'1',label:'Anakin Skywalker'},
{id:'2',label:'Luke Skywalker'},
{id:'3',label:'Master Yoda'},
{id:'4',label:'Han Solo'},
];
const{ filteredOptions, onSearch, resetFilter }=
useFilteredOptions(CHARACTERS);
return(
{filteredOptions.map(({ id, label })=>(
))}
);
}
```
--------------------------------
### AppFloorPlan Basic Configuration Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/floorplans-layouts
Demonstrates the usage of the AppFloorPlan component's props, including how to pass floorplan configurations via the `floorPlans` property. It highlights the need for a `$schema` path in the floorplan JSON for validation and mentions the `rightSide` prop for defining the right panel's content.
```javascript
import React from 'react';
import AppFloorPlan from '@guidewire/jutro';
const floorPlanConfig = {
// Floorplan configuration details...
};
const App = () => (
);
export default App;
```
```json
{
"$schema": "/path/to/your/floorplan-schema.json",
"routes": [
// ... route definitions
],
"rightSide": {
// ... right panel presentation metadata
}
}
```
--------------------------------
### Guidewire Jutro AppFloorPlan Initialization
Source: https://docs.guidewire.com/jutro/documentation/10.11/page-layouts/appfloorplan
Shows how to initialize the `AppFloorPlan` component in Guidewire Jutro with an array of floorplan configurations, including default and overridden settings. This example renders the application's main layout.
```JSX
exportfunctionJutro():JSX.Element{
return;
}
```
--------------------------------
### Jutro Toggle Button Group Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/toggle-button
This code snippet demonstrates how to implement a ToggleButtonGroup with two ToggleButton options, 'Yes' and 'No'. It includes basic setup for labels and values.
```jsx
```
--------------------------------
### MultipleCombobox with Filtering and Initial Values Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/drop-downs-overall
Demonstrates a MultipleCombobox component that allows filtering and pre-selection of options. It uses the `useFilteredOptions` hook and accepts an array of initial values.
```jsx
exportfunctionMultipleComboWithFilteAndInitial(){
constCHARACTERS=[
{id:'1',label:'Anakin Skywalker'},
{id:'2',label:'Luke Skywalker'},
{id:'3',label:'Master Yoda'},
{id:'4',label:'Han Solo'},
];
const{ filteredOptions, onSearch, resetFilter }=
useFilteredOptions(CHARACTERS);
return(
{filteredOptions.map(({ id, label })=>(
))}
);
}
```
--------------------------------
### Position Grid Items with colStart and rowStart
Source: https://docs.guidewire.com/jutro/documentation/10.11/grid
Explains and shows how to use `colStart` and `rowStart` props on `GridItem` to precisely position items within the grid. This example demonstrates complex layouts by combining spanning and starting positions.
```jsx
import{Grid,GridItem}from`@jutro/layout`;
First ItemSecond ItemThird ItemFourth ItemFifth Item
```
--------------------------------
### AppFloorPlan Basic Configuration
Source: https://docs.guidewire.com/jutro/documentation/10.11/page-layouts/appfloorplan
Demonstrates the basic usage of the AppFloorPlan component with header, left and right panels, and navigation routes. It utilizes props like `showHeader`, `header`, `showLeftSide`, `leftSide`, `sideRoutes`, `showRightSide`, `rightSide`, and `showFooter` to define the page layout. The example includes custom components for page content and side panel content.
```javascript
import React from 'react';
import { AppFloorPlan } from '@jutro/floorplan';
import { FloorPlan } from '@jutro/floorplan';
import { ChatIcon, MailIcon } from '@jutro/icons';
import { Card } from '@jutro/components';
export const floorPlanDefinition = (): FloorPlan => {
return {
showHeader: true,
header: {
showNotifications: true,
logoSrc: './images/guidewire-logo-dark.svg',
logoTitle: 'Guidewire',
showHelp: true,
showAppSwitcher: true,
showLanguageSelector: false,
},
showSubHeader: false,
showLeftSide: true,
leftSide: {
collapsible: true,
},
sideRoutes: [
{
path: '/',
exact: true,
showOnNavBar: false,
redirect: '/example',
},
{
title: 'Example page',
path: '/example',
exact: true,
component: PageExample,
},
{
title: 'Example page 2',
path: '/example2',
exact: true,
component: PageExample,
},
],
showRightSide: true,
rightSide: {
collapsible: true,
isInitiallyCollapsed: true,
sides: [
{
label: "Open chat",
icon: ChatIcon,
component: RightSideExample,
},
{
label: "Email",
icon: MailIcon,
component: RightSideExample,
}
],
},
showFooter: false,
};
};
export function Jutro(): JSX.Element {
return ;
}
const PageExample = (): JSX.Element => {
return
}
const RightSideExample = (): JSX.Element => {
return
}
```
--------------------------------
### Align Grid Items Individually with alignSelf
Source: https://docs.guidewire.com/jutro/documentation/10.11/grid
Shows how to use the `alignSelf` property on individual `GridItem` components to control their vertical alignment within the grid. Examples include stretch, center, start, end, and baseline alignment.
```jsx
import{Grid,GridItem}from'@jutro/layout';
alignSelf='stretch'
alignSelf='center'alignSelf='start'alignSelf='end'alignSelf='baseline'
```
--------------------------------
### Jutro Components Import Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/api-surface
Demonstrates correct and incorrect import statements for Jutro components. It highlights that only direct exports from defined entry points are part of the contract, and importing from internal type definitions is not supported.
```JavaScript
import{ intlMessageShape }from'@jutro/components/types/types';
```
```JavaScript
import{Button}from'@jutro/components';
```
--------------------------------
### useBreakpoint: Get Only Breakpoint Status
Source: https://docs.guidewire.com/jutro/documentation/10.11/responsiveness
This example illustrates using the `useBreakpoint` hook solely to determine the current breakpoint. The `breakpoint` value is then used to conditionally render or modify props, such as changing the `label` of a `TextInput` component when the breakpoint is 'phone'.
```javascript
const{ breakpoint }=useBreakpoint({});
return(
);
```
--------------------------------
### DateInput Validation Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/date-range
Demonstrates how to use the onChange prop in the DateRangePicker component to handle validation errors. The onChange callback receives event, value, and errorCode, with separate start and end properties for each. Error codes include INVALID_DATE, MIN_EXCEEDED, and MAX_EXCEEDED.
```javascript
const handleDateChange = (
event: React.ChangeEvent,
value: {
start: {
day: number;
month: number;
year: number;
};
end: {
day: number;
month: number;
year: number;
};
},
errorCode?: {
start?: 'INVALID_DATE' | 'MIN_EXCEEDED' | 'MAX_EXCEEDED';
end?: 'INVALID_DATE' | 'MIN_EXCEEDED' | 'MAX_EXCEEDED';
}
) => {
console.log('Date changed:', value);
if (errorCode?.start) {
console.error('Start date error:', errorCode.start);
}
if (errorCode?.end) {
console.error('End date error:', errorCode.end);
}
};
```
--------------------------------
### Simulating User Interactions with RTL
Source: https://docs.guidewire.com/jutro/documentation/10.11/rtl-patterns
Provides examples of simulating user interactions like clicking a button and typing into an input field using the `userEvent` utility in RTL. It also shows how to emulate tab key presses.
```javascript
userEvent.click(button);
```
```javascript
userEvent.clear(input);
userEvent.type(input,'myValue{enter}');
```
```javascript
userEvent.tab();
userEvent.tab();
```
--------------------------------
### Set Focus on CurrencyInput using useRef
Source: https://docs.guidewire.com/jutro/documentation/10.11/currency
This React component example shows how to use the `useRef` hook to get a reference to the `CurrencyInput` component. Clicking the button triggers a function that calls the `focus()` method on the referenced input, setting the focus imperatively.
```jsx
import{ useRef }from'react';
import{CurrencyInput,Button}from'@jutro/components';
exportfunctionCurrencyInputRef(){
const currencyRef =useRef(null);
constsetFocus=(e)=>{
currencyRef?.current?.focus();
};
return(
);
}
```
--------------------------------
### Set Focus on TextArea using ref in React
Source: https://docs.guidewire.com/jutro/documentation/10.11/textarea
This snippet demonstrates how to use the `useRef` hook in React to get a reference to a `TextArea` component. The `setFocus` function then calls the native `focus()` method on the referenced element, allowing programmatic control over the input's focus state. This is useful for guiding user interaction within forms.
```javascript
exportfunction TextAreaRef(){
const textAreaRef =useRef(null);
constsetFocus=(e)=>{
textAreaRef?.current?.focus();
};
return(
);
}
```
--------------------------------
### Basic TextArea Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/textarea
Demonstrates the basic usage of the TextArea component, requiring only a 'label' prop. Additional props like 'placeholder' and 'secondaryLabel' can be used to enhance its functionality.
```jsx
```
--------------------------------
### Basic Inline Notification Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/inline-notification
A simple example of an Inline Notification component that displays a message and logs a message to the console when dismissed. It is configured to be non-dismissable.
```jsx
```
--------------------------------
### Async Modal Example with ModalNext
Source: https://docs.guidewire.com/jutro/documentation/10.11/modal-component
Demonstrates how to use ModalNext, ModalHeader, ModalBody, and ModalFooter to create an asynchronous modal. It includes state management for modal visibility and processing, and handles modal results to trigger an asynchronous action.
```jsx
const MyModal = ({ isOpen, onResolve }) =>
isOpen ? (
onResolve()} />
);
};
```
--------------------------------
### Timezone Data Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/time-picker
Provides an example of how to define a list of IANA timezones for use with the TimezonePicker component. This list is crucial for populating the available timezone options.
```javascript
const timeZones = [
'Africa/Lagos',
'Africa/Maputo',
'Africa/Monrovia',
// ... and so on
];
```
--------------------------------
### Simple Progress Bar Basic Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/progress-indicator-simple-bar
Demonstrates how to display a basic progress bar indicating the completion percentage of a process. It requires 'completed' and 'total' props to define the progress.
```jsx
```
--------------------------------
### Controlled Year Picker Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/date-year-picker
Provides an example of using the Year Picker as a controlled component by managing its value with React state. It displays the selected year or a waiting message.
```JavaScript
const[picked, setYear]=React.useState({year:undefined});
functionhandleYearChange(event, value){
setYear(value);
}
{picked && picked.year?(
<>
The selected year is {picked.year}.
>
):(
<>
Waiting for the user to specify year.
>
)}
```
--------------------------------
### Accessible-disabled Button Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/ui-elements-states
An example of a button implementing the accessible-disabled state. This state maintains accessibility compliance by using ARIA attributes instead of the native disabled attribute and muting callbacks.
```html
```
--------------------------------
### Lookup Component Usage Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/lookup
Demonstrates the basic usage of the Lookup component, allowing users to select values via keyword search. It highlights its role in content discovery and filtering.
```javascript
import Lookup from '@guidewire/jutro-design-system/lookup';
function MyForm() {
const options = [
{ value: 'apple', label: 'Apple' },
{ value: 'banana', label: 'Banana' },
{ value: 'cherry', label: 'Cherry' },
];
return (
);
}
```
--------------------------------
### Radio Group Validation Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/radio-group
Provides an example of implementing custom validation logic for a RadioGroup. It uses the 'onChange' event and 'stateMessages' prop to display error messages based on user selection.
```JavaScript
import React, { useState, useCallback } from 'react';
import { RadioGroup, Radio } from '@guidewire/components'; // Assuming import path
exportfunctionRadioValidation(){
const[groupValidationMessages, setGroupValidationMessages]=useState({});
const onChange =useCallback((e, newValue)=>{
setGroupValidationMessages({});
if(newValue =='1'){
setGroupValidationMessages({
error:['Only second option can be marked'],
});
}
},[]);
return(
);
}
```
--------------------------------
### Basic Burger Menu Implementation
Source: https://docs.guidewire.com/jutro/documentation/10.11/burger-menu
Demonstrates a basic Burger Menu setup within a Header component. It includes sample menu items and links using BurgerMenuItem and BurgerMenuLink components. This is intended for use within Header UX patterns.
```JSX
Menu Item,
Menu Link,
]}
/>
```
--------------------------------
### DateInput Error Handling Example (React)
Source: https://docs.guidewire.com/jutro/documentation/10.11/simple-date-field
Shows how to display an error message for the `DateInput` component using the `stateMessages` prop. This example highlights setting an error state with a custom message.
```jsx
import React from 'react';
import { DateInput } from '@jutro/components/new';
export const ErrorDateInput = () => {
return (
);
};
```
--------------------------------
### Build React-based Frontends with JDP
Source: https://docs.guidewire.com/jutro/documentation/10.11/platform/getting-started/overview-platform
Jutro Digital Platform (JDP) provides tools and frameworks to build React-based frontends. These applications can be hosted either on Guidewire Cloud or on your own infrastructure, offering flexibility for deployment.
```javascript
/**
* Example of a Jutro app component structure (conceptual).
* JDP provides a framework for building React-based frontends.
*/
// Assuming JDP provides a base component or hook
import { useJutroApp } from '@guidewire/jutro-sdk';
function MyCustomExperience() {
const { data, loading, error } = useJutroApp('/api/customer-data');
if (loading) return
Loading...
;
if (error) return
Error loading data: {error.message}
;
return (
Welcome, {data.customerName}!
Your policy details: {data.policyNumber}
{/* Render other personalized UI elements */}
);
}
export default MyCustomExperience;
```
--------------------------------
### Controlled Time Picker Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/time-picker
Illustrates how to use the TimePicker as a controlled component by managing its state with the `value` prop. The example uses React's useState hook to store and update the selected time.
```JavaScript
import{TimePicker}from'@jutro/components/new';
functionDinnerTimeSelector(){
const[time, setTime]=React.useState({hour:19,minute:30});
functionhandleTimeChange(event, value){
setTime(value);
}
return(
);
}
```
--------------------------------
### Import Jutro TextInput Component
Source: https://docs.guidewire.com/jutro/documentation/10.11/text
Demonstrates how to import the TextInput component from the '@jutro/components' library.
```JavaScript
import{TextInput}from'@jutro/components';
```
--------------------------------
### NotificationAction Component Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/notification-action
This example demonstrates how to use the NotificationAction component to display a notification with a header link, footer link, and a trigger button. It includes the necessary import statement and the component's JSX structure.
```JSX
(
)}
title="This is popover">
lorem ipsum dolor sit amet
```
```JavaScript
import{NotificationAction}from'@jutro/components';
```
--------------------------------
### Jutro Digital SDK: Building Guidewire Cloud Apps
Source: https://docs.guidewire.com/jutro/documentation/10.11/platform/getting-started/overview-platform
The Jutro Digital SDK and helper libraries simplify the process of building React-based web applications on Guidewire Cloud. They provide functionalities for integration with InsuranceSuite APIs, handling validation, authentication, and other essential features for cloud-based development.
```javascript
import { useInsuranceSuiteApi } from '@jutro/sdk';
function DataFetcher() {
const api = useInsuranceSuiteApi();
const fetchData = async () => {
const data = await api.get('/some-resource');
console.log(data);
};
return ;
}
```
--------------------------------
### GridItem Clone Option Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/grid-layout
Provides an example of using `clone={false}` with GridItem when the wrapped component does not pass down the `style` prop correctly. This ensures proper styling by wrapping the component in an extra `
`.
```jsx
```
--------------------------------
### Basic Rendering with RTL
Source: https://docs.guidewire.com/jutro/documentation/10.11/rtl-patterns
Demonstrates the basic usage of the `render` function from `@jutro/test` for mounting components in React Testing Library tests. This replaces standard `mount` or `shallow` functions.
```javascript
render();
```
```javascript
render();
```
--------------------------------
### Basic Slider Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/slider
Demonstrates the basic usage of the Slider component to allow users to select a numeric value by sliding a handle across a bar. It includes a label and a secondary label for clarity.
```HTML
```
--------------------------------
### Filterable Combobox Example
Source: https://docs.guidewire.com/jutro/documentation/10.11/drop-downs-combobox
This example demonstrates how to use the Combobox component with filtering functionality. It utilizes the `useFilteredOptions` hook to manage the list of options based on user input. The component displays a label and a secondary label indicating the filtering behavior.
```TypeScript
exportfunctionComboWithFilter(){
constCHARACTERS=[
{id:'1',label:'Anakin Skywalker'},
{id:'2',label:'Luke Skywalker'},
{id:'3',label:'Master Yoda'},
{id:'4',label:'Han Solo'},
];
const{ filteredOptions, onSearch, resetFilter }=
useFilteredOptions(CHARACTERS);
return(
{filteredOptions.map(({ id, label })=>(
))}
);
}
```
--------------------------------
### MicroFrontend Component Usage
Source: https://docs.guidewire.com/jutro/documentation/10.11/api-surface
Illustrates the usage of the `MicroFrontend` component from the `@jutro/micro-frontends` package. It shows how to configure the source, mode, and routing for a micro frontend, emphasizing that properties and their accepted values can be extended while maintaining support for existing ones.
```JavaScript
import{MicroFrontend}from'@jutro/micro-frontends'
```